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

Title line overflows in documentation #365

Open
aryankeluskar opened this issue Jul 6, 2024 · 3 comments
Open

Title line overflows in documentation #365

aryankeluskar opened this issue Jul 6, 2024 · 3 comments

Comments

@aryankeluskar
Copy link

Describe the bug

While browsing the documentation for statsmodels, certain functions have really long names that overflow. The problem is the text doesn't wrap, causing some of the text to not be selectable or even visible (as showing in the image). Eg: https://www.statsmodels.org/stable/generated/statsmodels.regression.mixed_linear_model.MixedLM.html

Original:

image

Potential Fix 1:

I believe this could be a simple fix by enabling overflow to scroll. A potential solution could be adding the following to the documentation's CSS:

overflow: scroll;
image

Potential Fix 2:

I believe this could also be a simple fix by enabling overflow-wrap to anywhere or break-word. A potential solution could be adding the following to the documentation's CSS:

overflow-wrap: anywhere;
image
@2bndy5
Copy link
Collaborator

2bndy5 commented Jul 6, 2024

We actually implemented a more API-friendly solution for ToC entries using <wbr> injection.

def _insert_wbr(text: str) -> str:
"""Inserts <wbr> tags after likely split points for API symbols."""
# Split after punctuation
text = re.sub("([.:_-]+)", r"\1<wbr>", text)
# Split before brackets
text = re.sub(r"([(\[{])", r"<wbr>\1", text)
# Split between camel-case words
text = re.sub(r"([a-z])([A-Z])", r"\1<wbr>\2", text)
return text

image image

However, we don't alter the doc/section titles in the same way.

@2bndy5
Copy link
Collaborator

2bndy5 commented Jul 6, 2024

FYI, our CSS also has a rule that appends a ellipsis if overflow occurs. Adding this class to the raw html

<h1 id="long-api-name" class="md-ellipsis">long.API.name</h1>
CSS class definition

.md-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

results in
image

@jbms
Copy link
Owner

jbms commented Jul 11, 2024

A solution based on _insert_wbr for the titles seems like the best option. Ellipses are unfortunate because for API documentation it really is important to see the full string, especially the end of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants