-
-
Notifications
You must be signed in to change notification settings - Fork 252
Provide entire docs in a single text file for LLMs. #962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
fhammerschmidt
merged 6 commits into
rescript-lang:master
from
lucasguellis:llms-script
Jan 20, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
17be9d1
feat: script for generating llm files
16a3b2d
feat: adding mdx files on generating llm
ba95da9
feat: adding llms to sidebar + redirects to latest
1e5c255
fix: format
a072fcb
fix: changing to RegExp and String Rescript Core types
faa974c
feat: adding redirect for `next` version
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,7 @@ | |
"Extra": [ | ||
"newcomer-examples", | ||
"project-structure", | ||
"faq" | ||
"faq", | ||
"llms" | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,7 @@ | |
"Extra": [ | ||
"newcomer-examples", | ||
"project-structure", | ||
"faq" | ||
"faq", | ||
"llms" | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,5 +31,8 @@ | |
"beyond-jsx", | ||
"forwarding-refs", | ||
"extensions-of-props" | ||
], | ||
"Extra": [ | ||
"llms" | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,5 +26,8 @@ | |
"Guides": [ | ||
"beyond-jsx", | ||
"forwarding-refs" | ||
], | ||
"Extra": [ | ||
"llms" | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,5 +27,8 @@ | |
"beyond-jsx", | ||
"forwarding-refs", | ||
"extensions-of-props" | ||
], | ||
"Extra": [ | ||
"llms" | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
title: "LLMs" | ||
description: "Documentation for LLMs" | ||
canonical: "/docs/manual/<VERSION>/llms" | ||
--- | ||
|
||
# Documentation for LLMs | ||
|
||
We adhere to the [llms.txt convention](https://llmstxt.org/) to make documentation accessible to large language models and their applications. | ||
|
||
Currently, we have the following files... | ||
|
||
- [/docs/manual/llms.txt](/llms/manual/<VERSION>/llms.txt) — a list of the available files for ReScript language. | ||
- [/docs/manual/llm-full.txt](/llms/manual/<VERSION>/llm-full.txt) — complete documentation for ReScript language. | ||
- [/docs/manual/llm-small.txt](/llms/manual/<VERSION>/llm-small.txt) — compressed version of the former, without examples. | ||
|
||
...and package-level documentation: | ||
|
||
- [/docs/react/llms](/docs/react/latest/llms) — the LLms documentation for ReScript React. | ||
|
||
## Notes | ||
|
||
- The content is automatically generated from the same source as the official documentation for the specific version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# ReScript Documentation for LLMs | ||
|
||
> 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. | ||
|
||
## Documentation Sets | ||
|
||
- [Complete documentation](https://rescript-lang.org/llms/manual/<VERSION>/llm-full.txt): The complete ReScript documentation including all examples and additional content | ||
- [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 | ||
|
||
## Individual Package Documentation | ||
|
||
- [ReScript React documentation](https://rescript-lang.org/llms/react/latest/llms.txt): This is the developer documentation for ReScript React. | ||
|
||
## Notes | ||
|
||
- The abridged documentation excludes the detailed examples, and supplementary information | ||
- The complete documentation includes all content from the official documentation | ||
- Package-specific documentation files contain only the content relevant to that package | ||
- The content is automatically generated from the same source as the official documentation for the specific version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
title: "LLMs" | ||
description: "Documentation for LLMs" | ||
canonical: "/docs/react/<VERSION>/llms" | ||
--- | ||
|
||
# Documentation for LLMs | ||
|
||
We adhere to the [llms.txt convention](https://llmstxt.org/) to make documentation accessible to large language models and their applications. | ||
|
||
Currently, we have the following files... | ||
|
||
- [/docs/react/llms.txt](/llms/react/<VERSION>/llms.txt) — a list of the available files for ReScript React. | ||
- [/docs/react/llms-full.txt](/llms/react/<VERSION>/llm-full.txt) — complete documentation for ReScript React. | ||
- [/docs/react/llms-small.txt](/llms/react/<VERSION>/llm-small.txt) — compressed version of the former, without examples for ReScript React. | ||
|
||
...and the language documentation: | ||
|
||
- [/docs/manual/llms](/docs/manual/latest/llms) — the LLms documentation for ReScript. | ||
|
||
## Notes | ||
|
||
- The content is automatically generated from the same source as the official documentation for the specific version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# ReScript React Documentation for LLMs | ||
|
||
> 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. | ||
|
||
## ReScript React Documentation | ||
|
||
- [Complete documentation](https://rescript-lang.org/llms/react/<VERSION>/llm-full.txt): The complete ReScript React documentation including all examples and additional content | ||
- [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 | ||
|
||
## Language Documentation | ||
|
||
- [ReScript documentation](https://rescript-lang.org/llms/manual/latest/llms.txt): This is the developer documentation for ReScript. | ||
|
||
## Notes | ||
|
||
- The abridged documentation excludes the detailed examples, and supplementary information | ||
- The complete documentation includes all content from the official documentation | ||
- Package-specific documentation files contain only the content relevant to that package | ||
- The content is automatically generated from the same source as the official documentation for the specific version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
let readMarkdownFile = (filePath: string): string => { | ||
let fileContent = Node.Fs.readFileSync2(filePath, "utf8") | ||
fileContent | ||
} | ||
|
||
let rec collectFiles = (dirPath: string): array<string> => { | ||
let entries = Node.Fs.readdirSync(dirPath) | ||
entries->Array.reduce([], (acc, entry) => { | ||
let fullPath = Node.Path.join([dirPath, entry]) | ||
let stats = Node.Fs.statSync(fullPath) | ||
switch stats["isDirectory"]() { | ||
| true => acc->Array.concat(collectFiles(fullPath)) | ||
| false => { | ||
acc->Array.push(fullPath) | ||
acc | ||
} | ||
} | ||
}) | ||
} | ||
|
||
let clearFile = (filePath: string): unit => { | ||
Node.Fs.writeFileSync(filePath, "") | ||
} | ||
|
||
let createDirectoryIfNotExists = (dirPath: string): unit => { | ||
if !Node.Fs.existsSync(dirPath) { | ||
Node.Fs.mkdirSync(dirPath) | ||
} | ||
} | ||
|
||
let removeCodeTabTags = (content: string): string => { | ||
let regex = RegExp.fromStringWithFlags("<CodeTab.*?>[\\s\\S]*?</CodeTab>", ~flags="g") | ||
String.replaceRegExp(content, regex, "") | ||
} | ||
|
||
let removeCodeBlocks = (content: string): string => { | ||
let regex = RegExp.fromStringWithFlags("```[a-zA-Z]+\\s*[\\s\\S]*?```", ~flags="g") | ||
String.replaceRegExp(content, regex, "") | ||
} | ||
|
||
let removeFileTitle = (content: string): string => { | ||
let regex = RegExp.fromStringWithFlags("---\ntitle[\\s\\S]*?---", ~flags="g") | ||
String.replaceRegExp(content, regex, "") | ||
} | ||
|
||
let removeUnnecessaryBreaks = (content: string): string => { | ||
let regex = RegExp.fromStringWithFlags("^\n{2,}", ~flags="g") | ||
String.replaceRegExp(content, regex, "") | ||
} | ||
|
||
let removeToDos = (content: string): string => { | ||
let regex = RegExp.fromStringWithFlags("<!-- TODO[\\s\\S]*?-->", ~flags="g") | ||
String.replaceRegExp(content, regex, "") | ||
} | ||
|
||
let fillContentWithVersion = (content: string, version: string): string => { | ||
let regex = RegExp.fromStringWithFlags("<VERSION>", ~flags="g") | ||
String.replaceRegExp(content, regex, version) | ||
} | ||
|
||
let createFullFile = (content: string, filePath: string): unit => { | ||
Node.Fs.appendFileSync(filePath, content ++ "\n", "utf8") | ||
} | ||
|
||
let createSmallFile = (content: string, filePath: string): unit => { | ||
let smallContent = | ||
content | ||
->removeCodeTabTags | ||
->removeFileTitle | ||
->removeToDos | ||
->removeCodeBlocks | ||
->removeUnnecessaryBreaks | ||
Node.Fs.appendFileSync(filePath, smallContent, "utf8") | ||
} | ||
|
||
let createLlmsFiles = (version: string, docsDirectory: string, llmsDirectory: string): unit => { | ||
let mdxFileTemplatePath = llmsDirectory->Node.Path.join2("template.mdx") | ||
let mdxFilePath = docsDirectory->Node.Path.join2(version)->Node.Path.join2("llms.mdx") | ||
let txtFileTemplatePath = llmsDirectory->Node.Path.join2("template.txt") | ||
let txtFilePath = llmsDirectory->Node.Path.join2(version)->Node.Path.join2("llms.txt") | ||
|
||
Node.Fs.writeFileSync( | ||
mdxFilePath, | ||
readMarkdownFile(mdxFileTemplatePath)->fillContentWithVersion(version), | ||
) | ||
|
||
Node.Fs.writeFileSync( | ||
txtFilePath, | ||
readMarkdownFile(txtFileTemplatePath)->fillContentWithVersion(version), | ||
) | ||
} | ||
|
||
let processVersions = ( | ||
versions: array<string>, | ||
docsDirectory: string, | ||
llmsDirectory: string, | ||
): unit => { | ||
let fullFileName = "llm-full.txt" | ||
let smallFileName = "llm-small.txt" | ||
|
||
versions->Array.forEach(version => { | ||
let versionDir = docsDirectory->Node.Path.join2(version) | ||
let llmsDir = llmsDirectory->Node.Path.join2(version) | ||
let fullFilePath = llmsDir->Node.Path.join2(fullFileName) | ||
let smallFilePath = llmsDir->Node.Path.join2(smallFileName) | ||
|
||
createDirectoryIfNotExists(llmsDir) | ||
clearFile(fullFilePath) | ||
clearFile(smallFilePath) | ||
|
||
createLlmsFiles(version, docsDirectory, llmsDirectory) | ||
|
||
versionDir | ||
->collectFiles | ||
->Array.forEach(filePath => { | ||
if String.endsWith(filePath, ".mdx") { | ||
let content = readMarkdownFile(filePath) | ||
|
||
content->createFullFile(fullFilePath) | ||
|
||
content->createSmallFile(smallFilePath) | ||
} | ||
}) | ||
}) | ||
} | ||
|
||
let manualVersions = ["v12.0.0", "v11.0.0"] | ||
let reactManualVersions = ["latest", "v0.10.0", "v0.11.0"] | ||
|
||
let manualDocsDirectory = "pages/docs/manual" | ||
let reactDocsDirectory = "pages/docs/react" | ||
|
||
let manualLlmsDirectory = "public/llms/manual" | ||
let reactLlmsDirectory = "public/llms/react" | ||
|
||
processVersions(manualVersions, manualDocsDirectory, manualLlmsDirectory) | ||
processVersions(reactManualVersions, reactDocsDirectory, reactLlmsDirectory) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.