twisted / pydoctor

This is pydoctor, an API documentation generator that works by static analysis.
https://pydoctor.readthedocs.io
Other
186 stars 49 forks source link

Add support for doc comments #800

Open lod opened 4 months ago

lod commented 4 months ago

Sphinx supports doc comments in the form of #:.

This is also part of the expected and documented syntax for the google and numpy formats, supported in the sphinx implementation but not here.

The format isn't formalised in a PEP, but it is fairly widely used and should be supported. If a decision is made not to support it I believe that should be formally documented, especially in relation to the google and numpy format support.

tristanlatr commented 4 months ago

Hello @lod and thanks for your interest in pydoctor.

This feature would be great to have I agree! And the fact we do have this kind of docs in our demo makes it embarrassing not to support it. The main issue is that we don’t have the comments/tokens information in the model at the moment, we only work with the abstract syntax tree from the standard library.

I believe this could be implemented as a token aware ast transformer that would create legit Constant nodes (inline docstrings) based on doc comments. This way we don’t have to touch the astbuider code or only to add the preprocessing step.

tristanlatr commented 4 months ago

What happens if both syntax are used ? I'de suggest that we leave a warning and the inline docstring is used.