Skip to content

Commit 51bb6ba

Browse files
authored
Merge pull request #21844 from unoplatform/copilot/add-table-of-contents-to-llms
feat: Auto-generate table of contents in llms.txt from toc.yml
2 parents d9b756c + 8d57c6e commit 51bb6ba

File tree

4 files changed

+445
-273
lines changed

4 files changed

+445
-273
lines changed

build/Uno.UI.Build.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149

150150
<Exec Command="..\src\Uno.UWPSyncGenerator\Bin\Release\Uno.UWPSyncGenerator.exe &quot;doc&quot;" />
151151
<Exec Command="powershell .\import_external_docs.ps1" WorkingDirectory="..\doc" />
152-
<Exec Command="powershell .\generate-llms-full.ps1 -InputFolder &quot;articles&quot; -OutputFile &quot;articles/llms/llms-full.txt&quot; -Llmstxt &quot;articles/llms/llms.txt&quot;" WorkingDirectory="..\doc" />
152+
<Exec Command="powershell .\generate-llms-full.ps1 -InputFolder &quot;articles&quot; -LlmsTxtOutput &quot;articles/llms/llms.txt&quot; -LlmsFullTxtOutput &quot;articles/llms/llms-full.txt&quot; -BaseContentFile &quot;articles/llms/llms.txt&quot; -TocYmlPath &quot;articles/toc.yml&quot;" WorkingDirectory="..\doc" />
153153
<Exec Command="dotnet tool install --tool-path $(MSBuildThisFileDirectory)\tools docfx --version $(DocfxVersion)" Condition="!exists('$(MSBuildThisFileDirectory)\tools\docfx.exe')" />
154154
<Exec Command="$(MSBuildThisFileDirectory)\tools\docfx.exe ..\doc\docfx.json --debug -o $(OutputDir)\doc" />
155155
</Target>

doc/README.md

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,44 @@ build command is ran just before committing your work; this will minify the code
5858
folders and build the DocFx according to the `docfx.json`. The CI only runs the DocFx command, it will not regenerate
5959
the `styles` folder.
6060

61+
## Generating LLM Files
62+
63+
The documentation can be exported into LLM-friendly formats using the `generate-llms-full.ps1` PowerShell script. The script generates two files:
64+
65+
1. **llms.txt** - Lightweight index with base content and table of contents pointing to raw GitHub files
66+
2. **llms-full.txt** - Complete documentation with llms.txt content at the top, followed by all markdown documentation
67+
68+
### Usage
69+
70+
```bash
71+
pwsh ./generate-llms-full.ps1 `
72+
-InputFolder ./articles `
73+
-LlmsTxtOutput ./llms.txt `
74+
-LlmsFullTxtOutput ./llms-full.txt `
75+
-BaseContentFile ./articles/llms/llms.txt `
76+
-TocYmlPath ./articles/toc.yml
77+
```
78+
79+
### Output Files
80+
81+
**llms.txt** contains:
82+
83+
- Base content (introduction and important notes from `articles/llms/llms.txt`)
84+
- Generated table of contents from `toc.yml` with links to raw GitHub files on master branch
85+
86+
**llms-full.txt** contains:
87+
88+
- Complete llms.txt content at the top
89+
- Additional table of contents with xref anchor links (e.g., `#Uno.GetStarted`)
90+
- Full content of all markdown files with resolved xrefs and includes
91+
92+
### Notes
93+
94+
- The `articles/llms/llms.txt` file in the repository contains only the base content (introduction and important notes)
95+
- During the build process, the script first reads this file as the base content, then generates new llms.txt and llms-full.txt files with the auto-generated table of contents appended
96+
- The generated files are written to `articles/llms/llms.txt` and `articles/llms/llms-full.txt`
97+
- **Important**: Only commit the base content version of `articles/llms/llms.txt`. The script safely reads the base content before overwriting the file during builds
98+
6199
## Commands
62100

63101
### Start
@@ -126,17 +164,17 @@ Spell-checking for the docs is done as part of a GitHub Action.
126164
127165
If you'd like to perform the same check locally, you can run:
128166

129-
* `npm install -g cspell@8.3.2` to install the cSpell CLI
130-
* `cspell --config ./cSpell.json "doc/**/*.md" --no-progress` to check all the markdown files in the `doc` folder.
167+
- `npm install -g cspell@8.3.2` to install the cSpell CLI
168+
- `cspell --config ./cSpell.json "doc/**/*.md" --no-progress` to check all the markdown files in the `doc` folder.
131169

132170
### Markdown linting the docs
133171

134172
Markdown linting for the docs is done as part of a GitHub Action.
135173

136174
If you'd like to perform the same check locally, you can run:
137175
138-
* `npm install -g markdownlint-cli@0.38.0` to install the markdownlint CLI
139-
* `markdownlint "doc/**/*.md"` to lint all the markdown files in the `doc` folder.
176+
- `npm install -g markdownlint-cli@0.38.0` to install the markdownlint CLI
177+
- `markdownlint "doc/**/*.md"` to lint all the markdown files in the `doc` folder.
140178
141179
You can also install the [markdownlint Visual Studio Code Extension](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint) to easily check markdown linting and style while writing documentation.
142180

0 commit comments

Comments
 (0)