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

Conversation

dandhlee
Copy link
Collaborator

Before you open a pull request, note that this repository is forked from here.
Unless the issue you're trying to solve is unique to this specific repository,
please file an issue and/or send changes upstream to the original as well.


Previously when I simply concatenated the parent_class info to insert_class to combine the list and iterate through the combined list of the two, unfortunate things happened.

  • insert_class is a pointer reference to app.env.docfx_yaml_classes[datam[CLASS]], so modifying insert_class reflects the data stored in app.env.docfx_yaml_classes and we took advantage of that below.
  • When I extended insert_class with parent_class, that's where the duplication happened by echoing the parent_class data literally onto the corresponding app.env.docfx_yaml_classes[datam[CLASS]].

This is now avoided by handling them separately.

Also, when adding the subclass to its parent we only need to include its info in the reference and under children section of the yaml, so we do not need to append datam to the parent class, since this would be redundant information we echo onto the parent class.

Fixes #86

It's a good idea to open an issue first for discussion.

  • Tests pass
  • Appropriate changes to README are included in PR

@dandhlee dandhlee requested review from tbpg and a team July 29, 2021 05:41
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jul 29, 2021
Copy link
Contributor

@tbpg tbpg left a comment

Choose a reason for hiding this comment

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

One comment, otherwise looks good.

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).

@dandhlee dandhlee merged commit 06bb556 into master Jul 29, 2021
@dandhlee dandhlee deleted the fix_class_children branch July 29, 2021 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redundant subclass info gets added to the parent class and messes up subclass yaml
2 participants