Skip to content
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

Autodoc generated documentation overflow for python classes with a long import path #1631

Open
federicodabrunzo opened this issue Nov 19, 2024 · 2 comments
Labels
Bug A bug Needed: replication Bug replication is required

Comments

@federicodabrunzo
Copy link

Problem

The documentation generated with the autoclass directive for python classes placed in a module with a long import path overflows the wy-nav-content div.

Reproducible Project

https://github.com/federicodabrunzo/render-issue-for-autodoc-generated-class-with-long-import-path/tree/main?tab=readme-ov-file

Error Logs/Results

image

Expected Results

The <dt> element containing the class import path should not overflow its containing elements.

Environment Info

  • Python Version: 3.11.9
  • Sphinx Version: 8.1.3
  • RTD Theme Version: 3.0.1
@federicodabrunzo federicodabrunzo added Bug A bug Needed: replication Bug replication is required labels Nov 19, 2024
@arthur-tacca
Copy link

arthur-tacca commented Nov 23, 2024

To fix just on your specific project, you could put the following line in your custom CSS. See the image at the end of this StackOverflow answer for the effect (look at "SomeLongModule.SomeLongClassName"). It breaks long identifiers (or any long word) but only if strictly necessary to fit everything within the width.

html.writer-html5 .rst-content { overflow-wrap: break-word }

This is not to say that this bug report is invalid. IMO, the theme should include that styling by default.

A disadvantage of this approach is that the break can be anywhere in the identifier, whereas maybe it would be better to only break next to a dot (i.e. "foo.bar" becomes "foo.\nbar"). I don't think that can be done in CSS though so it would need a change in document generation in sphinx itself rather than in the theme (to insert <wbr> elements next to dots). But I actually quite like that the above CSS works even with long identifier fragments and non-identifier words.

@federicodabrunzo
Copy link
Author

@arthur-tacca Thanks for reporting this — it works fine for my usecase :)

IMO, the theme should include that styling by default.

I agree with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug Needed: replication Bug replication is required
Projects
None yet
Development

No branches or pull requests

2 participants