twisted / pydoctor

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

Docutils is slow for constructor links #786

Closed tristanlatr closed 2 months ago

tristanlatr commented 2 months ago

Just parsing constructor docstrings takes 4.6% of time (based on a --make-intersphinx run which skip html generation, the step that takes most of the time) because of this line in docutils which is always reached from the constructor docstrings parsing. I suspect this is because we're generating a link tag with a label with parenthesis like `Class(arg2, arg2) <module.Class.__init__>`; This label probably makes docutils go in some cold/unoptimized branches which are very time consuming...

https://github.com/twisted/pydoctor/blob/936db9373becb1e3d2ca7a94601fad4c76faf7da/pydoctor/epydoc2stan.py#L1150

The solution would be to avoid parsing restructuredtext programmatically, instead construct the document node manually.

tristanlatr commented 2 months ago

Using epytext is also another solution