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

Do a real distinction in between the code model and the view model #798

Open tristanlatr opened 3 weeks ago

tristanlatr commented 3 weeks ago

The view model would be initiated from a generated set of code models. The separation between the two models could firstly be done with Protocol classes (so we keep a unique structure at first) defining all required attributes by astbuilder and templatewriter. Classes that would be used to annotate Documentable to restrict the attributes that can be accessed.

Then we could look at creating two sets of concrete classes.

The main challenge of that operation (and probably the reason it has not been done a long time ago) is that the code model is strongly couple with the docstring parsing. Namely:

The main goal being not perform docstring parsing until we have the final state for all objects. This issue might be solvable with an ast transformer. But I need to dig into that problematic a little bit - for instance we need to ensure that the line numbers are not altered by the transformation.

Once we really have this separation, we'll be abler to look at making our parser interchangeable.