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

Documentation snippets with ~~~ or ``` #1025

Closed
gnzlbg opened this issue Jun 19, 2016 · 4 comments
Closed

Documentation snippets with ~~~ or ``` #1025

gnzlbg opened this issue Jun 19, 2016 · 4 comments
Labels
A-lint Area: New lints E-medium Call for participation: Medium difficulty level problem and requires some initial experience. L-style Lint: Belongs in the style lint group T-AST Type: Requires working with the AST

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Jun 19, 2016

The Rust book delimits documentation snippets for examples with ``` but ~~~ seems to work as well. Maybe we should have a new lint to tell people to use one over the other or at least to enforce a consistent stype within a crate.

E.g. this

/// Adds one to the number given.
///
/// # Examples
///
/// ```
/// let five = 5;
///
/// assert_eq!(6, add_one(5));
/// # fn add_one(x: i32) -> i32 {
/// #     x + 1
/// # }
/// ```
fn add_one(x: i32) -> i32 {
    x + 1
}

vs

/// Adds one to the number given.
///
/// # Examples
///
/// ~~~
/// let five = 5;
///
/// assert_eq!(6, add_one(5));
/// # fn add_one(x: i32) -> i32 {
/// #     x + 1
/// # }
/// ~~~
fn add_one(x: i32) -> i32 {
    x + 1
}
@mcarton
Copy link
Member

mcarton commented Jun 19, 2016

Is there any difference between the two forms or is this yet another markdown way to write the same thing? The ````` style seems to be preferred, a lint to enforce consistency would be nice.

I also note that the current markdown lint should support ~~~ then.
Cc #1007.

@mcarton mcarton added E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-AST Type: Requires working with the AST A-lint Area: New lints L-style Lint: Belongs in the style lint group labels Jun 19, 2016
@killercup
Copy link
Member

From what I've seen, Rust documentation uses ```.

If this is added, it might be useful to also tell people to set the code block language (mentioned in #1007 as well). While rustdoc automatically sets the language to 'rust' for un-annotated code blocks, it should be preferred to be explicit (and to e.g. set "plain" to not highlight code blocks).

@steveklabnik
Copy link
Member

Old Rust docs used to use ~~~, but I replaced them with ````` over time.

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Jun 21, 2016

Is the syntax ~~~ deprecated? If so we can just recommend using . Otherwise I don't know if it would be better to still recommend using or to recommend consistency independently of the style used (e.g. by inferring the style most commonly used within a crate).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints E-medium Call for participation: Medium difficulty level problem and requires some initial experience. L-style Lint: Belongs in the style lint group T-AST Type: Requires working with the AST
Projects
None yet
Development

No branches or pull requests

4 participants