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

Consider indicating which code blocks are expected to compile and which are not in the guide(s) #20524

Closed
huonw opened this issue Jan 4, 2015 · 6 comments
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@huonw
Copy link
Member

huonw commented Jan 4, 2015

It can be a little unclear when a code block is not meant to compile (there's occasionally a question in IRC about "a piece of code from the guide doesn't compile" because the asker didn't realise it's meant to be an example illustrating a compiler error) so we could do something to make it more obvious, e.g. coloured borders:

screenshot from 2015-01-05 03 33 49

@huonw huonw added the A-docs label Jan 4, 2015
@rustonaut
Copy link

I agree on this the question is how to link it with the automated doc generation.

Maybe adding a green border for examples run by doc test. And add some differentiation between tests witch does not run because they are "codesnipeds" (yellow) and this witch are negative examples (redly grayed out text?)

In general there should be as little negative examples as possible and we should pay attention that the "this does not work" mark is not confused with a ”important look here" mark by new comers

@steveklabnik steveklabnik added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. and removed A-docs labels Mar 8, 2015
@shepmaster
Copy link
Member

👍 This also creates Stack Overflow questions.

@huonw
Copy link
Member Author

huonw commented May 22, 2016

It's worth noting that using only a coloured border here is not very accessible: if something like this is added, we should strongly consider adding accessibility hints/ARIA at the same time, or even using an alternative scheme entirely.

@rustonaut
Copy link

@huonw: I agree it should be made accessible for everyone. I have no experience with aria and screen reader (sounds really helpful) but I think a possible approach would be

  • add color markings
  • change the visual so that colorblind people can see it*
  • add more ARIA accessibility features, e.g. for screen readers
  • maybe make some pull featured on the Forum+Weekly Rust Newsletter to decide between multiple possible ways to implement the previous steps

In regard to 3 for negative running examples we might add "a line of ! or X or???" parallel/instead of the straight line featured above e.g.:

X |     let x: u32 = 888i64;
X |     println!("{}", x);

or a zigzag line but not sure if there is a good way to implement this in css.

For code snippets we could consider adding some kind of marker at the top+bottom of the snipped to indicate that "there is more" similar to ellipses in a text. E.g. in gnome3 there is that stripped line at the top/bottom if you can scroll up/down (just as a example, not sure if that would work four this case)

Oh and this is a bit far stretched, but for negative examples witch run as doctest with should_panic or witch can't compile it might be possible to record the run-time/compiler error, and in case of a compiler error do some simple error highlighting in the shown code and maybe add some way to blend in the error message. But well that seems to be a lot of work an another attribute additional to ignore would be needed like should_not_compile (Through such a mechanism might also be useful to test restrictions through the type system in unit-tests).

@steveklabnik steveklabnik added T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. and removed T-tools labels May 18, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Jul 22, 2017
@kzys
Copy link
Contributor

kzys commented Sep 13, 2018

Resolving? We have merged #44397 and #44927 last year :)

@shepmaster
Copy link
Member

The original post concerned the book (now generated by mdbook), not the output of rustdoc.

A demo of rustdoc output from Rust 1.29.0:

image

Since mdbook is in a different repo, I think it's OK to close this. Ping me if you disagree!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants