-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Use one header per function on the API docs pages #23332
Comments
Alternately, I wonder if there is some way Furo itself could be improved to make this better. I'm working on a glossary (#23293) and noticing an absence of the right toc there too, which is not so easily fixed by just adding redundant headers. Or maybe there already are some other ways to adjust the right sidebar toc? CC @pradyunsg |
Furo "just" uses the toc that Sphinx provides -- https://github.com/pradyunsg/furo/blob/c790c6d7a33f45856fa85670a4238a101efefd08/src/furo/theme/furo/page.html#L206 and uses some CSS to make it look better + JS to highlight the current item. The fact that you can't do this is a known limitation of Sphinx's autodoc at this time, see sphinx-doc/sphinx#6316 (comment). Switching to alternative automated generators (apidoc) might make things easier for you! :) |
I dunno how to deal with Glossaries TBH. The only thing that I can think of is basically mimicking what sphinx-apidoc does for injecting the relevant headings. This stuff might make sense in a separate Sphinx extension, just to make it easier to have tests + CI checks for it. |
Hmm, so it sounds like I should dig into autodoc and see if it's possible to make it generate the toc without using headers. The headers are redundant on the page, so if we can avoid having them that would actually be better. Or I should just look at how hard fixing that upstream Sphinx issue would be. |
This upstream Sphinx PR will make each function, class, and method docstring appear in the table of contents (i.e., in the right sidebar). This means that headers like sympify ^^^^^^^ .. autofunction:: sympify are now redundant. This can be merged before the upstream Sphinx PR is merged, however, until a Sphinx release is made with it, those pages will not have headers for the functions. However, the use of the above one-header-per-function style was done very inconsistently throughout the reference pages. This PR also - Changes all index.rst pages to use :titlesonly: instead of :maxdepth:. This makes the table of contents pages only show the table of contents for actual pages. With each function included in the ToC, showing them all on the index page made the table of contents quite large in many cases. These index pages are still mostly useless, especially given the left sidebar. I leave it to a future PR to either do something better with them or remove them entirely. This is related to sympy#23333. - I have split the mechancs, vector, and physics vector API toc into separate index pages. This does not affect the URLs of the pages themselves (the API pages were already in separate api/ subdirectories), but it does make the left sidebar put these API pages under a separate foldable API heading. - A few very minor cleanups. I have left most things intact they way they were, even in instances where things could clearly be improved. Fixes sympy#23332.
So great news. Upstream support is being added to Sphinx for this in sphinx-doc/sphinx#10807. I have made a PR cleaning up the now duplicate headers at #24050. |
Since the API pages in the docs have a long listing of functions, with the new Furo Sphinx theme, it becomes easier to navigate them when there is a single header per function. Compare the right sidebar on https://docs.sympy.org/dev/modules/core.html which has this with https://docs.sympy.org/dev/modules/ntheory.html which does not.
This will become unnecessary once we use autosummary, but that is not so easy to do for various reasons (see #22589).
The most simple way to do this is to manually list each function in the rst file rather than using automodule. However, the issue with doing this is that we may forget to add new functions to the rst. The coverage_doctest script could help with this but 1) it is not currently working (see #22429) and 2) the current coverage is not 100%, so we couldn't require 100% coverage until we fix this. Having 100% coverage itself is problematic because we would actually want a full coverage documentation to be separate somehow (see #22105). I think long term though we want to do this anyway, so it's not a bad idea to aim for this.
Another thought would be to see if we can modify the autodoc templates so that
automodule
produces subheaders automatically. I'm not sure how difficult this would be.See also the discussion at #23159.
The text was updated successfully, but these errors were encountered: