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: deduplicate entries in children and references #61

Merged
merged 4 commits into from
Jun 28, 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.


There was an issue with the way Sphinx imports docstrings, and processes certain items twice in process_docstring function. Instead of checking for duplicate entries in the children/reference, we'll check to see if we've already processed a docstring or not and solve it from the root cause.

Fixes internally filed issue

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

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

@dandhlee dandhlee added the type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. label Jun 25, 2021
@dandhlee dandhlee requested review from tbpg and a team June 25, 2021 06:58
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jun 25, 2021
Comment on lines 634 to 635
# Checking in dictionary("{}") takes O(1) average time for a bit more space,
# whereas checking in lists("[]") takes O(n) average time.
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure we need this, but it doesn't hurt. Using a dict as a set is standard.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done.

@@ -626,6 +628,15 @@ def process_docstring(app, _type, name, obj, options, lines):
"""
This function takes the docstring and indexes it into memory.
"""

# Check if we already processed this docstring.
if name not in app.env.docfx_uid_names:
Copy link
Contributor

Choose a reason for hiding this comment

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

I would flip this, returning early if it's already processed. Then, you don't need the else.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done!

@dandhlee
Copy link
Collaborator Author

Thank you! Ready for review :)

@dandhlee dandhlee requested a review from tbpg June 25, 2021 21:57
@tbpg tbpg merged commit 6d5407b into master Jun 28, 2021
@tbpg tbpg deleted the deduplicate_entries branch June 28, 2021 17:16
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. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants