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 inline docstring confusion #815

Open
wants to merge 52 commits into
base: master
Choose a base branch
from

Conversation

tristanlatr
Copy link
Contributor

Fixes #813

tristanlatr and others added 30 commits May 20, 2022 02:49
This attribute was used to attach the right docstring node to the right Attribute object. Now it uses AST node navigation (with the .parent attribute) instead for fetching the docstring node for an ast.Assign.

This change might not be worth it, on the one hand it removes a attribute beeing mutated at different palces in the code, but replaces this kind of "unsafe" state tracking (meaning not with pop() and push()) by some more verbose solution that involves adding the .parent attribute on all nodes.

The zopeinferface extension needed to be adjusted as well because it relied on the docstring assigment feature in an implicit way, now it's explicit what we're doing.
…hpinx... Refactor for a better separation of docstring sources. And add a test.
@tristanlatr tristanlatr added the pending This ticket needs code related to another ticket not yet fixed label Sep 22, 2024
Copy link

codecov bot commented Sep 22, 2024

Codecov Report

Attention: Patch coverage is 89.92806% with 14 lines in your changes missing coverage. Please review.

Project coverage is 91.99%. Comparing base (5be6898) to head (ed1fc41).

Files with missing lines Patch % Lines
pydoctor/astutils.py 87.73% 8 Missing and 5 partials ⚠️
pydoctor/astbuilder.py 96.96% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #815      +/-   ##
==========================================
- Coverage   92.03%   91.99%   -0.05%     
==========================================
  Files          47       47              
  Lines        8465     8590     +125     
  Branches     1868     1897      +29     
==========================================
+ Hits         7791     7902     +111     
- Misses        395      403       +8     
- Partials      279      285       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

Diff from pydoctor_primer, showing the effect of this PR on open source code:

bottle (https://github.com/bottlepy/bottle)
+ /projects/bottle/bottle.py:4602: Cannot find link target for "bottle_sqlite"
+ /projects/bottle/bottle.py:2206: Cannot find link target for "latin1"

pydoctor (https://github.com/twisted/pydoctor)
+ /projects/pydoctor/pydoctor/epydoc/markup/restructuredtext.py:61: Existing docstring at line 31 is overriden

sphinx (https://github.com/sphinx-doc/sphinx)
+ /projects/sphinx/sphinx/locale/__init__.py:220: bad docstring: No role entry for "confval" in module "docutils.parsers.rst.languages.en".
+ Trying "confval" as canonical role name.
+ /projects/sphinx/sphinx/locale/__init__.py:220: bad docstring: Unknown interpreted text role "confval".
+ /projects/sphinx/sphinx/project.py:33: bad docstring: No role entry for "confval" in module "docutils.parsers.rst.languages.en".
+ Trying "confval" as canonical role name.
+ /projects/sphinx/sphinx/project.py:33: bad docstring: Unknown interpreted text role "confval".
+ /projects/sphinx/sphinx/ext/autodoc/__init__.py:60: bad docstring: Literal block expected; none found.
+ /projects/sphinx/sphinx/transforms/post_transforms/images.py:190: bad docstring: No directive entry for "todo" in module "docutils.parsers.rst.languages.en".
+ Trying "todo" as canonical directive name.
+ /projects/sphinx/sphinx/transforms/post_transforms/images.py:190: bad docstring: Unknown directive type "todo"... todo:: This should be refactored not to store the state without class
+           variable.
+ /projects/sphinx/sphinx/ext/intersphinx/_shared.py:36: bad docstring: No role entry for "confval" in module "docutils.parsers.rst.languages.en".
+ Trying "confval" as canonical role name.
+ /projects/sphinx/sphinx/ext/intersphinx/_shared.py:36: bad docstring: Unknown interpreted text role "confval".
+ /projects/sphinx/sphinx/addnodes.py:299: Cannot find link target for "_sig_element=True"
+ /projects/sphinx/sphinx/builders/__init__.py:73: Cannot find link target for "~sphinx.application.Sphinx.set_translator" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/domains/__init__.py:106: Cannot find link target for "self.data" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/ext/intersphinx/_shared.py:29: Cannot find link target for "~sphinx.builder.html.INVENTORY_FILENAME" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/locale/__init__.py:223: Cannot find link target for "LC_ALL"
+ /projects/sphinx/sphinx/locale/__init__.py:223: Cannot find link target for "LC_MESSAGES"
- these 64 objects' docstrings contain syntax errors:
+ these 69 objects' docstrings contain syntax errors:
+     sphinx.ext.autodoc.py_ext_sig_re
+     sphinx.ext.intersphinx._shared.IntersphinxMapping
+     sphinx.locale._
+     sphinx.project.Project.source_suffix
+     sphinx.transforms.post_transforms.images.ImageConverter.available

docutils (https://github.com/docutils/docutils)
+ /projects/docutils/docutils/docutils/__init__.py:201: Cannot find link target for "None"
+ /projects/docutils/docutils/docutils/__init__.py:204: Cannot find link target for "None"
+ /projects/docutils/docutils/docutils/__init__.py:226: Cannot find link target for "docutils.frontend.validate_*"

numpy (https://github.com/numpy/numpy): typechecking got 1.08x slower (175.2s -> 189.0s)
(Performance measurements are based on a single noisy sample)
+ /projects/numpy/numpy/typing/mypy_plugin.py:118: Cannot find link target for "numpy.intp", resolved from "np.intp"
+ /projects/numpy/numpy/typing/mypy_plugin.py:115: Cannot find link target for "numpy.number", resolved from "np.number"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending This ticket needs code related to another ticket not yet fixed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inline docstring is confused if there is a comment
1 participant