Skip to content

rustdoc: [src] view is broken in lynx #84242

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

Closed
jyn514 opened this issue Apr 16, 2021 · 5 comments · Fixed by #136829
Closed

rustdoc: [src] view is broken in lynx #84242

jyn514 opened this issue Apr 16, 2021 · 5 comments · Fixed by #136829
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@jyn514
Copy link
Member

jyn514 commented Apr 16, 2021

I tried this: Opening https://rust-for-linux.github.io/docs/src/kernel/sync/condvar.rs.html#19-23 in lynx.

I expected to see this happen: Either the source code is shown side-by-side with the line numbers, or the line numbers aren't shown at all.

Instead, this happened: image

I think there's a very old issue about this that was fixed for newer browsers, but I can't seem to find it. This has definitely happened on ancient docs in docs.rs before. cc @ojeda - is this something you care about? I saw someone mentioned it in https://lkml.org/lkml/2021/4/16/49 but I don't know if that was actually serious.

Meta

Not sure what rust-for-linux is using, but I can replicate the issue with rustdoc 1.53.0-nightly (d0695c9 2021-04-12).

@jyn514 jyn514 added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-rustdoc-ui Area: Rustdoc UI (generated HTML) labels Apr 16, 2021
@ojeda
Copy link
Contributor

ojeda commented Apr 16, 2021

I think we will need to see the overall sentiment from the kernel community. Reading the source code directly is good enough in my opinion, since Markdown is designed to be readable as-is, but we will see.

Perhaps it is easier to have a plain-text renderer in rustdoc than to try to keep the other docs always working in TUI browsers.

@ojeda
Copy link
Contributor

ojeda commented Apr 16, 2021

Not sure what rust-for-linux is using, but I can replicate the issue with rustdoc 1.53.0-nightly (d0695c9 2021-04-12).

Currently we recommend 2021-02-20 as that's the one we use in our CI.

By the way, thanks a lot for taking a look at this! :)

@jyn514
Copy link
Member Author

jyn514 commented Apr 16, 2021

Perhaps it is easier to have a plain-text renderer in rustdoc than to try to keep the other docs always working in TUI browsers.

That will be a lot more work 😅 to be perfectly frank I don't think rustdoc will ever have a renderer other than HTML, my hope is that the JSON format will stabilize enough that people can use it to write their own community backends.

@ojeda
Copy link
Contributor

ojeda commented Apr 16, 2021

Sure! A format-independent renderer like the JSON one would be enough.

@lolbinarycat
Copy link
Contributor

one possible workaround would be adding the attributes hidden="" style="display: block;" to the pre element that contains the line numbers. since hidden is often implemented as display: none;, this will show the numbers on most modern browsers (only tested firefox), and not show it on browsers that don't support css.

@bors bors closed this as completed in ba32d8b Feb 12, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 12, 2025
Rollup merge of rust-lang#136829 - GuillaumeGomez:move-line-numbers-into-code, r=notriddle

[rustdoc] Move line numbers into the `<code>` directly

Fixes rust-lang#84242.

This is the first for adding support for rust-lang#127334 and also for another feature I'm working on.

A side-effect of this change is that it also fixes source code pages display in lynx since they're not directly in the source code.

To allow having code wrapping, the grid approach doesn't work as the line numbers are in their own container, so we need to move them into the code. Now with this, it becomes much simpler to do what we want (with CSS mostly). One downside: the highlighting became more complex and slow as we need to generate some extra HTML tags directly into the highlighting process. However that also allows to not have a huge HTML size increase.

You can test the result [here](https://rustdoc.crud.net/imperio/move-line-numbers-into-code/scrape_examples/fn.test_many.html) and [here](https://rustdoc.crud.net/imperio/move-line-numbers-into-code/src/scrape_examples/lib.rs.html#10).

The appearance should have close to no changes.

r? ``@notriddle``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: Rustdoc UI (generated HTML) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants