-
Notifications
You must be signed in to change notification settings - Fork 243
docs: add llms.txt, page descriptions, and edit links #4037
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
Open
Giri-Aayush
wants to merge
1
commit into
NethermindEth:main
Choose a base branch
from
Giri-Aayush:docs/agent-readiness
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
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
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
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 |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| --- | ||
| title: GCP | ||
| description: "Run a Juno node on Google Cloud Platform." | ||
| --- | ||
|
|
||
| # Running Juno on GCP | ||
|
|
||
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
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
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
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file should maybe have unit tests? |
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,151 @@ | ||
| // Emits /llms.txt, /llms-full.txt and a raw .md route beside every page, on every build, | ||
| // generated from the version the site root serves (versions.json[0]), never from next. | ||
|
|
||
| const fs = require("fs"); | ||
| const path = require("path"); | ||
|
|
||
| // Strip MDX plumbing (imports, mdx-code-block fences) so agents get plain markdown. | ||
| // dir is the page's directory, used to inline any local partial it renders. | ||
| function cleanBody(body, dir) { | ||
| // Inline local partials: `import X from "./_p.md"` + `<X />` becomes the | ||
| // partial's content, so a page's real table isn't left as a dangling tag. | ||
| if (dir) { | ||
| const partials = {}; | ||
| for (const m of body.matchAll(/^import\s+(\w+)\s+from\s+["'](\.\/[\w./-]+\.md)["']/gm)) { | ||
| const f = path.join(dir, m[2]); | ||
| if (fs.existsSync(f)) partials[m[1]] = readPage(f).body; | ||
| } | ||
| for (const [name, pbody] of Object.entries(partials)) { | ||
| body = body.replace(new RegExp(`<${name}\\s*/>`, "g"), "\n" + pbody.trim() + "\n"); | ||
| } | ||
| } | ||
| // Tabs are presentation only; unwrap TabItems to "### <label>" and drop the wrappers. | ||
| body = body | ||
| .replace(/<TabItem\b[^>]*\b(?:label|value)="([^"]+)"[^>]*>/g, "\n### $1\n") | ||
| .replace(/<\/?Tabs\b[^>]*>/g, "") | ||
| .replace(/<\/TabItem>/g, ""); | ||
| // GuideCards become plain markdown links so their routing survives. | ||
| body = body.replace(/<GuideCard\b([\s\S]*?)\/>/g, (m, props) => { | ||
| const g = (k) => (props.match(new RegExp(`${k}="([^"]+)"`)) || [])[1]; | ||
| if (!g("href") || !g("title")) return m; // keep a broken card visible rather than dropping it | ||
| return `- [${g("title")}](${g("href")})${g("description") ? ": " + g("description") : ""}`; | ||
| }); | ||
| const lines = []; | ||
| let inMdx = false; | ||
| let inFence = false; // never strip anything inside a real code fence | ||
| for (const l of body.split("\n")) { | ||
| const t = l.trim(); | ||
| if (t === "```mdx-code-block") { inMdx = true; continue; } | ||
| if (inMdx && t === "```") { inMdx = false; continue; } | ||
| if (!inMdx && /^(```|~~~)/.test(t)) inFence = !inFence; | ||
| if (!inFence && /^import\s.+\sfrom\s["']/.test(l)) continue; | ||
| lines.push(l); | ||
| } | ||
| return lines.join("\n").replace(/\n{3,}/g, "\n\n"); | ||
| } | ||
|
|
||
| // Read one page's frontmatter and body. | ||
| function readPage(file) { | ||
| const raw = fs.readFileSync(file, "utf8"); | ||
| const fm = raw.match(/^---\n([\s\S]*?)\n---\n/); | ||
| const field = (name) => { | ||
| const v = ((fm ? fm[1] : "").match(new RegExp(`^${name}:\\s*(.+)$`, "m")) || [])[1]; | ||
| return v && v.replace(/^"(.*)"$/, "$1"); // values may be quoted | ||
| }; | ||
| return { | ||
| id: path.basename(file, ".md"), | ||
| title: field("title") || path.basename(file, ".md"), | ||
| description: field("description") || "", | ||
| slug: field("slug"), | ||
| raw, | ||
| body: fm ? raw.slice(fm[0].length) : raw, | ||
| }; | ||
| } | ||
|
|
||
| // Sidebar JSON: strings are doc ids, categories carry labels, html items are skipped. | ||
| function sidebarSections(sidebarFile) { | ||
| const sidebars = Object.values(JSON.parse(fs.readFileSync(sidebarFile, "utf8"))); | ||
| if (sidebars.length !== 1) { | ||
| throw new Error(`[llms-txt] expected one sidebar, found ${sidebars.length}; update the plugin`); | ||
| } | ||
| const sidebar = sidebars[0]; | ||
| const sections = []; | ||
| let current = { label: null, ids: [] }; | ||
| for (const item of sidebar) { | ||
| if (typeof item === "string") { | ||
| current.ids.push(item); | ||
| } else if (item.type === "category") { | ||
| if (current.ids.length) sections.push(current); | ||
| const ids = item.items.filter((i) => typeof i === "string"); | ||
| sections.push({ label: item.label, ids }); | ||
| current = { label: null, ids: [] }; | ||
| } | ||
| } | ||
| if (current.ids.length) sections.push(current); | ||
| return sections; | ||
| } | ||
|
|
||
| module.exports = function llmsTxtPlugin() { | ||
| return { | ||
| name: "llms-txt", | ||
| async postBuild({ siteConfig, siteDir, outDir }) { | ||
| const versions = JSON.parse( | ||
| fs.readFileSync(path.join(siteDir, "versions.json"), "utf8"), | ||
| ); | ||
| const version = versions[0]; | ||
| const docsDir = path.join(siteDir, "versioned_docs", `version-${version}`); | ||
| const sidebarFile = path.join( | ||
| siteDir, "versioned_sidebars", `version-${version}-sidebars.json`, | ||
| ); | ||
| const site = siteConfig.url; | ||
|
|
||
| // Disk decides what exists; the sidebar only orders and labels it. | ||
| const onDisk = fs.readdirSync(docsDir) | ||
| .filter((f) => f.endsWith(".md") && !f.startsWith("_")) | ||
| .map((f) => f.slice(0, -3)); | ||
| const sections = sidebarSections(sidebarFile); | ||
| const listed = new Set(sections.flatMap((s) => s.ids)); | ||
| const unlisted = onDisk.filter((id) => !listed.has(id)); | ||
| if (unlisted.length) sections.push({ label: "Other pages", ids: unlisted.sort() }); | ||
|
|
||
| const index = []; | ||
| const full = []; | ||
| for (const section of sections) { | ||
| if (section.label) index.push(`\n- ${section.label}\n`); | ||
| for (const id of section.ids) { | ||
| const file = path.join(docsDir, `${id}.md`); | ||
| if (!fs.existsSync(file)) { | ||
| console.warn(`[llms-txt] sidebar lists "${id}" but ${file} does not exist; skipping`); | ||
| continue; | ||
| } | ||
| const page = readPage(file); | ||
| const route = page.slug === "/" ? "" : (page.slug || `/${id}`); | ||
| const url = `${site}${route || "/"}`; | ||
| const note = page.description ? `: ${page.description}` : ""; | ||
| index.push(` - [${page.title}](${url})${note}`); | ||
| const body = cleanBody(page.body, docsDir).trim(); | ||
| full.push(`# ${page.title}\n\nSource: ${url}\n\n${body}\n`); | ||
| // Raw markdown sits beside its HTML route; the front page becomes /index.md. | ||
| const clean = body.startsWith("# ") | ||
| ? `${body}\n` | ||
| : `# ${page.title}\n\n${page.description ? page.description + "\n\n" : ""}${body}\n`; | ||
| const target = path.join(outDir, `${route === "" ? "index" : route.slice(1)}.md`); | ||
| fs.mkdirSync(path.dirname(target), { recursive: true }); | ||
| fs.writeFileSync(target, clean); | ||
| if (route === "") fs.writeFileSync(path.join(outDir, `${id}.md`), clean); | ||
| } | ||
| } | ||
|
|
||
| const header = | ||
| "Append `.md` to any docs page URL below for its raw Markdown " + | ||
| `(e.g. \`${site}/configuring.md\`; the front page is \`${site}/index.md\`), ` + | ||
| `or fetch all current pages at \`${site}/llms-full.txt\`.\n\n` + | ||
| `# Juno Docs\n\n> ${siteConfig.title}: ${siteConfig.tagline}. ` + | ||
| `Documentation for Juno ${version}, a Starknet full node written in Go.\n`; | ||
|
|
||
| fs.writeFileSync(path.join(outDir, "llms.txt"), header + "\n" + index.join("\n") + "\n"); | ||
| fs.writeFileSync(path.join(outDir, "llms-full.txt"), full.join("\n---\n\n")); | ||
| console.log(`[llms-txt] wrote llms.txt, llms-full.txt and raw .md routes for ${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,4 @@ | ||
| User-agent: * | ||
| Allow: / | ||
|
|
||
| Sitemap: https://juno.nethermind.io/sitemap.xml |
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
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
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 |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| --- | ||
| title: GCP | ||
| description: "Run a Juno node on Google Cloud Platform." | ||
| --- | ||
|
|
||
| # Running Juno on GCP | ||
|
|
||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this for?