|
| 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. |
0 commit comments