-
-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
Doc: Summary table for pathlib #126342
base: main
Are you sure you want to change the base?
Doc: Summary table for pathlib #126342
Conversation
Thanks for doing the work to create these tables. Concrete examples are much better for discussion. When I look at this table, I find the repeated class names distracting and obscuring the thing I want to see, the method names. I'd love to find a way to let the method names stand out more. I doubt rst could make them bold. |
It doesn't look like it's possible: https://docutils.sourceforge.io/FAQ.html#is-nested-inline-markup-possible. I tried just in case, but it really doesn't work. The workaround proposed would not be realistically maintainable, and I can't make it work for internal links: Here is an |Path.lchmod|_.
.. |Path.lchmod| replace:: Path.\ **lchmod**\ (mode)
.. _Path.lchmod: :meth:`Path.lchmod` renders as I could remove the class name completely, but it would become misleading. Also, the distinction between |
The table is struggling to fit on mobile, likely due to some long entries with no spaces for it to break on like We could adjust CSS to use something like Or dropping class names would help. Here's just one removed here, shall we try with more? I also recommend using reST's https://sublime-and-sphinx-guide.readthedocs.io/en/latest/tables.html#list-table-directive |
I'd prefer list-tables too, but AFAIK it's not possible to span cells over multiple columns like I do for the section titles. I tried to use multiple tables in the I'm afraid that completely dropping class names might be confusing. I would like to have similar tables in many module documentations, and it wouldn't play well if there are both methods and functions in a module. How about using |
To answer @nedbat's comment, one way to make the method names stand out is to put the link on the method only, and not the class. I did an example using the Another format can be used for the "PP." part: |
This pathlib summary table seems like a great addition and I am excited to see these summary tables being added to the Python documentation.
How about Changing Putting a |
Here is what it looks like with
I'd prefer to keep the same signature in the table and for the function, to avoid confusion for both the reader and future doc maintainers.
|
We could use flat-table, but it's an external sphinx extension that would add a new dependency. As a newcomer, I don't know if it's worth it. |
We generally avoid using external extensions, as downstream redistributors often build without them. |
Thanks for putting this together. I'm a little uneasy about the table needing to be manually maintained, when other documentation tools (I'm thinking of Doxygen) can automatically create these summary tables. But I don't know too much about CPython docs practices, so if others are fine with it, then I am too. |
Initially I had the same thought. I tried to play with autosummary, but I couldn't make it work, I don't know why. I abandoned the idea because that would pull the documentation from the docstrings, while the rest of the documentation in the RST files is independent, as far as I know. The initial tables are indeed tedious to write, but all the python documentation is actually written by hand, independently of the code. |
In the same vein as #125810, this PR adds a table summary to the
pathlib
module documentation. It helps to view all the available attributes and methods at a glance.See also the discussion on Discourse
Direct link to the modified
pathlib
documentation📚 Documentation preview 📚: https://cpython-previews--126342.org.readthedocs.build/