-
-
Notifications
You must be signed in to change notification settings - Fork 157
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 |
#define DOC_CURSORS_CURSOR "Cursor(constant=...) -> Cursor\nCursor(cursor) -> Cursor\nCursor(size, hotspot, xormasks, andmasks) -> Cursor\nCursor(hotspot, surface) -> Cursor\nPygame object representing a cursor." | ||
#define DOC_CURSORS_CURSOR_COPY "copy() -> Cursor\nCopy the current cursor." | ||
#define DOC_CURSORS_CURSOR_TYPE "type -> Literal['system', 'color', 'bitmap']\nGet the cursor type." | ||
#define DOC_CURSORS_CURSOR_DATA "data -> ...\nGet the cursor data." |
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.
I think that the original typehint tuple
was better here.
Basically, I think that we shouldn't use ...
to replace tuple[big list of stuff here]
, in such cases it is probably better to display tuple
.
I think the same strategy could be applied to list
/dict
/etc as well.
Union
and Optional
are also cases that may be need to be handled specially. I think it is better to leave those as is.
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: