Skip to content

Commit 557c490

Browse files
committed
docs(style): Specify the frontmatter style
Taken from [a style team discussion](rust-lang/style-team#212 (comment)). Assumptions on my part: - I don't need to specify the lack of trailing spaces after the code fence / infostring - We aren't specifying when to include the infostring (one idea being if there is no shebang) - Keep it simple and have a single example instead of showing allowed several variations
1 parent 8c32e31 commit 557c490

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/doc/style-guide/src/nightly.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,27 @@ This chapter documents style and formatting for nightly-only syntax. The rest of
55
Style and formatting for nightly-only syntax should be removed from this chapter and integrated into the appropriate sections of the style guide at the time of stabilization.
66

77
There is no guarantee of the stability of this chapter in contrast to the rest of the style guide. Refer to the style team policy for nightly formatting procedure regarding breaking changes to this chapter.
8+
9+
### Frontmatter
10+
11+
*Location: Placed before comments and attributes in the [root](index.html).*
12+
13+
*Tracking issue: [#136889](https://github.com/rust-lang/rust/issues/136889)*
14+
15+
*Feature gate: `frontmatter`*
16+
17+
There should be no blank lines between the frontmatter and either the start of the file or a shebang.
18+
There can be zero or one line between the frontmatter and any following content.
19+
20+
The frontmatter fence should use the minimum number of dashes necessary for the contained content.
21+
If an infostring is present after the opening fence, there should be one space separating them.
22+
23+
```rust
24+
#!/usr/bin/env cargo
25+
--- cargo
26+
[dependencies]
27+
regex = "1"
28+
---
29+
30+
fn main() {}
31+
```

0 commit comments

Comments
 (0)