Skip to content

rustdoc: three tick code blocks confuse language choice with testing options #13947

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
pnkfelix opened this issue May 5, 2014 · 2 comments
Closed

Comments

@pnkfelix
Copy link
Member

pnkfelix commented May 5, 2014

In other non-Rust contexts, when writing a code block, I have become used to using the (optional) first word after the initial three ticks to indicate the language of the code block. See for example the syntax example taken from octopress:

``` [language] [title] [url] [link text] [linenos:false] [start:#] [mark:#,#-#]
code snippet
```

However, rustdoc has a different interpretation for the (again optional) first word after the initial three ticks: it is used for an directive regarding how to handle the given code when interpreted as a test. Potential values for the directive include: "ignore", "should_fail", "no_run"

It would be better if we came up with some way to indicate these meta-data directives in a manner that was still compatible with using the language directives as indicated in the octopress system.

At the very least, we could treat any code block that has a string that is not one of the builtin rustdoc directives (like the three listed above) nor the string "rust" should be implicitly treated as ignore. Then the author will retain the option of including the language name, and it will just get skipped by rustdoc when testing rust code blocks.

(Other options include: find some other channel to use to communicate this information besides the initial three ticks. A simple one would be instead following the final three ticks, though admittedly that may be too subtle.)

@huonw
Copy link
Member

huonw commented May 5, 2014

Sundown (and by extension Rustdoc) supports multiple attributes, like

``` {.rust .ignore}
...
```

They actually get added as part of the class attribute of the rendered HTML codeblock (and rustdoc happens to (ab)use them for detecting testable things). However, it seems this syntax is not sufficient for full octopress attributes.

@pnkfelix pnkfelix added the A-docs label May 7, 2014
@steveklabnik
Copy link
Member

At this point, I think that changing this behavior would need an RFC. It's effectively a feature request for Rustdoc, and would cause pretty huge churn amongst all the work that we're doing.

I'm going to close this, but @pnkfelix , if you stil lcare about this and would like me to move it to the RFCs repo, just let me know.

bors added a commit to rust-lang-ci/rust that referenced this issue Feb 13, 2023
…, r=Veykril

Add basic tooltips to adjustment hints

![2023-01-16_16-45](https://user-images.githubusercontent.com/38225716/212681383-a60b60bb-a8e7-410d-8b24-f6b72c197311.png)

I'm not sure how to make them look nicer, but it's at least something.
bors pushed a commit to rust-lang-ci/rust that referenced this issue Jan 28, 2025
changelog: [`slow_vector_initialization`]: auto-fix when appropriate

I made a change for `slow_vector_initialization` lint suggestion to use
`vec!` with size and remove the unneeded `resize` (or similar one) call
in rust-lang#13912, while only the former one was suggested in the previous
implementation. Now, I think this lint can be automatically fixed with
no unnecessary code in some cases. I wrote “in some cases” because if
there are comments between vector declaration and `resize`, Clippy
shouldn't apply auto-fix because the comment may informational.
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