Skip to content

Commit e1632c5

Browse files
committed
build: generate llms.txt and markdown files of the documentation for optimal AI consumption
INSTUI-4701
1 parent e66ad32 commit e1632c5

22 files changed

+1067
-4
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
title: AI features
3+
category: Contributor Guides
4+
order: 8
5+
---
6+
7+
## Generating AI agent friendly markdown files for components and guides
8+
9+
InstUI's JSON metadata is used to create a markdown version of the documentation for easier use by AI tools and coding assistants.
10+
11+
These markdown files are created during the build process then are made available for users using specific links.
12+
13+
This collection includes structured files for almost everything under the 'Getting Started', 'Guides', 'Patterns' and 'Components' (including Components/AI Components and Components/Utilities) sections of the documentation.
14+
15+
How it works:
16+
The core logic resides in `packages/__docs__/buildScripts/ai-accessible-documentation/generate-ai-accessible-markdowns.mts`.
17+
18+
1. **Input and output**
19+
Input: The script processes the JSON files found under `packages/__docs__/__build__/docs` if they belong to the corresponding sections mentioned above.
20+
Output: A directory of generated .md files under `packages/__docs__/__build__/markdowns`, which are also compressed into a documentation.zip archive as well which also can be found in this directory.
21+
22+
2. **Data loading and classification**
23+
The script reads all JSON files from the specified docs folder.
24+
Identifies the necessary components and guides based on data.category value.
25+
26+
3. **Markdown generation**
27+
A markdown file is generated using the data found under the 'description' key. As for components, an addtional table of props and a 'Usage' section is generated for showing how to import the component.
28+
As for the table of props, the props of a child component (e.g. Tabs.Panel) of a parent component (e.g. Tabs) is also included in the table.
29+
30+
4. **Index file creation and packaging**
31+
After all individual markdown files are written, index.md file is generated, which acts as a master list of contents for the entire documentation set.
32+
Finally, the script uses the system's zip command to package all .md files in the output directory into the final documentation.zip file, which can be downloaded here: https://instructure.design/markdowns/documentation.zip
33+
The AI-friendly markdown files are now avaliable either downloading the documentation.zip file or through a link that follows this pattern: https://instructure.design/markdowns/Alert.md
34+
35+
## Generating llms.txt for LLMs
36+
37+
In addition to the markdown files, a llms.txt file is also generated. This file is specifically formatted for optimal consumption by Large Language Models (LLMs) and AI coding agents.
38+
This file contains a catalog of links pointing to the online markdown files of InstUI components and guides generated above and short description of each component/guide
39+
40+
How it works:
41+
The core logic resides in `packages/__docs__/buildScripts/ai-accessible-documentation/ggenerate-ai-accessible-llms-file.mts`.
42+
43+
1. **Input and output**
44+
Input: The script processes the following JSON file: `packages/__docs__/__build__/markdown-and-sources-data.json`
45+
Output: An llms.txt file is placed into `packages/__docs__/__build__` which can be found here: https://instructure.design/llms.txt
46+
47+
2. **Data loading and classification**
48+
The script indenftifies the necessary elements looking for "Getting Started", "Guides", "Patterns", and "Components" section names.
49+
50+
3. **Markdown generation**
51+
It creates a documentation structure like this:
52+
53+
```md
54+
---
55+
type: code
56+
---
57+
58+
# Instructure UI (InstUI) - React Component Library
59+
60+
## Documentation
61+
62+
### User Guides
63+
64+
#### Getting Started
65+
66+
#### Guides
67+
68+
#### Patterns
69+
70+
### Components
71+
72+
#### Utilities
73+
74+
#### AI components
75+
```
76+
77+
It generates links for the components/guides and appends a brief summary of each of them using the `packages/__docs__/buildScripts/ai-accessible-documentation/summaries-for-llms-file.json` file, searching for matching component/guide title.

docs/contributor-docs/contributing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ Please update the documentation and examples with any changes.
102102
11. Visit [http://localhost:9090](http://localhost:9090) in a browser. You should see your component listed in the docs.
103103
12. Start making changes to your component, and watch it update in the browser automatically.
104104
13. Resolve all `FIXME` comments in the generated code (except in the `MyComponentLocator.ts`).
105+
14. Add a short description of the new component to the `packages/__docs__/buildScripts/ai-accessible-documentation/summaries-for-llms-file.json` file. This will optimize the component's documentation for consumption by AI agents.
105106

106107
### Adding a new dependency
107108

docs/getting-started/accessibility.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Accessibility
33
category: Getting Started
44
order: 6
5+
relevantForAI: true
56
---
67

78
## Accessibility

docs/getting-started/theming-components.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Themes
33
category: Getting Started
44
order: 8
5+
relevantForAI: true
56
---
67

78
## Themes

docs/getting-started/usage.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Usage
33
category: Getting Started
44
order: 1
5+
relevantForAI: true
56
---
67

78
## Quick Start
@@ -74,6 +75,20 @@ Congrats, you have now a (very) basic app that uses Instructure UI :)
7475

7576
Just add the `@instructure/ui` dependency as shown above and wrap the part of your app that will use InstUI in `<InstUISettingsProvider>` and start using InstUI components.
7677

78+
## Using InstUI with AI coding agents
79+
80+
InstUI provides a compressed, downloadable collection of all component documentation and user guides in an AI-agent-friendly markdown format.
81+
82+
You can download the archive from the following link:
83+
https://instructure.design/markdowns/documentation.zip
84+
85+
The download includes an index.md file that references all available documentation within the compressed folder.
86+
87+
These files are designed to be used as context for AI coding agents.
88+
89+
Additionally, an llms.txt file is available. This file contains a catalog of links pointing to the online markdown files for InstUI components and guides, which are also accessible to AI agents. It can be found at:
90+
https://instructure.design/llms.txt
91+
7792
## Further reading
7893

7994
- To use a different theme or customize one read about [Using theme overrides](#using-theme-overrides)

docs/guides/accessing-the-dom.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Accessing the DOM
33
category: Guides
44
order: 5
5+
relevantForAI: true
56
---
67

78
## Accessing the DOM

docs/guides/color-system.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Color System
33
category: Guides
44
order: 6
5+
relevantForAI: true
56
---
67

78
## Colors

docs/guides/focus-management.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Focus Management
33
category: Guides
44
order: 4
5+
relevantForAI: true
56
---
67

78
## The Focus Management Problem

docs/guides/form-errors.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Form Errors
33
category: Guides
44
order: 7
5+
relevantForAI: true
56
---
67

78
# Adding Error Messages to Form Components

docs/guides/layout-spacing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Layout Spacing
33
category: Guides
44
order: 8
5+
relevantForAI: true
56
---
67

78
# Layout Spacing

0 commit comments

Comments
 (0)