-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
Generate reST/ref docs from python or stub files, move time and cursors docs #3188
base: main
Are you sure you want to change the base?
Conversation
5e95dd3
to
ae70cfa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this is a really good idea and should make things better, thanks a lot for getting work started on this!
I have left a couple of thoughts/reviews for your consideration
I'm curious about the flexibility of this system. Can we have content in the rst docs that surrounds content pulled from stubs? I feel like it would to nice to have method docs pulled in from stubs into a manually set up page with examples and other things. Why are the cursor docstrings in the Python code for Python modules? All modules have stubs that can be used. |
I don't see why we wouldn't have examples and "other things" already in the docs but yes we can, though it is a bit more verbose. Say you wanted to add some extra info under .. autopgmodule:: pygame.time
.. autopgfunction:: get_ticks
.. autopgfunction:: wait
.. autopgfunction:: delay
This sentence will be right under delay's docs (note the extra newline above).
.. autopgfunction:: set_timer
.. autopgclass:: Clock
:members:
Because I wanted those to be proper docstrings that get picked up by python. If we put them in the stub files things like the builtin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a hard PR to approve because it changes our approach to documentation significantly.
But this should lead to a really nice improvement in user experience.
I like how you did it as two example modules at first, minimizing the changes. I like your writeup. I like that you are not a drive by contributor and if this breaks I can ping you about it 😄
So with that in mind, thank you for the PR-- let's try this out!
Related to #2757
This PR implements autodoc style documentation generation. This allows us to have documentation in python files or (if the module is implemented in C) in stub files. It uses autoapi because stub files are not runnable python files thus we cannot use autodoc. These changes are under the commit Generate reST/ref docs from python or stub files.
This PR also ports two modules (time which is a C based module and cursors which is a python based module) as reference. Following modules can be easily ported based on these by anyone.
The generated docs should look almost the same. The only changes are to signatures and summary lines. Signatures will now use the stubs as their source, which means that argument names and default values should be more accurate. But this also means that we cannot just write anything there. Because of this return values are now types (or just "..." if it is too complex) not some descriptive names. Summary lines also change a bit to conform to the convention of having a full sentence as the first line of docstrings (this of course can be reverted if others are against it).
Future work related to this: