readthedocs / sphinx-autoapi

A new approach to API documentation in Sphinx.
https://sphinx-autoapi.readthedocs.io/
MIT License
415 stars 126 forks source link

how to customize titles of the generated pages ? #427

Closed 12rambau closed 2 months ago

12rambau commented 3 months ago

I'm using sphinx-autoapi to build my documentation and specifically the release 3.1.0a3 to build every method of my classes on a specific page: https://geetools.readthedocs.io/en/latest/autoapi/index.html

The problem is that now the titles are way too long to be displayed on a single line and "pre" tags in my html build don't wrap as normal text.

image

I would like to display them as pure h1 as in the pandas documentation to ensure they behave as normal text.

image

I assume I need to modify a template but I didn't understand which one and where to store it when reading your documentation

AWhetter commented 3 months ago

Thanks for trying out an alpha build and providing your feedback! I actually think that it's not great that we use the fully qualified domain name in headings for anything other than modules. It creates too much redundancy, other than maybe in projects where there's very little nesting (like with pandas). So I instead propose that we use the name of the entity as the heading, rather than the fully qualified name.

As for "pre" tags, I've always been on the fence about whether I like the look of the monospaced headings, both on the page and in the side bar. The links that it outputs aren't really useful and, as you say, it comes at the cost of not wrapping. So I'd be up for removing that too.

12rambau commented 3 months ago

So you are even suggesting to change the default template ? I'm happy with that but I think I should wait for https://github.com/readthedocs/sphinx-autoapi/pull/399 to be merged to avoid polluting too much an already complex PR.

In the meantime could you advise on the process I should follow to update the templates ? I'll make an edition to the documentation.

My guess is that I should override these files: https://github.com/ansys/sphinx-autoapi/blob/feat/single-page-option/autoapi/templates/python/class.rst

but I don't know where to store then in my build.

Also I see the the title of the template is just a regular title with "====": https://github.com/ansys/sphinx-autoapi/blob/feat/single-page-option/autoapi/templates/python/method.rst so where is the "pre" tag coming from ?

AWhetter commented 3 months ago

Documentation on editing the templates is here: https://sphinx-autoapi.readthedocs.io/en/latest/how_to.html#how-to-customise-layout-through-templates They can be stored anywhere. But usually you would store them in a directory next to your conf.py file called something like _templates.

v3.1.0a3 isn't using that branch. It's using :py:meth:: https://github.com/readthedocs/sphinx-autoapi/blob/v3.1.0a3/autoapi/templates/python/method.rst