Documentation Rules (docs-rules)
This document is the authoritative definition of the documentation rules; before making changes, start with the self-check in HOWTO.md (the unified handbook; Section 2 covers documentation changes). This document is at the same level as coding-rules.md: coding-rules governs code, while this document governs documentation.
0. Three Prohibitions (Documentation Edition)
These mirror the three prohibitions in coding-rules; reviews should reject changes on the same grounds:
- Do not invent: Before adding a new term or document type, demonstrate that it does not overlap with an existing concept—check docs/glossary.json, consult the classification table in §1, and grep the existing documentation.
- Do not accumulate responsibilities: A document belongs to only one quadrant and serves only one audience. Putting a reference table in a tutorial or design motivations in a reference is responsibility accumulation.
- Refactor rather than patch: If the same content appears in ≥2 places, a directory mixes two audiences, or a single change affects ≥3 synonymous formulations—stop, adjust the structure first, and then write the content.
1. Classification Rules: Six Top-Level Directories, Six Audiences
The documentation site organizes user documentation into the four quadrants of Diátaxis, plus two directories for the repository itself:
| Directory | Quadrant | Audience | Reader's question | Document Form |
|---|---|---|---|---|
tutorial/ | Tutorial (learning-oriented) | Beginners | “Show me how to build my first thing” | Progressive course |
guide/ | Guide (task-oriented) | Users | “I need to complete X; how do I do it?” | Step-by-step checklist |
reference/ | Reference (information-oriented) | Users | “What does X mean exactly?” | Lookup-oriented description |
explanation/ | Explanation (understanding-oriented) | Curious readers | “Why is it designed this way?” | Expository discussion |
dev/ | — (outside Diátaxis) | Contributors | “I want to change this repository; which rules must I follow?” | Rules, architecture, workflows |
rfc/ | — (language governance) | Language designers | “How is this feature decided and proposed?” | Proposal + status catalog |
blog/ is a chronological, external-facing narrative, and archive/ is cold storage excluded from publication; neither participates in the classification.
Decision Tree
- Is the reader a user of the language or tool?
- Yes → They want to learn (tutorial), accomplish a task (guide), look something up (reference), or understand (explanation)
- No → 2
- Does the reader need to modify the compiler or repository? →
dev/ - Is the reader reviewing or submitting a language feature? →
rfc/
If a document cannot yield a unique answer, it is serving two audiences—split it and place each part where it belongs.
Commonly Confused Boundaries (Empirical)
| Content | Destination | Common Misplacement |
|---|---|---|
Command-line usage of yx check | reference/check-command.md | dev/design/check/ |
Design specifications for yx check (zero false positives, incremental mechanism) | dev/design/check/ | reference/ |
| Formatter rules (implementation behavior specification) | dev/design/formatter/ | reference/ |
Command-line usage of yx format | reference/format-command.md | dev/design/formatter/ |
| Language philosophy and manifesto (evergreen exposition) | explanation/ | blog/ (blog is chronological) |
| Compiler architecture and implementation plan | dev/architecture/ | explanation/ (it is an operations manual, not an exposition) |
| Feature proposals and final decision records | rfc/ | dev/ (the RFC audience extends beyond contributors) |
2. Language Style (Wiki-Style Writing)
This section follows the core principles of Wikipedia's Manual of Style and applies to all directories; point of view and tone vary slightly by quadrant (§2.4).
2.1 Prefer the Active Voice
- Write “The compiler reports E1001,” not “E1001 is reported by the compiler.”
- Use the passive voice only when the actor is unknown or unimportant.
- Test: when a sentence contains a passive construction such as “is reported by” or “is achieved through,” ask “Who does it?” If there is an answer, rewrite the sentence in the active voice.
2.2 Definite Statements
- Write “yx check does not generate code,” not “yx check may not generate code.”
- State facts definitively. There are only two legitimate ways to present uncertain content:
- Give an exact condition: “When
--watchis enabled, yx check rechecks only affected files.” - Remove it and write it after verification.
- Give an exact condition: “When
- Do not use vague terms such as “may,” “perhaps,” “probably,” “basically,” or “to some extent.” Use “should” only to express obligation (“You should run the tests”), never speculation.
2.3 Present Tense
- Write “The parser rejects empty modules,” not “The parser will reject empty modules.” Documentation describes the behavior of the current version.
- Exception: when
rfc/draft/andrfc/review/describe proposals that have not yet been implemented, use “will”; after the proposal is implemented, return to the present tense.
2.4 Point of View
reference/,explanation/, andrfc/: use impersonal statements (“The function returns Result”).tutorial/andguide/: use the second person (“you”; for example, “You run yx new”).dev/: keep rules impersonal, but operational guidance may address the reader as “you.”- Do not use “we” in any directory: replace “We recommend” with “Recommended.”
2.5 One Idea per Sentence
- A sentence must make only one assertion; if there are two assertions, write two sentences.
- Use a list instead of a long sentence for three or more parallel facts.
2.6 Consistent Terminology
- A concept must have only one name across the entire site. If an earlier section says “ownership,” a later section must not switch to a synonym such as “ownership rights.”
- Before adding a term, check docs/glossary.json and its usage in the existing documentation.
- At its first occurrence, define a term or link to its definition.
2.7 Objective and Neutral Tone
- Do not write “extremely simple,” “all you need to do,” or “effortless.” When a reader is stuck, these words are mocking.
- Do not use marketing terms such as powerful, elegant, or seamless. Replace them with verifiable facts: “compile-time monomorphization, with no runtime overhead.”
- When comparing other languages, state behavioral differences rather than evaluating merits.
2.8 Verifiability
- Every behavioral assertion must be verifiable through code or tests; do not make assertions that cannot be verified.
- Code examples must be executable: CI (
scripts/ci/check-docs-examples.py) runs them. Mark examples that cannot be executed with<!-- docs-example: skip -->and explain why.
3. Structure and Mechanical Rules
- frontmatter:
titleis required (the sidebar generator depends on it);descriptionis recommended. - Headings: Each page has one H1, the body starts at H2, and heading levels must not be skipped.
- Links: All internal links must use a relative path to the target file, not a site-absolute path. The build configuration uses
ignoreDeadLinks: false; dead links cause the build to fail. - Do not write line numbers: Line numbers drift whenever anything changes, while
check-docs-refs.pyonly validates that the path can be resolved. Locate content semantically (“the arm inir_genthat retrieves the span forExpr::Cast”); if a line number is truly required, retrieve it again at the referenced revision (git show <rev>:<file>). Exception: build-generated error-code reference pages include afile:lineemission-point anchor—the generator computes the line number from the current source at build time, so it is always up to date. - Moving a file = changing the URL: You must synchronize references across the entire site, both sidebar configurations, the en mirror, scripts that reference the path, and AGENTS.md. For the complete process, see Section 2, “Six Synchronizations for Moving Documentation,” in HOWTO.md.
- Formatting: Table alignment and blank lines in fenced blocks are enforced by prettier (
docs/.prettierrc.json) and markdownlint. - Chinese-English mirror: zh is the source, and en is synchronized by the translation workflow. After adding or moving a zh file, the en path must match. Exception: error-code reference pages are not checked in; both the zh and en versions are generated at build time by
scripts/docs/gen-error-code-docs.py(with their text taken respectively fromlocales/zh.jsonandlocales/en.json) and do not pass through the translation workflow. - For structural issues, obtain the rendered ground truth first: When determining whether the structure is correct (heading hierarchy and count, code-block scope, and whether anchors can be reached), use the
dist/**/*.htmlfiles produced bypnpm docs:buildas the source of truth—not line counts in the source and not an assumption that zh must be right and en must be wrong. Evidence (2026-12-05): the zh version ofdev/commit-convention.mdwas missing two closing fences, and the zh version ofrfc/accepted/011a-interface-implementation.mdplaced a paragraph immediately before---(which CommonMark treats as a setext heading)—in both cases, the source was at fault and the mirror was actually correct; counting Markdown alone would flag the correct side as drift. The mechanical reconciliation script (scripts/check-translation-structure.mjs) is only responsible for detecting inconsistencies; determining which side is responsible requires examining the site build output.
4. Responsibilities of Directory Index Pages
Each top-level directory's index.md answers two questions: “What does this directory include, and what does it exclude?” The index page links to this rule and does not duplicate a content list—a hand-written list inevitably becomes outdated (the sole authoritative source for RFC status is rfc/TRACKING.md, which is generated by a script; the same principle applies).
5. Authority Chain and Prerequisites for Changes
The authority chain is one-way: RFC (establishes the basis) → SPEC / specifications / design documents. A SPEC may state “For the design rationale, see RFC-xxx”; an RFC must not use a SPEC as its basis—once an RFC depends on a SPEC, the SPEC can no longer be changed, which undermines design authority.
Before changing documentation, you must read three things:
- Upstream design: Which decision in which RFC provides the basis for the conclusions of the document being changed (RFC-039 and the supporting documents under
architecture/, or a topical RFC in that area)? If you cannot name it, the change has no basis. - Adjacent documents at the same level: Whether the same table or set of terms has already been defined elsewhere—writing two separate definitions is a variant of §0, “Do not invent.”
- The hard rules in commit-convention.md and coding-rules.md.
Corrections are made in place: When a document does not match the facts, directly rewrite the body to match the facts and delete the old wording; do not retain comparisons such as “formerly... now...” or “errata.” History is in git, and readers should not have to read the incorrect version before the correct one.
Criterion: Every added or modified sentence must be able to answer “Who, under what conditions, must do what?” A sentence that cannot answer this is explanatory material and belongs in the RFC's “Motivation” section, not the normative body.
