Summary tables as an API overview

I think that my PR is ready to be merged. If not, please tell me what to improve.

My PR was merged, thanks! It’s my first official contribution to Python :fireworks:

I followed up with another summary table, this time for pathlib: PR, Preview. The number of attributes and methods is quite big: 6 classes, 11 attributes, 59 methods. Despite the good documentation, it can be hard to remember them all. I hope that this table can be of help.

6 Likes

What’s the progress on this? The library docs still have expanded ā€œBuilt in Functionsā€ and ā€œBuilt in Constantsā€ sections on the main page, and the decrease in usability is significant (for me, at least) compared to the 3.11 and earlier docs.

3 Likes

Sorry, slipped my mind. I’ll have another look now.

A

2 Likes

I’ve made a terser summary table for pathlib in this PR A more compact pathlib summary by nedbat Ā· Pull Request #127911 Ā· python/cpython Ā· GitHub

  • Removed class names and parameters from the summary
  • Used parentheses uniformly to indicate methods
  • Shortened some of the summary descriptions (more could be done here)
  • Moved ā€œexceptionsā€ to the end

My goal was to let the most pertinent information (the method name) stand out, and to keep the table rows short for smaller screens.

Doc build preview: pathlib — Object-oriented filesystem paths — Python 3.14.0a1 documentation

1 Like

Another gentle ping on this. I appreciate that it’s one job among many, but personally if it’s likely to take some time to improve the situation, I’d be in favour of simply reverting the previous change in the meantime - the current behaviour is a significant regression.

3 Likes

This is much better on mobile. Left is the earlier python/cpython#126342 and right is the new python/cpython#127911:

6 Likes

I quite like this proposal @nedbat overall; this removes a lot of redundant information, which makes the whole table easier to read and cleaner (across viewport sizes, including mobile).

2 Likes

What if this top summary has only the top-level element? The classes’ attributes and methods would be in a class-level summary.

The summary would be cleaner, and the attributes/methods would be contextualized more.

TBH, I’m not sure the best approach. The math page has a summary table with parameters included. But those function names are short, and the parameter names tend to be short, so it doesn’t cause a problem there.

Indeed, math mostly has short function names with just one or two single-character parameters, and they don’t make the table too wide.

I think it’s okay to pick whichever style makes sense for a given table, and be consistent within that table.

8 Likes

Is it worth me raising an issue for this? It’s been a couple of months now and for me it’s a serious usability problem. If having an issue will make it less likely to fall off people’s radar, I’m happy to raise one, but I don’t want to create more admin if it won’t help.

3 Likes

Let’s give a few more days until the new year in case @AA-Turner is available, but I think by now we could just revert it (python/cpython#125757 is the PR in question), and it can always be fixed and re-applied later.

3 Likes

I’ve opened python/cpython#128406 to revert.

1 Like

Now reverted (in #128406). To solve this elegantly we might need to add a new feature to Sphinx – we want to exclude object descriptions from the ā€œglobalā€ table of contents (generated by the .. toctree:: directive), but still to include them on each individual page.

Sorry for the disruption here!

A

4 Likes

Confirmed, the TOC page is now back to its old form. Thanks for this!

I created a similar post, not knowing about this one. I do think my thoughts are slightly different.

I do not like the summary in the sidebar. They do make the sidebar look too messy and take up too much horizontal space. It is easy to click the link to the section.
(Regarding horizontal space, I really hate it when sidebars are wide and do not have any way to change width or hide when the browser window is narrowed. It can make a page almost unusable when the browser is half the width of a typical screen.)

I still think the idea of adding collapsible items that expand to show a list are the best way to provide a more full featured TOC and still allow keeping it compact for normal/default viewing.
My primary wants are a list of classes, methods for each class and functions for each module. I am constantly using ā€œfindā€ in the browser to get to the function I want. An even bigger issue is that I cannot search unless I know what function I am looking for. As far as I know, there isn’t even a list of functions or methods in the body of the doc, which leaves the user to read through the entire documentation to see what is there.

My topic is at Improve documentation page navigation, specificly by adding a function list and I am going to mark it as closed.

2 Likes

Thanks for bringing this subject back! I confirm that this is my goal as well. I tried to work towards this, but I found that it was complicated to converge towards a solution fitting every page, because each module documentation seems maintained by different people with different views on what is best. My idea was to incrementally add tables to the documentation, but lack of consensus and lack of time on my side made me stop for now.

I think a larger hurdle is that different pages need different approaches. Pathlib and builtins have different needs, so it’s very hard to find a one-size-fits-all solution, or even a crisply defined rubric about how to approach each page.

See A more compact pathlib summary by nedbat Ā· Pull Request #127911 Ā· python/cpython Ā· GitHub for a discussion about Pathlib.

2 Likes