Skip to content

Commit c2a1851

Browse files
committed
Copy the spec authoring guide over verbatim.
The next commit will update to keep in sync with the reference.
1 parent 257454f commit c2a1851

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

docs/authoring.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Authoring Guide
2+
3+
## Markdown formatting
4+
5+
* Use [ATX-style headings][atx] (not Setext) with [sentence case].
6+
* Do not use tabs, only spaces.
7+
* Files must end with a newline.
8+
* Lines must not end with spaces. Double spaces have semantic meaning, but can be invisible. Use a trailing backslash if you need a hard line break.
9+
* If possible, avoid double blank lines.
10+
* Do not use indented code blocks, use 3+ backticks code blocks instead.
11+
* Code blocks should have an explicit language tag.
12+
* Do not wrap long lines. This helps with reviewing diffs of the source.
13+
* Use [smart punctuation] instead of Unicode characters. For example, use `---` for em-dash instead of the Unicode character. Characters like em-dash can be difficult to see in a fixed-width editor, and some editors may not have easy methods to enter such characters.
14+
15+
There are automated checks for some of these rules. Run `cargo run --manifest-path style-check/Cargo.toml -- spec` to run them locally.
16+
17+
[atx]: https://spec.commonmark.org/0.31.2/#atx-headings
18+
[sentence case]: https://apastyle.apa.org/style-grammar-guidelines/capitalization/sentence-case
19+
[smart punctuation]: https://rust-lang.github.io/mdBook/format/markdown.html#smart-punctuation
20+
21+
## Special markdown constructs
22+
23+
### Rules
24+
25+
Most clauses should be preceded with a rule.
26+
Rules can be specified in the markdown source with the following on a line by itself:
27+
28+
```
29+
r[foo.bar]
30+
```
31+
32+
The rule name should be lowercase, with periods separating from most general to most specific (like `r[array.repeat.zero]`).
33+
34+
Rules can be linked to by their ID using markdown such as `[foo.bar]`. There are automatic link references so that any rule can be referred to from any page in the book.
35+
36+
In the HTML, the rules are clickable just like headers.
37+
38+
### Standard library links
39+
40+
You should link to the standard library without specifying a URL in a fashion similar to [rustdoc intra-doc links][intra]. Some examples:
41+
42+
```
43+
Link to Option is [`std::option::Option`]
44+
45+
You can include generics, they are ignored, like [`std::option::Option<T>`]
46+
47+
You can shorthand things if you don't want the full path in the text,
48+
like [`Option`](std::option::Option).
49+
50+
Macros can use `!`, which also works for disambiguation,
51+
like [`alloc::vec!`] is the macro, not the module.
52+
53+
Explicit namespace disambiguation is also supported, such as [`std::vec`](mod@std::vec).
54+
```
55+
56+
[intra]: https://doc.rust-lang.org/rustdoc/write-documentation/linking-to-items-by-name.html
57+
58+
### Admonitions
59+
60+
Admonitions use a style similar to GitHub-flavored markdown, where the style name is placed at the beginning of a blockquote, such as:
61+
62+
```
63+
> [!WARNING]
64+
> This is a warning.
65+
```
66+
67+
All this does is apply a CSS class to the blockquote. You should define the color or style of the rule in the `css/custom.css` file if it isn't already defined.
68+
69+
## Content guidelines
70+
71+
The following are guidelines for the content of the spec.
72+
73+
### Targets
74+
75+
The spec does not document which targets exist, or the properties of specific targets. The spec may refer to *platforms* or *target properties* where required by the language. Some examples:
76+
77+
* Conditional-compilation keys like `target_os` are specified to exist, but not what their values must be.
78+
* The `windows_subsystem` attribute specifies that it only works on Windows platforms.
79+
* Inline assembly and the `target_feature` attribute specify the architectures that are supported.

0 commit comments

Comments
 (0)