10000 Sphinx Doc-comments support by tristanlatr · Pull Request #804 · twisted/pydoctor · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Sphinx Doc-comments support #804

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

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

Conversation

tristanlatr
Copy link
Contributor

Fixes #800

tristanlatr and others added 15 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
Copy link
Contributor Author

@lod, this PR introduces support for doc-comments

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@tristanlatr
Copy link
Contributor Author

This code obviously has a bug (the pydoctor_primer diff makes no sens)... Still to be worked on...

@tristanlatr tristanlatr marked this pull request as draft July 8, 2024 20:55
@tristanlatr tristanlatr changed the title Doc-comments support Sphinx Doc-comments support Aug 20, 2024

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@tristanlatr
Copy link
Contributor Author
tristanlatr commented Dec 9, 2024

I’de prefer if the implementation was using ast-comments so the astbuilder code is not mixed with token processing code. But this is not possible because of issues like this: t3rn0/ast-comments#13 . So I'm inclined to merge this implementation.

This comment has been minimized.

This comment was marked as outdated.

@tristanlatr tristanlatr requested a review from a team January 14, 2025 18:33
Copy link

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

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

scrapy (https://github.com/scrapy/scrapy)
+ /projects/scrapy/scrapy/item.py:80: bad docstring: No role entry for "ref" in module "docutils.parsers.rst.languages.en".
+ Trying "ref" as canonical role name.
+ /projects/scrapy/scrapy/item.py:80: bad docstring: Unknown interpreted text role "ref".
- these 31 objects' docstrings contain syntax errors:
+ these 32 objects' docstrings contain syntax errors:
+     scrapy.Item.fields

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

sphinx (https://github.com/sphinx-doc/sphinx)
+ /projects/sphinx/sphinx/locale/__init__.py:219: 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:219: bad docstring: Unknown interpreted text role "confval".
+ /projects/sphinx/sphinx/ext/autodoc/__init__.py:66: bad docstring: Literal block expected; none found.
+ /projects/sphinx/sphinx/project.py:33: bad docstring: No role entry for "confval" in module "docutils.parsers.rst.languages.en".
+ Trying "confva
8000
l" as canonical role name.
+ /projects/sphinx/sphinx/project.py:33: bad docstring: Unknown interpreted text role "confval".
+ /projects/sphinx/sphinx/environment/__init__.py:992: bad docstring: Inline literal start-string without end-string.
+ /projects/sphinx/sphinx/environment/__init__.py:992: bad docstring: Inline literal start-string without end-string.
+ /projects/sphinx/sphinx/environment/__init__.py:1010: bad docstring: Inline literal start-string without end-string.
+ /projects/sphinx/sphinx/environment/__init__.py:1010: bad docstring: Inline literal start-string without end-string.
+ /projects/sphinx/sphinx/transforms/post_transforms/images.py:196: 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:196: 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:314: Cannot find link target for "_sig_element=True"
+ /projects/sphinx/sphinx/builders/__init__.py:92: Cannot find link target for "~.Builder.write_doc" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:92: Cannot find link target for "~.Builder.write_doc" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:92: Cannot find link target for "~.Builder.write_doc" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:92: Cannot find link target for "~.Builder.write_doc" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:92: Cannot find link target for "~.Builder.write_doc" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:87: Cannot find link target for "~sphinx.application.Sphinx.set_translator" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/domains/__init__.py:104: 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:222: Cannot find link target for "LC_ALL"
+ /projects/sphinx/sphinx/locale/__init__.py:222: Cannot find link target for "LC_MESSAGES"
- these 66 objects' docstrings contain syntax errors:
+ these 73 objects' docstrings contain syntax errors:
+     sphinx.environment._CurrentDocument.c_namespace_stack
+     sphinx.environment._CurrentDocument.cpp_namespace_stack
+     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

numpy (https://github.com/numpy/numpy)
+ /projects/numpy/numpy/typing/mypy_plugin.py:101: Cannot find link target for "numpy._core.intp", resolved from "np.intp"
+ /projects/numpy/numpy/typing/mypy_plugin.py:98: Cannot find link target for "numpy._core.number", resolved from "np.number"

@twisted twisted deleted a comment from github-actions bot Jan 14, 2025
@tristanlatr
Copy link
Contributor Author

This one needs a review as well @glyph

Comment on lines +95 to +96
* Add support for doc-comments as found in Sphinx. Use the special comment formatting ``#:`` to start the comment instead of just ``#``.
Comments need to be either on a line of their own before the definition, or immediately after the assignment on the same line.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This needs to move up to in development section

Comment on lines +836 to +837
lines = self.builder.lines_collection[self.module]
if lines:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
lines = self.builder.lines_collection[self.module]
if lines:
if lines := self.builder.lines_collection[self.module]:

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:4499: Cannot find link target for "bottle_sqlite"

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

scrapy (https://github.com/scrapy/scrapy)
+ /projects/scrapy/scrapy/item.py:80: bad docstring: No role entry for "ref" in module "docutils.parsers.rst.languages.en".
+ Trying "ref" as canonical role name.
+ /projects/scrapy/scrapy/item.py:80: bad docstring: Unknown interpreted text role "ref".
- these 31 objects' docstrings contain syntax errors:
+ these 32 objects' docstrings contain syntax errors:
+     scrapy.Item.fields

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/ext/autodoc/__init__.py:67: bad docstring: Literal block expected; none found.
+ /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/environment/__init__.py:1009: bad docstring: Inline literal start-string without end-string.
+ /projects/sphinx/sphinx/environment/__init__.py:1009: bad docstring: Inline literal start-string without end-string.
+ /projects/sphinx/sphinx/environment/__init__.py:1027: bad docstring: Inline literal start-string without end-string.
+ /projects/sphinx/sphinx/environment/__init__.py:1027: bad docstring: Inline literal start-string without end-string.
+ /projects/sphinx/sphinx/transforms/post_transforms/images.py:196: 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:196: 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:303: Cannot find link target for "_sig_element=True"
+ /projects/sphinx/sphinx/builders/__init__.py:92: Cannot find link target for "~.Builder.write_doc" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:92: Cannot find link target for "~.Builder.write_doc" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:92: Cannot find link target for "~.Builder.write_doc" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:92: Cannot find link target for "~.Builder.write_doc" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:92: Cannot find link target for "~.Builder.write_doc" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:87: Cannot find link target for "~sphinx.application.Sphinx.set_translator" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/domains/__init__.py:104: 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 65 objects' docstrings contain syntax errors:
+ these 72 objects' docstrings contain syntax errors:
+     sphinx.environment._CurrentDocument.c_namespace_stack
+     sphinx.environment._CurrentDocument.cpp_namespace_stack
+     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

sdk-python (https://github.com/temporalio/sdk-python): typechecking got 1.09x slower (173.8s -> 188.8s)
(Performance measurements are based on a single noisy sample)

numpy (https://github.com/numpy/numpy)
+ /projects/numpy/numpy/typing/mypy_plugin.py:101: Cannot find link target for "numpy._core.intp", resolved from "np.intp"
+ /projects/numpy/numpy/typing/mypy_plugin.py:98: Cannot find link target for "numpy._core.number", resolved from "np.number"

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:4499: Cannot find link target for "bottle_sqlite"

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

scrapy (https://github.com/scrapy/scrapy)
+ /projects/scrapy/scrapy/item.py:80: bad docstring: No role entry for "ref" in module "docutils.parsers.rst.languages.en".
+ Trying "ref" as canonical role name.
+ /projects/scrapy/scrapy/item.py:80: bad docstring: Unknown interpreted text role "ref".
- these 31 objects' docstrings contain syntax errors:
+ these 32 objects' docstrings contain syntax errors:
+     scrapy.Item.fields

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/ext/autodoc/__init__.py:67: bad docstring: Literal block expected; none found.
+ /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/environment/__init__.py:1009: bad docstring: Inline literal start-string without end-string.
+ /projects/sphinx/sphinx/environment/__init__.py:1009: bad docstring: Inline literal start-string without end-string.
+ /projects/sphinx/sphinx/environment/__init__.py:1027: bad docstring: Inline literal start-string without end-string.
+ /projects/sphinx/sphinx/environment/__init__.py:1027: bad docstring: Inline literal start-string without end-string.
+ /projects/sphinx/sphinx/transforms/post_transforms/images.py:196: 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:196: 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:303: Cannot find link target for "_sig_element=True"
+ /projects/sphinx/sphinx/builders/__init__.py:92: Cannot find link target for "~.Builder.write_doc" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:92: Cannot find link target for "~.Builder.write_doc" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:92: Cannot find link target for "~.Builder.write_doc" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:92: Cannot find link target for "~.Builder.write_doc" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:92: Cannot find link target for "~.Builder.write_doc" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:87: Cannot find link target for "~sphinx.application.Sphinx.set_translator" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/builders/__init__.py:78: Cannot find link target for ".SphinxPostTransform" (you can link to external docs with --intersphinx)
+ /projects/sphinx/sphinx/domains/__init__.py:104: 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 65 objects' docstrings contain syntax errors:
+ these 72 objects' docstrings contain syntax errors:
+     sphinx.environment._CurrentDocument.c_namespace_stack
+     sphinx.environment._CurrentDocument.cpp_namespace_stack
+     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

numpy (https://github.com/numpy/numpy)
+ /projects/numpy/numpy/typing/mypy_plugin.py:101: Cannot find link target for "numpy._core.intp", resolved from "np.intp"
+ /projects/numpy/numpy/typing/mypy_plugin.py:98: Cannot find link target for "numpy._core.number", resolved from "np.number"

src = f.read() + b'\n'
return _parse(src, filename=str(path))

def parseFile(path: Path) -> tuple[ast.Module, Sequence[str]]:
Copy link
Member

Choose a reason for hiding this comment

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

Returning tuples of things can be a code smell; would it make sense to create an object (a ParsedModule) that contains both elements of this tuple?

Copy link
Member
@glyph glyph left a comment

Choose a reason for hiding this comment

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

Comments inline; approved conditional on getting the coverage & licensing a little more tidy, but it doesn't look like that will be hard.

@@ -816,6 +822,25 @@ def _handleAssignment(self,
else:
raise IgnoreAssignment()

def _handleDocComment(self, node: ast.Assign | ast.AnnAssign, target: ast.expr) -> None:
# Process the doc-comments, this is very similiar to the inline docstrings.
Copy link
Member

Choose a reason for hiding this comment

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

Ironically — this comment should probably be a docstring :)

@@ -843,9 +868,11 @@ def visit_Assign(self, node: ast.Assign) -> None:
continue
else:
if not isTupleAssignment:
self._handleDocComment(node, target)
Copy link
Member

Choose a reason for hiding this comment

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

I am slightly suspicious that these two functions seem to be always called together. Should they be tied together more closely?



# Part of the sphinx.pycode.parser module.
# Copyright 2007-2020 by the Sphinx team, see AUTHORS.
Copy link
Member

Choose a reason for hiding this comment

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

Could this code be isolated to a separate file to make license provenance at least a little less confusing?

if isinstance(other, int):
return self.kind == other
elif isinstance(other, str):
return bool(self.value == other)
Copy link
Member

Choose a reason for hiding this comment

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

Coverage gaps like this are one reason I hate vendoring stuff this way 😬 . Could the examples be expanded to cover these cases at least?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know I don’t really like that neither. I could refactor the functions to use the standard tokenize objects and drop the wrapper copied from Sphinx… adding more test cases to cover all these branches seems like a comparable amount of work.

anyway It’s the busy period for me, I probably won’t have time to get this done until September

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It might be a good opportunity to use doctests since we recently enabled them (#888). If you have time to submit suggestions of doctests that would cover the gaps that would awesome. @glyph

@@ -60,9 +60,6 @@
from pydoctor.epydoc.markup.plaintext import ParsedPlaintextDocstring
from pydoctor.epydoc.docutils import new_document

#: A dictionary whose keys are the "consolidated fields" that are
Copy link
Me CEB7 mber

Choose a reason for hiding this comment

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

Huh, why remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the doc-comment is redundant. It was triggering a pydoctor warning, rightfully. So I removed it.

@@ -18,7 +18,6 @@ def test_get_assign_docstring_node() -> None:
astutils.Parentage().visit(tree)
assert astutils.get_str_value(astutils.get_assign_docstring_node(tree.body[0])) == "inline docs" # type:ignore


Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is probably coming from a merge conflict resolution that i did from the GitHub ui

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for doc comments
2 participants
0