|
1 | 1 | # Developer table of contents |
2 | 2 |
|
3 | | -This directory generates a full table of contents for the docs.github.com site. |
| 3 | +The dev-toc subject generates a static, browsable table of contents (TOC) for local development. It creates HTML files showing the complete documentation site structure across all versions, making it easy to navigate and verify the site hierarchy during development. |
| 4 | + |
| 5 | +## Purpose & Scope |
| 6 | + |
| 7 | +This subject is responsible for: |
| 8 | +- Generating static HTML TOC files for all versions |
| 9 | +- Rendering page titles with Liquid templating |
| 10 | +- Creating expandable/collapsible navigation tree |
| 11 | +- Supporting auto-expansion of specific product sections |
| 12 | +- Opening generated TOC in browser automatically |
| 13 | +- Developer tool for site navigation and verification |
4 | 14 |
|
5 | 15 | <img src="toc-screenshot.png" width=30% style="padding-bottom: 2em" /> |
6 | 16 |
|
7 | | -The table of contents is generated locally within the `static` subdirectory as a series of `index.html` files, within version subdirectories such as `free-pro-team@latest` and `enterprise-cloud@latest` etc. |
| 17 | +## Architecture & Key Assets |
| 18 | + |
| 19 | +### Key capabilities and their locations |
| 20 | + |
| 21 | +- `generate.ts` - Main script that builds TOC HTML files for all versions |
| 22 | +- `layout.html` - HTML template with expandable/collapsible tree structure |
| 23 | +- `static/` - Output directory containing generated `index.html` files per version (not committed) |
8 | 24 |
|
9 | | -## Generating the table of contents |
| 25 | +## Setup & Usage |
10 | 26 |
|
11 | | -To generate the table of contents, run the following command from the Terminal: |
| 27 | +### Generating the TOC |
| 28 | + |
| 29 | +Generate the complete table of contents: |
12 | 30 |
|
13 | 31 | ```bash |
14 | 32 | npm run dev-toc |
15 | 33 | ``` |
16 | 34 |
|
17 | | -After generating the files, the ToC should open in your default browser. If it doesn't, open your browser and navigate to `file:///PATH/TO/docs-internal/src/dev-toc/static/free-pro-team@latest/index.html`. |
| 35 | +This will: |
| 36 | +1. Generate HTML files in `src/dev-toc/static/` for each version |
| 37 | +2. Render all page titles (including Liquid templates) |
| 38 | +3. Open the TOC in your default browser at the FPT version |
| 39 | + |
| 40 | +If it doesn't open automatically, navigate to the generated file in your browser. |
18 | 41 |
|
19 | | -## Generating the ToC with one or more sections auto-expanded |
| 42 | +### Auto-expanding specific sections |
20 | 43 |
|
21 | | -Alternatively, you can generate the table of contents with a specific top-level section of the docs auto-expanded by running the following command: |
| 44 | +Generate TOC with specific product sections pre-expanded: |
22 | 45 |
|
23 | 46 | ```bash |
24 | | -tsx src/dev-toc/generate.ts -o PRODUCT-ID [PRODUCT-ID PRODUCT-ID ...] |
| 47 | +tsx src/dev-toc/generate.ts -o actions |
25 | 48 | ``` |
26 | 49 |
|
27 | | -where `PRODUCT-ID` is the first part of the URL for the top-level section of the docs. For example, the `actions` section of the docs has the URL `https://docs.github.com/en/actions`, so the `PRODUCT-ID` is `actions`. So the command would be: |
28 | | - |
| 50 | +Multiple sections: |
29 | 51 | ```bash |
30 | | -tsx src/dev-toc/generate.ts -o actions |
| 52 | +tsx src/dev-toc/generate.ts -o actions copilot pull-requests |
31 | 53 | ``` |
32 | 54 |
|
33 | | -Note: if you generate the table more than once, with a different product ID flag you will need to refresh the page to see the changes. |
| 55 | +Where product IDs match the URL structure (e.g., `actions` for `https://docs.github.com/en/actions`). |
| 56 | + |
| 57 | +Note: If regenerating with different flags, refresh your browser to see changes. |
| 58 | + |
| 59 | +### What gets generated |
| 60 | + |
| 61 | +For each version, the script: |
| 62 | +1. Loads the site tree for that version |
| 63 | +2. Recursively renders all page titles (handles Liquid templating) |
| 64 | +3. Builds an HTML tree with expandable/collapsible sections |
| 65 | +4. Writes to `static/{version}/index.html` |
| 66 | + |
| 67 | +## Data & External Dependencies |
| 68 | + |
| 69 | +### Data inputs |
| 70 | +- Site tree from content files (all pages and their hierarchy) |
| 71 | +- Page frontmatter (titles, which may include Liquid) |
| 72 | +- Version information from `@/versions/lib/all-versions` |
| 73 | + |
| 74 | +### Dependencies |
| 75 | +- `@/frame/middleware/context/context` - Context initialization |
| 76 | +- `@/content-render` - Liquid template rendering |
| 77 | +- `@/versions` - Version enumeration |
| 78 | +- HTML template in `layout.html` |
| 79 | +- Browser (for opening generated TOC) |
| 80 | + |
| 81 | +### Data outputs |
| 82 | +- Static HTML files in `static/` directory |
| 83 | +- One `index.html` per version |
| 84 | +- Expandable tree navigation with page links |
| 85 | +- Links that can open in VS Code or browser |
| 86 | + |
| 87 | +## Cross-links & Ownership |
| 88 | + |
| 89 | +### Related subjects |
| 90 | +- [`src/frame`](../frame/README.md) - Site tree structure and context |
| 91 | +- [`src/content-render`](../content-render/README.md) - Liquid rendering for titles |
| 92 | +- [`src/versions`](../versions/README.md) - Version enumeration |
| 93 | +- Content files - Source of page hierarchy |
| 94 | + |
| 95 | +### Ownership |
| 96 | +- Team: Docs Content (with engineering support and reviews as needed) |
| 97 | + |
| 98 | +## Current State & Next Steps |
| 99 | + |
| 100 | +### Use cases |
| 101 | + |
| 102 | +The dev-toc is useful for: |
| 103 | +- **Navigation** - Quickly browse entire site structure during development |
| 104 | +- **Verification** - Check that pages appear in correct hierarchy |
| 105 | +- **Title debugging** - See rendered titles (including Liquid output) |
| 106 | +- **Structure review** - Review content organization across versions |
| 107 | +- **Link checking** - Verify navigation structure makes sense |
| 108 | + |
| 109 | +### Known limitations |
| 110 | +- Generated files are static (don't auto-update when content changes) |
| 111 | +- Must regenerate when content structure changes |
| 112 | +- Only shows structure, not content |
| 113 | +- Requires re-running script to see updates |
| 114 | +- Links open file paths, not the dev server |
| 115 | + |
| 116 | +### Output directory |
| 117 | +The `static/` directory is gitignored because it contains generated files that vary by local environment. |
| 118 | + |
| 119 | +### Development workflow |
| 120 | + |
| 121 | +Common pattern: |
| 122 | +1. Make content structure changes |
| 123 | +2. Run `npm run dev-toc` |
| 124 | +3. Review structure in generated TOC |
| 125 | +4. Verify pages appear in correct locations |
| 126 | +5. Check that parent/child relationships are correct |
| 127 | + |
| 128 | +### Troubleshooting |
| 129 | + |
| 130 | +**TOC doesn't open:** |
| 131 | +Manually navigate to `src/dev-toc/static/free-pro-team@latest/index.html` in your file browser. |
| 132 | + |
| 133 | +**Missing pages:** |
| 134 | +- Ensure content files have proper frontmatter |
| 135 | +- Check that pages are included in parent's `children` array |
| 136 | +- Regenerate TOC after content changes |
| 137 | + |
| 138 | +**Liquid rendering errors:** |
| 139 | +Check console output when running `generate.ts` for template errors. |
| 140 | + |
| 141 | +**Wrong sections expanded:** |
| 142 | +Regenerate with correct `-o` flags, then refresh browser (hard refresh may be needed). |
| 143 | + |
0 commit comments