typedoc-plugin-llms-txt 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/LICENSE +55 -0
- package/README.md +130 -0
- package/dist/generator.d.ts +172 -0
- package/dist/generator.d.ts.map +1 -0
- package/dist/generator.js +434 -0
- package/dist/generator.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +144 -0
- package/dist/index.js.map +1 -0
- package/dist/options.d.ts +76 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +74 -0
- package/dist/options.js.map +1 -0
- package/dist/template.d.ts +44 -0
- package/dist/template.d.ts.map +1 -0
- package/dist/template.js +95 -0
- package/dist/template.js.map +1 -0
- package/package.json +128 -0
- package/src/generator.ts +563 -0
- package/src/index.ts +193 -0
- package/src/options.ts +152 -0
- package/src/template.ts +131 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Blue Oak Model License
|
|
2
|
+
|
|
3
|
+
Version 1.0.0
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
This license gives everyone as much permission to work with
|
|
8
|
+
this software as possible, while protecting contributors
|
|
9
|
+
from liability.
|
|
10
|
+
|
|
11
|
+
## Acceptance
|
|
12
|
+
|
|
13
|
+
In order to receive this license, you must agree to its
|
|
14
|
+
rules. The rules of this license are both obligations
|
|
15
|
+
under that agreement and conditions to your license.
|
|
16
|
+
You must not do anything with this software that triggers
|
|
17
|
+
a rule that you cannot or will not follow.
|
|
18
|
+
|
|
19
|
+
## Copyright
|
|
20
|
+
|
|
21
|
+
Each contributor licenses you to do everything with this
|
|
22
|
+
software that would otherwise infringe that contributor's
|
|
23
|
+
copyright in it.
|
|
24
|
+
|
|
25
|
+
## Notices
|
|
26
|
+
|
|
27
|
+
You must ensure that everyone who gets a copy of
|
|
28
|
+
any part of this software from you, with or without
|
|
29
|
+
changes, also gets the text of this license or a link to
|
|
30
|
+
<https://blueoakcouncil.org/license/1.0.0>.
|
|
31
|
+
|
|
32
|
+
## Excuse
|
|
33
|
+
|
|
34
|
+
If anyone notifies you in writing that you have not
|
|
35
|
+
complied with [Notices](#notices), you can keep your
|
|
36
|
+
license by taking all practical steps to comply within 30
|
|
37
|
+
days after the notice. If you do not do so, your license
|
|
38
|
+
ends immediately.
|
|
39
|
+
|
|
40
|
+
## Patent
|
|
41
|
+
|
|
42
|
+
Each contributor licenses you to do everything with this
|
|
43
|
+
software that would otherwise infringe any patent claims
|
|
44
|
+
they can license or become able to license.
|
|
45
|
+
|
|
46
|
+
## Reliability
|
|
47
|
+
|
|
48
|
+
No contributor can revoke this license.
|
|
49
|
+
|
|
50
|
+
## No Liability
|
|
51
|
+
|
|
52
|
+
**_As far as the law allows, this software comes as is,
|
|
53
|
+
without any warranty or condition, and no contributor
|
|
54
|
+
will be liable to anyone for any damages related to this
|
|
55
|
+
software or this license, under any kind of legal claim._**
|
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# typedoc-plugin-llms-txt
|
|
2
|
+
|
|
3
|
+
A TypeDoc plugin that generates `llms.txt` files for LLM consumption.
|
|
4
|
+
|
|
5
|
+
## What is llms.txt?
|
|
6
|
+
|
|
7
|
+
[llms.txt](https://llmstxt.org/) is a convention for providing LLM-friendly documentation summaries. This plugin automatically generates an `llms.txt` file from your TypeDoc documentation.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install typedoc-plugin-llms-txt typedoc -D
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
Add the plugin to your TypeDoc configuration:
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
// typedoc.config.js
|
|
21
|
+
export default {
|
|
22
|
+
plugin: ['typedoc-plugin-llms-txt'],
|
|
23
|
+
// ... other options
|
|
24
|
+
};
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
That's it! The plugin will generate an `llms.txt` file in your output directory with reasonable defaults.
|
|
28
|
+
|
|
29
|
+
## Zero-Config Defaults
|
|
30
|
+
|
|
31
|
+
The plugin works out of the box with sensible defaults:
|
|
32
|
+
|
|
33
|
+
- **Project name**: From TypeDoc's `name` option
|
|
34
|
+
- **Description**: From your `package.json` description
|
|
35
|
+
- **Sections**: Auto-discovered from `projectDocuments` frontmatter categories
|
|
36
|
+
- **API links**: Auto-generated from TypeDoc entry points
|
|
37
|
+
|
|
38
|
+
## Configuration
|
|
39
|
+
|
|
40
|
+
Customize the output with these TypeDoc options:
|
|
41
|
+
|
|
42
|
+
### `llmsTxt`
|
|
43
|
+
|
|
44
|
+
Enable or disable llms.txt generation. Default: `true`
|
|
45
|
+
|
|
46
|
+
### `llmsTxtFilename`
|
|
47
|
+
|
|
48
|
+
Output filename. Default: `"llms.txt"`
|
|
49
|
+
|
|
50
|
+
### `llmsTxtHeader`
|
|
51
|
+
|
|
52
|
+
Customize the header section:
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
{
|
|
56
|
+
llmsTxtHeader: {
|
|
57
|
+
name: 'My Project', // defaults to TypeDoc name
|
|
58
|
+
description: 'A cool library', // defaults to package.json description
|
|
59
|
+
features: [ // defaults to empty
|
|
60
|
+
'Feature one',
|
|
61
|
+
'Feature two',
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### `llmsTxtSections`
|
|
68
|
+
|
|
69
|
+
Control how document categories are displayed and ordered:
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
{
|
|
73
|
+
llmsTxtSections: {
|
|
74
|
+
Guides: { displayName: 'Documentation', order: 1 },
|
|
75
|
+
Reference: { displayName: 'Reference', order: 2 },
|
|
76
|
+
About: { displayName: 'Optional', order: 3 },
|
|
77
|
+
},
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Categories not listed use their original name and appear alphabetically after configured sections.
|
|
82
|
+
|
|
83
|
+
### `llmsTxtDeclarations`
|
|
84
|
+
|
|
85
|
+
Add links to specific API symbols using TypeDoc declaration references:
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
{
|
|
89
|
+
llmsTxtDeclarations: [
|
|
90
|
+
{ ref: 'myproject!', label: 'API Reference', description: 'Full API docs' },
|
|
91
|
+
{ ref: 'myproject!myFunction', label: 'myFunction()' },
|
|
92
|
+
],
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### `llmsTxtQuickReference`
|
|
97
|
+
|
|
98
|
+
Add a code examples section:
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
{
|
|
102
|
+
llmsTxtQuickReference: `
|
|
103
|
+
// Basic usage
|
|
104
|
+
import { foo } from 'myproject';
|
|
105
|
+
foo();
|
|
106
|
+
`,
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### `llmsTxtTemplate`
|
|
111
|
+
|
|
112
|
+
Use a custom template file for full layout control:
|
|
113
|
+
|
|
114
|
+
```js
|
|
115
|
+
{
|
|
116
|
+
llmsTxtTemplate: './llms-template.md',
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Template slots:
|
|
121
|
+
|
|
122
|
+
- `{{header}}` - Name, description, and features
|
|
123
|
+
- `{{sections}}` - All document sections
|
|
124
|
+
- `{{section:CategoryName}}` - Specific category
|
|
125
|
+
- `{{declarations}}` - API links
|
|
126
|
+
- `{{quickReference}}` - Code examples
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
[BlueOak-1.0.0](https://blueoakcouncil.org/license/1.0.0)
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core llms.txt content generation logic
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
import type { Application, ProjectReflection } from 'typedoc';
|
|
7
|
+
import type { LlmsTxtDeclaration, LlmsTxtHeader, LlmsTxtSectionConfig } from './options.js';
|
|
8
|
+
/**
|
|
9
|
+
* Document info extracted from markdown frontmatter
|
|
10
|
+
*/
|
|
11
|
+
export interface DocumentInfo {
|
|
12
|
+
category: string;
|
|
13
|
+
path: string;
|
|
14
|
+
title: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* All content needed to render llms.txt
|
|
18
|
+
*/
|
|
19
|
+
export interface LlmsTxtContent {
|
|
20
|
+
declarations: ResolvedDeclaration[];
|
|
21
|
+
header: {
|
|
22
|
+
description: string;
|
|
23
|
+
features: string[];
|
|
24
|
+
name: string;
|
|
25
|
+
};
|
|
26
|
+
quickReference: string;
|
|
27
|
+
sections: Section[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Resolved declaration with URL
|
|
31
|
+
*/
|
|
32
|
+
export interface ResolvedDeclaration {
|
|
33
|
+
description?: string;
|
|
34
|
+
label: string;
|
|
35
|
+
url: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Section with its documents
|
|
39
|
+
*/
|
|
40
|
+
export interface Section {
|
|
41
|
+
displayName: string;
|
|
42
|
+
documents: DocumentInfo[];
|
|
43
|
+
name: string;
|
|
44
|
+
order: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Strips YAML string quotes from a value
|
|
48
|
+
*
|
|
49
|
+
* YAML allows strings to be quoted with single or double quotes to escape
|
|
50
|
+
* special characters. This function removes those quotes to get the actual
|
|
51
|
+
* string value.
|
|
52
|
+
*
|
|
53
|
+
* @function
|
|
54
|
+
* @param value - Raw YAML string value (may include quotes)
|
|
55
|
+
* @returns Unquoted string value
|
|
56
|
+
*/
|
|
57
|
+
export declare const stripYamlQuotes: (value: string) => string;
|
|
58
|
+
/**
|
|
59
|
+
* Extracts YAML frontmatter from markdown content
|
|
60
|
+
*
|
|
61
|
+
* @function
|
|
62
|
+
* @param content - Markdown file content
|
|
63
|
+
* @returns Frontmatter object or null if not found
|
|
64
|
+
*/
|
|
65
|
+
export declare const extractFrontmatter: (content: string) => null | {
|
|
66
|
+
category?: string;
|
|
67
|
+
title?: string;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Converts a document title to TypeDoc's URL path format
|
|
71
|
+
*
|
|
72
|
+
* TypeDoc converts titles by:
|
|
73
|
+
*
|
|
74
|
+
* - `@` → `-I_`
|
|
75
|
+
* - `/` → `_`
|
|
76
|
+
* - `&` → `___`
|
|
77
|
+
* - ` ` → `_`
|
|
78
|
+
*
|
|
79
|
+
* @function
|
|
80
|
+
* @param title - Document title
|
|
81
|
+
* @returns URL path segment
|
|
82
|
+
*/
|
|
83
|
+
export declare const titleToUrlPath: (title: string) => string;
|
|
84
|
+
/**
|
|
85
|
+
* Discovers sections from project documents
|
|
86
|
+
*
|
|
87
|
+
* @function
|
|
88
|
+
* @param projectDocuments - Paths to project document files
|
|
89
|
+
* @param sectionConfig - User-provided section configuration
|
|
90
|
+
* @param baseUrl - Base URL for links
|
|
91
|
+
* @returns Array of sections with their documents
|
|
92
|
+
*/
|
|
93
|
+
export declare const discoverSections: (projectDocuments: string[], sectionConfig: Record<string, LlmsTxtSectionConfig>, baseUrl: string) => Section[];
|
|
94
|
+
/**
|
|
95
|
+
* Auto-generates declarations from entry points
|
|
96
|
+
*
|
|
97
|
+
* @function
|
|
98
|
+
* @param project - TypeDoc project reflection
|
|
99
|
+
* @param baseUrl - Base URL for links
|
|
100
|
+
* @returns Array of resolved declarations
|
|
101
|
+
*/
|
|
102
|
+
export declare const autoGenerateDeclarations: (project: ProjectReflection, baseUrl: string) => ResolvedDeclaration[];
|
|
103
|
+
/**
|
|
104
|
+
* Resolves declaration references to URLs
|
|
105
|
+
*
|
|
106
|
+
* @function
|
|
107
|
+
* @param declarations - User-provided declaration configs
|
|
108
|
+
* @param project - TypeDoc project reflection
|
|
109
|
+
* @param app - TypeDoc application
|
|
110
|
+
* @param baseUrl - Base URL for links
|
|
111
|
+
* @returns Array of resolved declarations
|
|
112
|
+
*/
|
|
113
|
+
export declare const resolveDeclarations: (declarations: LlmsTxtDeclaration[], project: ProjectReflection, app: Application, baseUrl: string) => ResolvedDeclaration[];
|
|
114
|
+
/**
|
|
115
|
+
* Gets the project name with fallback
|
|
116
|
+
*
|
|
117
|
+
* @function
|
|
118
|
+
* @param app - TypeDoc application
|
|
119
|
+
* @param headerConfig - User header configuration
|
|
120
|
+
* @returns Project name
|
|
121
|
+
*/
|
|
122
|
+
export declare const getProjectName: (app: Application, headerConfig: LlmsTxtHeader) => string;
|
|
123
|
+
/**
|
|
124
|
+
* Gets the project description with fallback to package.json
|
|
125
|
+
*
|
|
126
|
+
* @function
|
|
127
|
+
* @param app - TypeDoc application
|
|
128
|
+
* @param headerConfig - User header configuration
|
|
129
|
+
* @returns Project description or empty string
|
|
130
|
+
*/
|
|
131
|
+
export declare const getProjectDescription: (app: Application, headerConfig: LlmsTxtHeader) => string;
|
|
132
|
+
/**
|
|
133
|
+
* Renders the llms.txt content to a string
|
|
134
|
+
*
|
|
135
|
+
* @function
|
|
136
|
+
* @param content - The content to render
|
|
137
|
+
* @returns Rendered llms.txt string
|
|
138
|
+
*/
|
|
139
|
+
export declare const renderLlmsTxt: (content: LlmsTxtContent) => string;
|
|
140
|
+
/**
|
|
141
|
+
* Renders a specific section to markdown
|
|
142
|
+
*
|
|
143
|
+
* @function
|
|
144
|
+
* @param section - The section to render
|
|
145
|
+
* @returns Rendered section string
|
|
146
|
+
*/
|
|
147
|
+
export declare const renderSection: (section: Section) => string;
|
|
148
|
+
/**
|
|
149
|
+
* Renders the header to markdown
|
|
150
|
+
*
|
|
151
|
+
* @function
|
|
152
|
+
* @param header - Header content
|
|
153
|
+
* @returns Rendered header string
|
|
154
|
+
*/
|
|
155
|
+
export declare const renderHeader: (header: LlmsTxtContent["header"]) => string;
|
|
156
|
+
/**
|
|
157
|
+
* Renders declarations to markdown
|
|
158
|
+
*
|
|
159
|
+
* @function
|
|
160
|
+
* @param declarations - Resolved declarations
|
|
161
|
+
* @returns Rendered declarations string
|
|
162
|
+
*/
|
|
163
|
+
export declare const renderDeclarations: (declarations: ResolvedDeclaration[]) => string;
|
|
164
|
+
/**
|
|
165
|
+
* Renders quick reference to markdown
|
|
166
|
+
*
|
|
167
|
+
* @function
|
|
168
|
+
* @param quickReference - Quick reference content
|
|
169
|
+
* @returns Rendered quick reference string
|
|
170
|
+
*/
|
|
171
|
+
export declare const renderQuickReference: (quickReference: string) => string;
|
|
172
|
+
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../src/generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAK9D,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACb,oBAAoB,EACrB,MAAM,cAAc,CAAC;AAEtB;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,mBAAmB,EAAE,CAAC;IACpC,MAAM,EAAE;QACN,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED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