💄 Fix code blocks in reference docs overflowing table width#15094
Merged
💄 Fix code blocks in reference docs overflowing table width#15094
Conversation
Contributor
svlandeg
approved these changes
Mar 11, 2026
Member
svlandeg
left a comment
There was a problem hiding this comment.
Ah, this looks great!
You'd still have to scroll for long code lines, but at least having everything else better visible is a huge improvement.
We should do this in Typer, too, will you make the PR Yurii or shall I? 🙏
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There is currently an issue in FastAPI Reference docs (reported in this discussion): if parameter description contains code block with long lines, it will extend the column width and part of the text will become hidden:
See: https://fastapi.tiangolo.com/reference/fastapi/#fastapi.FastAPI--example
See screenshot (before fix)
Together with Claude Code figured out a solution that looks quite simple and reasonable.
Claude Code explained it this way:
width: 0- tells the table layout algorithm that.highlightneeds zero width, so the<td>doesn't expandmin-width: 100%- once the table has calculated column widths,.highlightfills the available spaceoverflow-x: auto- adds a horizontal scrollbar when code is wider than the columnAfter fix, text fits the column width. If there are long lines in code block, you can use horizontal scroll bar to read them:
See (after fix): https://9541300a.fastapitiangolo.pages.dev/reference/fastapi/#fastapi.FastAPI--example
See screenshot (after fix)
Bonus - fix displaying line numbers in API Reference docs (when run with
LINENUMS=true)Also fixed annoying bug - when you run docs live locally, it's run with
LINENUMS=true. But line numbers layout is broken for API Reference docs:See screenshot (line numbers before fix)
By-default line numbers are added using table. And if this table is placed inside another table (table of parameters in API reference docs), it breaks styles..
There is an alternative approach as described in docs - use
linenums_style: pymdownx-inline.This way line numbers are displayed correctly:
See screenshot (line numbers after fix)