Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove redundant class info for subclasses #87

Merged
merged 1 commit into from
Jul 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions docfx_yaml/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,24 +797,29 @@ def insert_children_on_class(app, _type, datam):
insert_class = app.env.docfx_yaml_classes[datam[CLASS]]
# Find the parent class using the module for subclasses of a class.
parent_class = app.env.docfx_yaml_classes.get(datam[MODULE])
if parent_class:
insert_class += parent_class

# Find the class which the datam belongs to
for obj in insert_class:
if obj['type'] != CLASS:
continue
# Add subclass & methods & attributes & properties to class
if _type in [METHOD, ATTRIBUTE, PROPERTY, CLASS] and \
(
# If obj is either method, attr or prop of a class and not self, or
(obj[CLASS] == datam[CLASS] and obj != datam) or \
# If datam is a subclass of another class.
(_type == CLASS and obj['class'] == datam['module'])
):
(obj[CLASS] == datam[CLASS] and obj != datam):
obj['children'].append(datam['uid'])
obj['references'].append(_create_reference(datam, parent=obj['uid']))
insert_class.append(datam)

# If there is a parent class, determine if current class is a subclass.
if not parent_class:
return
for obj in parent_class:
if obj['type'] != CLASS:
continue
if _type == CLASS and obj['class'] == datam['module']:
# No need to add datam to the parent class.
obj['children'].append(datam['uid'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is datum['parent'] already set to obj['uid']?

I'm pretty sure parent and children should agree.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't actually keep track of parent, it's only tracked in the reference after the fact.

In this case we have datam['module'] which is equivalent to datam['parent'], so I think we're good (we'll never have a subclass that's in a different module).

obj['references'].append(_create_reference(datam, parent=obj['uid']))


def insert_children_on_function(app, _type, datam):
"""
Expand Down