-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Use # vs. ## consistently for headings in documentation #15499
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
Comments
Yeah, I'm not sure how Rustdoc renders these two off the top of my head, but |
Single |
We could just fix the documentation styles to make |
There's only supposed to be one H1 per section. H2 is more appropriate. |
@steveklabnik What do you mean "supposed to be"? Heading tags introduce sections. There are 6 levels of heading tags. There's no intrinsic semantic meaning to each level, except in that higher levels are considered to nest within lower ones (and typically use a smaller font, though you can certainly override that however you wish). Given that we don't use a |
Headings form a 'document outline,' and there's only supposed to be one h1 per page, although with HTML5 the outline resets per https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements makes mention of this,for example. This is, of course, a recommendation. But we should strive to act according to best practices where possible. |
My main objection is that I think /// ## Example
is wrong if there was no preceding /// # Foo
header. You're looking at the rustdoc HTML output, but that's basically embedding a tiny document within a bigger one. From the perspective of the docstring itself, If you care about the usage of |
I agree that in general, the HTML Rustdoc generates should get a once-over. Why does it matter that this fragment has a single heading? In all contexts where it's used, there should be (emphasis on should there) be an h1 generated for the surrounding page. It's never the single top level heading. And, when there's more than one heading, then it as h1 doesn't make sense either. |
I have a vague uneasiness about Rustdoc producing a h2 when I type #. Can't quantify it specifically... |
I’m not in the slightest bit uneasy about bumping the start level for headings. Doing that would be considered entirely normal in reStructuredText for things like Python docs, anyway. But then, reStructuredText is defined that way, that heading levels are purely a document-level construct, whereas strictly Markdown headings are defined as global constructs (this is not a good thing, and I feel entirely at liberty to ignore it). (I don’t like the whole |
@steveklabnik When using Markdown to generate an entire web page, you care about |
/cc @aturon |
internal: up lsp-server
Some places use
# Examples
others use## Examples
:#
:rust/src/libstd/collections/hashmap.rs
Line 692 in 4f120e6
rust/src/libstd/rand/mod.rs
Line 23 in 4f120e6
rust/src/libstd/io/mod.rs
Line 24 in 4f120e6
##
:rust/src/libcollections/slice.rs
Line 26 in 4f120e6
rust/src/liballoc/rc.rs
Line 26 in 4f120e6
rust/src/liballoc/lib.rs
Line 24 in 4f120e6
It seems that single
#
is far more popular at the moment:cc @steveklabnik
The text was updated successfully, but these errors were encountered: