Skip to content

Commit 27eedd3

Browse files
authored
Provide entire docs in a single text file for LLMs. (#962)
* feat: script for generating llm files * feat: adding mdx files on generating llm * feat: adding llms to sidebar + redirects to latest * fix: format * fix: changing to RegExp and String Rescript Core types * feat: adding redirect for `next` version
1 parent d832f29 commit 27eedd3

15 files changed

+257
-3
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ lib/
2727

2828
src/**/*.mjs
2929
scripts/**/*.mjs
30+
31+
# Generated via generate-llms script
32+
public/llms/manual/**/llm*.txt
33+
public/llms/react/**/llm*.txt
34+
pages/docs/**/**/llms.mdx

data/sidebar_manual_v1100.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"Extra": [
7474
"newcomer-examples",
7575
"project-structure",
76-
"faq"
76+
"faq",
77+
"llms"
7778
]
7879
}

data/sidebar_manual_v1200.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"Extra": [
7373
"newcomer-examples",
7474
"project-structure",
75-
"faq"
75+
"faq",
76+
"llms"
7677
]
7778
}

data/sidebar_react_latest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,8 @@
3131
"beyond-jsx",
3232
"forwarding-refs",
3333
"extensions-of-props"
34+
],
35+
"Extra": [
36+
"llms"
3437
]
3538
}

data/sidebar_react_v0100.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@
2626
"Guides": [
2727
"beyond-jsx",
2828
"forwarding-refs"
29+
],
30+
"Extra": [
31+
"llms"
2932
]
3033
}

data/sidebar_react_v0110.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,8 @@
2727
"beyond-jsx",
2828
"forwarding-refs",
2929
"extensions-of-props"
30+
],
31+
"Extra": [
32+
"llms"
3033
]
3134
}

next.config.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ const config = {
136136
destination: `/docs/manual/${process.env.VERSION_NEXT}/:slug*`,
137137
permanent: false,
138138
},
139+
{
140+
source: "/llms/manual/latest/:file*",
141+
destination: `/llms/manual/${process.env.VERSION_LATEST}/:file*`,
142+
permanent: false,
143+
},
144+
{
145+
source: "/llms/manual/next/:file*",
146+
destination: `/llms/manual/${process.env.VERSION_NEXT}/:file*`,
147+
permanent: false,
148+
},
139149
];
140150
},
141151
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@
6161
"build": "rescript && npm run update-index && next build",
6262
"test": "node scripts/test-examples.mjs && node scripts/test-hrefs.mjs",
6363
"reanalyze": "reanalyze -all-cmt .",
64-
"update-index": "node scripts/extract-indices.mjs && node scripts/extract-tocs.mjs && node scripts/extract-syntax.mjs && node scripts/generate_feed.mjs > public/blog/feed.xml"
64+
"update-index": "npm run generate-llms && node scripts/extract-indices.mjs && node scripts/extract-tocs.mjs && node scripts/extract-syntax.mjs && node scripts/generate_feed.mjs > public/blog/feed.xml",
65+
"generate-llms": "node scripts/generate_llms.mjs"
6566
},
6667
"devDependencies": {
6768
"@mdx-js/react": "^2.3.0",

public/_redirects

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@
1111

1212
/docs/manual/latest/:slug* /docs/manual/v11.0.0/:slug* 307
1313
/docs/manual/next/:slug* /docs/manual/v12.0.0/:slug* 307
14+
15+
/llms/manual/latest/:file* /llms/manual/v11.0.0/:file* 307
16+
/llms/manual/next/:file* /llms/manual/v12.0.0/:file* 307

public/llms/manual/template.mdx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
title: "LLMs"
3+
description: "Documentation for LLMs"
4+
canonical: "/docs/manual/<VERSION>/llms"
5+
---
6+
7+
# Documentation for LLMs
8+
9+
We adhere to the [llms.txt convention](https://llmstxt.org/) to make documentation accessible to large language models and their applications.
10+
11+
Currently, we have the following files...
12+
13+
- [/docs/manual/llms.txt](/llms/manual/<VERSION>/llms.txt) — a list of the available files for ReScript language.
14+
- [/docs/manual/llm-full.txt](/llms/manual/<VERSION>/llm-full.txt) — complete documentation for ReScript language.
15+
- [/docs/manual/llm-small.txt](/llms/manual/<VERSION>/llm-small.txt) — compressed version of the former, without examples.
16+
17+
...and package-level documentation:
18+
19+
- [/docs/react/llms](/docs/react/latest/llms) — the LLms documentation for ReScript React.
20+
21+
## Notes
22+
23+
- The content is automatically generated from the same source as the official documentation for the specific version

0 commit comments

Comments
 (0)