Skip to content

Commit c17f60c

Browse files
committed
Explain how to name rule identifiers
1 parent 687faf9 commit c17f60c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

docs/authoring.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,36 @@ Rules can be linked to by their ID using markdown such as `[foo.bar]`. There are
7575

7676
In the HTML, the rules are clickable just like headers.
7777

78+
When assigning rules to new paragraphs, or when modifying rule names, use the following guidelines:
79+
1. A rule applies to one core idea, which should be easily determined when reading the paragraph it is applied to,
80+
2. Other than the "intro" paragraph, purely explanatory, expository, or exemplary content does not need a rule. If the expository paragraph isn't directly related to the previous, separate it with a hard (rendered) line break
81+
3. Rust Code examples and tests do not need their own rules
82+
4. Notes do not need rules. For other admonition types, use the following guidelines:
83+
* Warning: Omit the rule if and only if the warning follows from the previous paragraph.
84+
* Target Specific Behaviour: Always include the rule
85+
* Edition Differences: Always include the rule
86+
* Version History: Omit the rule if the present behaviour is explained in the immediately preceeding rule.
87+
4. The following keywords should be used to identify paragraphs when unambiguous:
88+
* `intro`: The beginning paragraph of each section - should explain the construct being defined overall.
89+
* `syntax`: Syntax definitions or explanations when BNF syntax definitions are not used
90+
* `restriction`: Syntactic (parsing) requirements on the construct
91+
* `constraint`: Semantic (type checking) requirements on the construct
92+
* `safety` (instead of restriction): Stating that an operation is `unsafe` or the conditions under which it is `unsafe`
93+
* `behavior`: Runtime effects of evaluating the construct in a well-defined manner
94+
* `panics`: Conditions under which evaluating the construct causes a runtime panic
95+
* `preconditions`: Conditions which must be satisfied for the evaluation of the construct to be well-defined
96+
* `namespace`: For items only, specifies the namespace(s) the item introduces a name in. May also be used elsewhere when defining a namespace (e.g. `r[attribute.diagnostic.namespace]`)
97+
5. When a rule doesn't fall under the above keywords. or for section rule ids, name the subrule as follows:
98+
* If the rule is naming a specific Rust language construct (IE. an attribute, standard library type/function, or keyword-introduced concept), use the construct as named in the language, appropriately case-adjusted (but do not replace `_`s with `-`s)
99+
* Other than rust language concepts with `_`s in the name, use `-` characters to separate words within a "subrule"
100+
* Whenever possible, do not repeat previous components of the rule
101+
* Prefer using singular forms of words over plural unless the rule applies to a list or the construct is named as plural in the language (e.g. `r[attribute.diagnostic.lint.group])
102+
* Whenever possible, don't use a name that conflicts with one of the above keywords, even if this violates the first bullet.
103+
* Use an appropriately discriptive, but short, name if the language does not provide one.
104+
6. When a keyword applies, but multiple different rules in the same section would use the same keyword, prefix or suffix the rule with a descriptive id given above, separated with a `-`
105+
* When the paragraph modifies a specific named construct or applies to a specific named construct only, prefix the rule with the name of the construct (e.g. `r[items.fn.params.self-constraint]`).
106+
* When the paragraph refers to a specific named construct that applies the particular keyword behaviour, suffix the rule with the name of the construct
107+
78108
### Standard library links
79109

80110
You should link to the standard library without specifying a URL in a fashion similar to [rustdoc intra-doc links][intra]. Some examples:

0 commit comments

Comments
 (0)