Generating docspec with pydoctor
#20
Replies: 6 comments 6 replies
-
Hey @tristanlatr , haven't had a lot of time to think about this yet, but I'll respond tomorrow. |
Beta Was this translation helpful? Give feedback.
-
Hi @tristanlatr , Thanks for your thoughts! I'll try to cover each point and give my perspective.
The main reason that docspec is using Docspec is intended as only a slightly higher-level API compared to an abstract syntax tree. It leaves the interpretation of that tree to the client (i.e. any information derived from content rather than structure). Pydoctor seems to be doing a lot of that interpretation, and with that perspective in mind I would see how pydoctor could rely on docspec to build it's interpreted documentable tree, but not the other way around as you are suggesting.
Can you elaborate what you are currently getting out of the docspec <-> pydoctor integration? Is it only the JSON de/serialization or where you aiming to feed the results into Pydoc-Markdown?
This "kind" information would be derivable from the other information in the docspec tree (e.g. module is a package if it has modules under it/if it's filename is
Same as above.
I like the idea of recording external references because right now the information is simply not present and prevents clients to properly resolve the full qualified name of referenced names (for example in
The name
As I mentioned above I don't see pydoctor as a potential drop in replacement for two main reasons, but if you still want to build a Sorry for the overall negative vibe. Maybe there is some clarification to be added in the README/docs to describe exactly what docspec is intended to be. I hope I was able to show you my point of view on your points, the purpose I see for docspec in this context and why I don't quite think it matches with pydoctor as you suggest. Kind regards, |
Beta Was this translation helpful? Give feedback.
-
For your awareness, I migrated this to the Discussions section. :) |
Beta Was this translation helpful? Give feedback.
-
Hi,
Single lines comments are the comments starting by
I'm OK with dumping less interpreted data and doing more of the interpretation in pydoctor json builder, it will probably create some code duplication with our ast builder, tough. In terms of interpretation, are you talking about the modules hierarchy ? Pydoctor generates nested modules inside modules. I understand the I'm not sure regarding the
That is definitively the goal. This is also why I want to make this work. I like the idea of the creation of a new class Tell me what you think, Thanks |
Beta Was this translation helpful? Give feedback.
-
That is correct. If you feel like this would work, feel free to give it a try. Still I believe using libCST would probably make the loader code more maintainable and reliable.
Docspec supports nested modules as of recently, I need to update the docspec-python loader though.
Something like this I, yes. I would keep Best |
Beta Was this translation helpful? Give feedback.
-
Thanks. |
Beta Was this translation helpful? Give feedback.
-
Hi @NiklasRosenstein ,
I've been working on generating
docspec
classes frompydoctor
's internals.I think it could replace the current
docspec-python
parser. This would avoid you to rewrite a new parser as described in #3.I've written the serializer with the visitor pattern, you can see the code here: https://github.com/twisted/pydoctor/blob/json-docspec/pydoctor/jsonbuilder.py#L213
It's currently using a modified version of
docspec
, but it's working great.The main changes that I've done are the following:
ApiObject.kind
attribute which is a list of all possibles python objects types. See https://github.com/twisted/pydoctor/blob/json-docspec/pydoctor/docspec/__init__.py#L90. This could be removed if theFunction.modifiers
attribute is moved toApiObject.modifiers
such that we can store this information there.docspec
repository, but if you like it I can submit it as well. See https://github.com/twisted/pydoctor/blob/json-docspec/pydoctor/zopeinterface.py#L330Data
such that the links can be correctly linked to objects documentation when using the local name.decorations: List[Decoration]
bydecorators: List[str]
. I found theDecoration
object not really optimal, it's harder to dump from AST because the name is separated from the arguments. I'm currently usingastor.to_source
to dump theast.Call
object to string. This is the only thing i'm not sure how to do, any help appreciated.I could send a few patches to introduces the required changes, then we can introduce a new module
docspec_pydoctor
of something, that will offer very similar interface asdocspec_python
, but using thepydoctor
parser, such that both implementation can live of a period of time.Tell me what you think
Thanks
Beta Was this translation helpful? Give feedback.
All reactions