|
| 1 | +# Temporal Documentation Site Utilities |
| 2 | + |
| 3 | +This file documents utilities meant to support repository health. |
| 4 | +These utilities are not meant for use by contributors. |
| 5 | + |
| 6 | +## audit-stray-pages |
| 7 | + |
| 8 | +[**Docusaurus**](https://docusaurus.io) serves all files, whether they are mentioned in sidebars.js or not. |
| 9 | +[**Algolia**](https://algolia.com) will index these files so they show up in search, even though we intend to hide them. |
| 10 | + |
| 11 | +The `audit-stray-pages` utility audits unreferenced docs files so they can be evaluated and, if needed, hidden in Docusaurus. |
| 12 | +This script scans your Docusaurus project for `.md` and `.mdx` files in the top level `docs/` folder and reports the ones that are **not actively referenced** in your `sidebars.js` file. "Not actively referenced" includes: |
| 13 | + |
| 14 | +- Files that were commented out in sidebars.js |
| 15 | +- Files that are not included at all |
| 16 | + |
| 17 | +It helps you find: |
| 18 | + |
| 19 | +- Stray or deprecated documentation pages that aren’t in the site navigation |
| 20 | +- Files that are publicly accessible but unintentionally published |
| 21 | +- Gaps in `id:` usage where default IDs don’t match sidebar references |
| 22 | + |
| 23 | +You can hide Docusaurus files by setting them to drafts in the file metadata: |
| 24 | + |
| 25 | +``` |
| 26 | +draft: true |
| 27 | +``` |
| 28 | + |
| 29 | +Docusaurus will render drafts in preview mode but not production. |
| 30 | + |
| 31 | +**Please note**: |
| 32 | + |
| 33 | +- Some "deprecated" files are left intentionally visible outside the normal navigation system and are linked from other pages. |
| 34 | + They should not be set to draft as that breaks `yarn build` and will fail CI and Vercel deployment. |
| 35 | +- The sidebars.js file does not use `/path/to/file.mdx`. |
| 36 | + It uses `/path/to/folder/your-file-id`, which uses the `id: your-file-id` declared in your mdx YAML frontmatter. |
| 37 | +- Slugs are not equivalent to ids. |
| 38 | + Ids are used to stitch together the site. |
| 39 | + |
| 40 | +### What It Does |
| 41 | + |
| 42 | +1. **Parses `sidebars.js`** to extract all actively referenced doc IDs |
| 43 | + - Ignores lines that are commented out (`//` or `/* ... */`) |
| 44 | +2. **Extracts doc IDs** from sidebar references, including: |
| 45 | + - Simple string references: `"foo/bar"` |
| 46 | + - Object syntax: `{ type: 'doc', id: 'foo/bar' }` |
| 47 | +3. **Scans all `.md` and `.mdx` files** in the `docs/` directory: |
| 48 | + - First checks if the file's path-derived ID is in the sidebar |
| 49 | + - Then checks for a frontmatter `id:` override and searches that |
| 50 | + - If neither is found, the file is flagged as unreferenced |
| 51 | + |
| 52 | +### Usage |
| 53 | + |
| 54 | +Save the script as `audit-stray-pages` and make it executable: |
| 55 | + |
| 56 | +```bash |
| 57 | +chmod +x audit-stray-pages |
| 58 | +./audit-stray-pages |
| 59 | +``` |
| 60 | + |
| 61 | +### Work |
| 62 | + |
| 63 | +After running the script, review each unreferenced file carefully. |
| 64 | + |
| 65 | +- Some files may be intentionally excluded from the sidebar, such as deprecated pages or internal drafts. |
| 66 | +- Others may be unintentional omissions that should be added to sidebars.js. |
| 67 | +- Others are intentionally excluded but not referenced from anywhere on the site. |
| 68 | + This is deliberate in the case of `tctl` pages. |
| 69 | + This is accidental for other pages. |
| 70 | + |
| 71 | +For each flagged file, check whether it: |
| 72 | + |
| 73 | +- Should be deleted or archived |
| 74 | +- Should have a `draft: true` frontmatter added (Docusaurus v3+) |
| 75 | +- Needs a matching `id:` in the frontmatter |
| 76 | +- Belongs in `sidebars.js` but was accidentally left out or commented out |
| 77 | + |
| 78 | +This utility highlights potential issues—it’s up to you to decide what belongs in our published documentation. |
0 commit comments