Skip to content

Commit 16a3b2d

Browse files
author
luguellis
committed
feat: adding mdx files on generating llm
1 parent 17be9d1 commit 16a3b2d

File tree

7 files changed

+115
-5
lines changed

7 files changed

+115
-5
lines changed

.gitignore

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

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@
5858
},
5959
"scripts": {
6060
"dev": "next",
61-
"build": "rescript && npm run generate-llms && npm run update-index && next build",
61+
"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",
6565
"generate-llms": "node scripts/generate_llms.mjs"
6666
},
6767
"devDependencies": {

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

public/llms/manual/template.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# ReScript Documentation for LLMs
2+
3+
> ReScript is a robustly typed language that compiles to efficient and human-readable JavaScript. It comes with a lightning fast compiler toolchain that scales to any codebase size.
4+
5+
## Documentation Sets
6+
7+
- [Complete documentation](https://rescript-lang.org/llms/manual/<VERSION>/llm-full.txt): The complete ReScript documentation including all examples and additional content
8+
- [Abridged documentation](https://rescript-lang.org/llms/manual/<VERSION>/llm-small.txt): A minimal version of the ReScript documentation, with the essential content for quick reference
9+
10+
## Individual Package Documentation
11+
12+
- [ReScript React documentation](https://rescript-lang.org/llms/react/latest/llms.txt): This is the developer documentation for ReScript React.
13+
14+
## Notes
15+
16+
- The abridged documentation excludes the detailed examples, and supplementary information
17+
- The complete documentation includes all content from the official documentation
18+
- Package-specific documentation files contain only the content relevant to that package
19+
- The content is automatically generated from the same source as the official documentation for the specific version

public/llms/react/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/react/<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/react/llms.txt](/llms/react/<VERSION>/llms.txt) — a list of the available files for ReScript React.
14+
- [/docs/react/llms-full.txt](/llms/react/<VERSION>/llm-full.txt) — complete documentation for ReScript React.
15+
- [/docs/react/llms-small.txt](/llms/react/<VERSION>/llm-small.txt) — compressed version of the former, without examples for ReScript React.
16+
17+
...and the language documentation:
18+
19+
- [/docs/manual/llms](/docs/manual/latest/llms) — the LLms documentation for ReScript.
20+
21+
## Notes
22+
23+
- The content is automatically generated from the same source as the official documentation for the specific version

public/llms/react/template.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# ReScript React Documentation for LLMs
2+
3+
> ReScript React is a strongly typed interface for React, designed to integrate seamlessly with modern React (>= v18.0) while compiling to idiomatic JavaScript, enabling robust and scalable React applications.
4+
5+
## ReScript React Documentation
6+
7+
- [Complete documentation](https://rescript-lang.org/llms/react/<VERSION>/llm-full.txt): The complete ReScript React documentation including all examples and additional content
8+
- [Abridged documentation](https://rescript-lang.org/llms/react/<VERSION>/llm-small.txt): A minimal version of the ReScript React documentation, with the essential content for quick reference
9+
10+
## Language Documentation
11+
12+
- [ReScript documentation](https://rescript-lang.org/llms/manual/latest/llms.txt): This is the developer documentation for ReScript.
13+
14+
## Notes
15+
16+
- The abridged documentation excludes the detailed examples, and supplementary information
17+
- The complete documentation includes all content from the official documentation
18+
- Package-specific documentation files contain only the content relevant to that package
19+
- The content is automatically generated from the same source as the official documentation for the specific version

scripts/generate_llms.res

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ let removeToDos = (content: string): string => {
5353
Js.String.replaceByRe(regex, "", content)
5454
}
5555

56+
let fillContentWithVersion = (content: string, version: string): string => {
57+
let regex = Js.Re.fromStringWithFlags("<VERSION>", ~flags="g")
58+
Js.String.replaceByRe(regex, version, content)
59+
}
60+
5661
let createFullFile = (content: string, filePath: string): unit => {
5762
Node.Fs.appendFileSync(filePath, content ++ "\n", "utf8")
5863
}
@@ -68,14 +73,30 @@ let createSmallFile = (content: string, filePath: string): unit => {
6873
Node.Fs.appendFileSync(filePath, smallContent, "utf8")
6974
}
7075

76+
let createLlmsFiles = (version: string, docsDirectory: string, llmsDirectory: string): unit => {
77+
let mdxFileTemplatePath = llmsDirectory->Node.Path.join2("template.mdx")
78+
let mdxFilePath = docsDirectory->Node.Path.join2(version)->Node.Path.join2("llms.mdx")
79+
let txtFileTemplatePath = llmsDirectory->Node.Path.join2("template.txt")
80+
let txtFilePath = llmsDirectory->Node.Path.join2(version)->Node.Path.join2("llms.txt")
81+
82+
Node.Fs.writeFileSync(
83+
mdxFilePath,
84+
readMarkdownFile(mdxFileTemplatePath)->fillContentWithVersion(version),
85+
)
86+
87+
Node.Fs.writeFileSync(
88+
txtFilePath,
89+
readMarkdownFile(txtFileTemplatePath)->fillContentWithVersion(version),
90+
)
91+
}
92+
7193
let processVersions = (
7294
versions: array<string>,
7395
docsDirectory: string,
7496
llmsDirectory: string,
7597
): unit => {
7698
let fullFileName = "llm-full.txt"
7799
let smallFileName = "llm-small.txt"
78-
let llmsFileName = "llms.txt"
79100

80101
versions->Array.forEach(version => {
81102
let versionDir = docsDirectory->Node.Path.join2(version)
@@ -87,6 +108,8 @@ let processVersions = (
87108
clearFile(fullFilePath)
88109
clearFile(smallFilePath)
89110

111+
createLlmsFiles(version, docsDirectory, llmsDirectory)
112+
90113
versionDir
91114
->collectFiles
92115
->Array.forEach(filePath => {

0 commit comments

Comments
 (0)