|
| 1 | +--- |
| 2 | +applyTo: "docs/src/**/*.md" |
| 3 | +--- |
| 4 | +# Documentation standards |
| 5 | + |
| 6 | +This codebase is a library that helps developers to build schema-driven form wizards for the terminal |
| 7 | + |
| 8 | +ALWAYS use `TUI Forms` as the friendly name of the package and `tui-forms` when refering to the package codebase. |
| 9 | + |
| 10 | +## 1. Audience and scope |
| 11 | + |
| 12 | +- This library is intended for Python developers building terminal applications or command line utilities. |
| 13 | +- About the reader: |
| 14 | + - Could be categorized as: |
| 15 | + - **End User**: Python developer willing to use this library in their own projects. |
| 16 | + - **Contributor**: Also a Python developer, probably also an End User, but someone willing to contribute to this library by fixing issues, implementing new features, and writing documentation. |
| 17 | + - Assume they know: Python development terms, Python 3.12+ |
| 18 | + - Do NOT assume they know: internal architecture decisions, the history of the project, or even other libraries providing the same features. |
| 19 | +- Full documentation lives at: https://collective.github.io/tui-forms |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## 2. Documentation structure (Diátaxis) |
| 24 | + |
| 25 | +All documentation must fit one of these four types. Never mix types in the same file. |
| 26 | + |
| 27 | +| Type | Purpose | Answers | |
| 28 | +|---|---|---| |
| 29 | +| **Tutorial** | Learning-oriented, step-by-step | "How do I get started?" | |
| 30 | +| **How-to guide** | Task-oriented, goal-focused | "How do I accomplish X?" | |
| 31 | +| **Reference** | Information-oriented, API/config | "What does parameter X do?" | |
| 32 | +| **Explanation** | Understanding-oriented, concepts | "Why does it work this way?" | |
| 33 | + |
| 34 | +When drafting a new file, STATE which type it is at the top of your working notes before writing. |
| 35 | + |
| 36 | +--- |
| 37 | + |
| 38 | +## 3. File metadata (REQUIRED on every file) |
| 39 | + |
| 40 | +Every `.md` file must begin with a MyST metadata block. Use this template and fill in accurate values — do not copy the placeholder text verbatim into the output: |
| 41 | + |
| 42 | +```markdown |
| 43 | +--- |
| 44 | +myst: |
| 45 | + html_meta: |
| 46 | + "description": "[PLACEHOLDER: one sentence, plain English, no marketing language]" |
| 47 | + "property=og:description": "[PLACEHOLDER: same as description above]" |
| 48 | + "property=og:title": "[PLACEHOLDER: page title, matches the H1 heading below]" |
| 49 | + "keywords": "[PLACEHOLDER: comma-separated, include library name, relevant concepts]" |
| 50 | +--- |
| 51 | +``` |
| 52 | + |
| 53 | +Rules: |
| 54 | +- `description` must be a single sentence under 160 characters. |
| 55 | +- `keywords` must include `tui-forms` as the first keyword. |
| 56 | +- The `og:title` must exactly match the H1 heading of the page. |
| 57 | +- NEVER copy example metadata from another page without updating all four fields. |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +## 4. Toolchain |
| 62 | + |
| 63 | +- **Documentation framework**: Sphinx with MyST-Parser (Markdown) |
| 64 | +- **Setup environment**: `make install` |
| 65 | +- **Build command**: `make docs-html` |
| 66 | +- **Live preview**: `make docs-livehtml` |
| 67 | +- **Output directory**: `docs/_build/html` |
| 68 | +- **Hosting**: `GitHub Pages` |
| 69 | + |
| 70 | +Before suggesting any Sphinx extension or MyST feature, verify it is listed in `docs/src/conf.py`. Do not assume extensions are available. |
| 71 | + |
| 72 | +--- |
| 73 | + |
| 74 | +## 5. Writing standards (Vale-enforced) |
| 75 | + |
| 76 | +Vale is configured for **American English** with the following style guides active: |
| 77 | +- Microsoft |
| 78 | + |
| 79 | +Vale runs via: `make docs-vale` |
| 80 | + |
| 81 | +Rules that Vale does NOT catch but must still be followed: |
| 82 | + |
| 83 | +- Use second-person voice ("you", not "the user" or "one"). |
| 84 | +- Use active voice. Passive voice is allowed only when the actor is genuinely unknown. |
| 85 | +- Use present tense ("returns a string", not "will return a string"). |
| 86 | +- Sentence case for all headings ("Getting started", not "Getting Started"). Exception: proper nouns and the library name. |
| 87 | +- One sentence per line in the source Markdown (makes diffs readable). |
| 88 | +- No filler phrases: "simply", "just", "easily", "obviously", "of course". |
| 89 | +- Spell out acronyms on first use per page, even common ones. |
| 90 | + |
| 91 | +--- |
| 92 | + |
| 93 | +## 6. Code examples |
| 94 | + |
| 95 | +- ALL code examples must be tested and working against the current version. |
| 96 | +- Use `tui_forms` as the import in all examples. |
| 97 | +- Show the minimal working example first, then add complexity. |
| 98 | +- Every code block must have a language tag: |
| 99 | + ````markdown |
| 100 | + ```python |
| 101 | + ``` |
| 102 | + ```` |
| 103 | +- If an example requires setup not shown inline, reference the relevant how-to guide explicitly. |
| 104 | +- NEVER fabricate API behaviour. If unsure whether a method exists or behaves a certain way, read the source at `src/tui_forms` before writing. |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +## 7. MyST-specific syntax |
| 109 | + |
| 110 | +Use MyST directives correctly. Prefer these patterns: |
| 111 | + |
| 112 | +**Notes and warnings:** |
| 113 | +```markdown |
| 114 | +:::{note} |
| 115 | +Use notes sparingly — only for information the reader would otherwise miss. |
| 116 | +::: |
| 117 | + |
| 118 | +:::{warning} |
| 119 | +Reserve warnings for actions that could cause data loss or security issues. |
| 120 | +::: |
| 121 | +``` |
| 122 | + |
| 123 | +**Cross-references** (always use labels, never bare URLs for internal links): |
| 124 | +```markdown |
| 125 | +{doc}`/path/to/page` |
| 126 | +{ref}`label-name` |
| 127 | +{py:func}`yourlibrary.module.function` |
| 128 | +``` |
| 129 | + |
| 130 | +**Do not use** raw HTML unless there is no MyST equivalent. |
| 131 | + |
| 132 | +--- |
| 133 | + |
| 134 | +## 8. What to verify before writing |
| 135 | + |
| 136 | +Before drafting any documentation: |
| 137 | + |
| 138 | +1. Read the relevant source files in `src/tui_forms`. |
| 139 | +2. Check whether existing documentation already covers the topic (`docs/src`). |
| 140 | +3. Run the build to confirm there are no pre-existing errors: `make docs-html`. |
| 141 | + |
| 142 | +FORBIDDEN: "I think this method does...", "It should...", "Probably..." |
| 143 | +REQUIRED: "According to `[file:line]`...", "The source shows..." |
| 144 | + |
| 145 | +If the behaviour is not clear from the source, STATE: "I cannot confirm this from the source code — please verify." |
| 146 | + |
| 147 | +--- |
| 148 | + |
| 149 | +## 9. Definition of done |
| 150 | + |
| 151 | +A documentation task is complete only when: |
| 152 | + |
| 153 | +- [ ] Vale passes with zero errors: `make docs-vale` |
| 154 | +- [ ] Sphinx builds with zero warnings: `make docs-html` |
| 155 | +- [ ] All internal cross-references resolve. |
| 156 | +- [ ] All code examples have been run and produce the stated output. |
| 157 | +- [ ] Metadata block is present and accurate on every new or modified file. |
| 158 | +- [ ] The page fits exactly one Diátaxis type. |
| 159 | + |
| 160 | +"The page renders" is not done. "Vale passes" is not done on its own. All six must be true. |
| 161 | + |
| 162 | +--- |
| 163 | + |
| 164 | +## 10. What not to do |
| 165 | + |
| 166 | +- NEVER mix tutorial and reference content in the same page. |
| 167 | +- NEVER use the word "simply" or "just" (Vale will catch this, but be proactive). |
| 168 | +- NEVER document behaviour you have not verified in the source. |
| 169 | +- NEVER copy metadata from another page without updating all fields. |
0 commit comments