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

rustdoc does not highlight code blocks in other languages #40301

Closed
jorendorff opened this issue Mar 6, 2017 · 8 comments
Closed

rustdoc does not highlight code blocks in other languages #40301

jorendorff opened this issue Mar 6, 2017 · 8 comments
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools

Comments

@jorendorff
Copy link
Contributor

jorendorff commented Mar 6, 2017

The "Documentation" chapter of the Rust book says:

If you want something that's not Rust code, you can add an annotation:

/// ```c
/// printf("Hello, world\n");
/// ```

This will highlight according to whatever language you're showing off.

This doesn't work for me. I asked Steve about it on IRC:

<jorendorff> steveklabnik: Is this true?
<steveklabnik> jorendorff: as long as highlight.js or whatever knows how to do it, yeah, and
    there's a lot of them. like x86asm.
<jorendorff> steveklabnik: huh. i just tried it out locally and i'm not getting any highlighting...
<steveklabnik> weird
<jorendorff> steveklabnik: My devtools network tab doesn't show it trying to load highlight.js.
<jorendorff> the output HTML does contain `<code class="language-c">` and such...
<steveklabnik> i dunno then, maybe file a bug?
<steveklabnik> my understanding is that it's supposed to
<jorendorff> steveklabnik: a bug against rust, or the book? or both? I'm trying to find
    evidence in librustdoc that this feature exists, no luck
<steveklabnik> file it against rust, becuase we should determine if this feature was intended
    to exist or not first
<steveklabnik> it might end up being one against the book if that was wrong
<steveklabnik> but this might be a regression 
<steveklabnik> i dunno
@jorendorff
Copy link
Contributor Author

@steveklabnik

@steveklabnik steveklabnik added A-docs T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools labels Mar 6, 2017
@steveklabnik
Copy link
Member

I thought this was a rustdoc feature, but now am not so sure. I thought we used highlight.js and so inherited everything it uses.

If this is not true, we should decide which is broken: the docs or rustdoc.

/cc @rust-lang/tools @rust-lang/docs

@alexcrichton
Copy link
Member

Currently code is highlighted using the actual libsyntax lexer, which in turn is why no other language is supported (we only lex rust!)

@alexcrichton
Copy link
Member

(at least that's what it originally did, unsure if it still does that...)

@GuillaumeGomez
Copy link
Member

No, it's still the case. Should we use highlightjs or any equivalent instead?

@nrc
Copy link
Member

nrc commented Mar 7, 2017

I'd be happy to keep using a custom highlighter - it is nice to have a highlighter written in Rust (I use it rustw for example) and it allows us to be in control and ensure quality highlighting. I suspect it is uncommon for rustdoc to need to highlight non-Rust code.

@steveklabnik
Copy link
Member

Okay, let's change this into a docs bug to fix the book.

@steveklabnik steveklabnik added A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools and removed T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-tools A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools labels Mar 7, 2017
frewsxcv added a commit to frewsxcv/rust that referenced this issue Mar 14, 2017
…g, r=steveklabnik

Remove doc about highlighting code in other languages rust-lang#40301

This doesn't appear to be true any longer, so removing it to avoid confusion. See rust-lang#40301

Thoughts:
- may be a good idea to remove "Let's discuss the details of these code blocks.", as there's not much being discussed at this point;
- does `text` still work?

r? @steveklabnik
frewsxcv added a commit to frewsxcv/rust that referenced this issue Mar 14, 2017
…g, r=steveklabnik

Remove doc about highlighting code in other languages rust-lang#40301

This doesn't appear to be true any longer, so removing it to avoid confusion. See rust-lang#40301

Thoughts:
- may be a good idea to remove "Let's discuss the details of these code blocks.", as there's not much being discussed at this point;
- does `text` still work?

r? @steveklabnik
frewsxcv added a commit to frewsxcv/rust that referenced this issue Mar 15, 2017
…g, r=steveklabnik

Remove doc about highlighting code in other languages rust-lang#40301

This doesn't appear to be true any longer, so removing it to avoid confusion. See rust-lang#40301

Thoughts:
- may be a good idea to remove "Let's discuss the details of these code blocks.", as there's not much being discussed at this point;
- does `text` still work?

r? @steveklabnik
frewsxcv added a commit to frewsxcv/rust that referenced this issue Mar 17, 2017
…g, r=steveklabnik

Remove doc about highlighting code in other languages rust-lang#40301

This doesn't appear to be true any longer, so removing it to avoid confusion. See rust-lang#40301

Thoughts:
- may be a good idea to remove "Let's discuss the details of these code blocks.", as there's not much being discussed at this point;
- does `text` still work?

r? @steveklabnik
frewsxcv added a commit to frewsxcv/rust that referenced this issue Mar 17, 2017
…g, r=steveklabnik

Remove doc about highlighting code in other languages rust-lang#40301

This doesn't appear to be true any longer, so removing it to avoid confusion. See rust-lang#40301

Thoughts:
- may be a good idea to remove "Let's discuss the details of these code blocks.", as there's not much being discussed at this point;
- does `text` still work?

r? @steveklabnik
frewsxcv added a commit to frewsxcv/rust that referenced this issue Mar 17, 2017
…g, r=steveklabnik

Remove doc about highlighting code in other languages rust-lang#40301

This doesn't appear to be true any longer, so removing it to avoid confusion. See rust-lang#40301

Thoughts:
- may be a good idea to remove "Let's discuss the details of these code blocks.", as there's not much being discussed at this point;
- does `text` still work?

r? @steveklabnik
frewsxcv added a commit to frewsxcv/rust that referenced this issue Mar 17, 2017
…g, r=steveklabnik

Remove doc about highlighting code in other languages rust-lang#40301

This doesn't appear to be true any longer, so removing it to avoid confusion. See rust-lang#40301

Thoughts:
- may be a good idea to remove "Let's discuss the details of these code blocks.", as there's not much being discussed at this point;
- does `text` still work?

r? @steveklabnik
@steveklabnik
Copy link
Member

fixed by #40466

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools
Projects
None yet
Development

No branches or pull requests

5 participants