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
Remove duplicated headings for docstrings nested in tabs/admonitions #610
Conversation
Amazing! I can confirm that both the issue exists and the fix works! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot! I had noticed the issue but didn't get time to report it. You reported it, and fixed it, that's awesome 😍
Just a few nitpicks!
Co-authored-by: Timothée Mazzucotelli <pawamoy@pm.me>
d06656e
to
d0f06d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK perfect, thanks so much again!
elif carry_text: | ||
el.tail = (el.tail or "") + carry_text | ||
carry_text = "" | ||
elif self._remove_duplicated_headings(el): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has a wrong behavior: "If text was carried, don't bother stepping into the current element". There is no connection between the two, so it shouldn't be an else
.
elif carry_text: | ||
el.tail = (el.tail or "") + carry_text | ||
carry_text = "" | ||
elif self._remove_duplicated_headings(el): | ||
found = True | ||
break |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has a wrong behavior: "If duplicated headings were found in a child element, stop scanning the rest of the document upwards". Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess there's no specific "why" and the assumption is that duplicated headings appear in a single child element. Do you recommend that we try and remove them from the whole subtree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this was my assumption, that transformations would only nest the duplicated heading block without repeating it. Breaking early should improve the performance if the tree is large, but I have not idea by how much or if this was necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Results from the child element are being propagated to the parent loop and it gets interrupted.
Hi,
As mentioned in #609, nesting a docstring in another block (e.g., tab or admonition) produces duplicated headings.
At the moment, the extension postprocessor only checks inside the immediate root children when removing duplicated heading.
Some markdown extensions move the produced docstring in a nested html node : we only need to search deeply when removing duplicatas.