Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ commands:
command: pnpm -F "./packages/*" add react-compiler-runtime
- run:
name: Build with compiler
command: pnpm -F "./packages/*" build --enableReactCompiler
command: pnpm release:build --enableReactCompiler
environment:
MUI_REACT_COMPILER_MODE: 'infer'

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ size-snapshot.json
# Remove if you want to pregenerate the docs md files
docs/public/llms.txt
docs/public/llms-full.txt
docs/public/index.md
docs/public/react
packages/react/published-docs/
.cursor/rules/nx-rules.mdc
.github/instructions/nx.instructions.md

Expand Down
15 changes: 13 additions & 2 deletions docs/scripts/generateLlmTxt/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ function incrementHeaders(increment = 1) {
};
}

function inlineCodeHtmlTags(text) {
return text.replace(/<\/?[a-zA-Z][^>]*>/g, '`$&`');
}

function githubSlugify(text) {
return text
.trim()
Expand Down Expand Up @@ -216,7 +220,11 @@ async function generateLlmsTxt() {
// Page rendering functions - focused only on their unique logic
const renderPageAsLink = (page) => {
const resolvedUrl = resolveUrl(page.mdUrlPath, BASE_URL);
return [`- [${page.title}](${resolvedUrl}): ${page.description}`];
return [`- [${page.title}](${resolvedUrl}): ${inlineCodeHtmlTags(page.description)}`];
};
const renderPageAsRelativeLink = (page) => {
const relativeUrl = `.${page.mdUrlPath}`;
return [`- [${page.title}](${relativeUrl}): ${inlineCodeHtmlTags(page.description)}`];
};
const renderPageAsInline = async (page) => {
const content = await prepareForInlineMarkdown(page.fullMarkdown, 2, metadataByUrl);
Expand Down Expand Up @@ -300,9 +308,12 @@ async function generateLlmsTxt() {
await Promise.all([
createFile('llms.txt', renderPageAsLink),
createFile('llms-full.txt', renderPageAsInline),
createFile('index.md', renderPageAsRelativeLink),
]);

console.log(`Successfully generated ${totalFiles} markdown files, llms.txt, and llms-full.txt`);
console.log(
`Successfully generated ${totalFiles} markdown files, llms.txt, llms-full.txt, and index.md`,
);
} catch (error) {
console.error('Error generating llms.txt:', error);
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"deduplicate": "pnpm dedupe",
"build": "lerna run --no-private build",
"release:version": "lerna version --no-changelog --no-push --no-git-tag-version --no-private",
"release:build": "lerna run --concurrency 8 --no-private build --skip-nx-cache",
"release:build": "pnpm docs:generate-llms && lerna run --concurrency 8 --no-private build --skip-nx-cache --",
"release:changelog": "code-infra generate-changelog",
"release:changelog:docs": "FORMAT=docs code-infra generate-changelog",
"release:publish": "code-infra publish --github-release",
Expand Down
4 changes: 2 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@
},
"type": "commonjs",
"scripts": {
"prebuild": "rimraf --glob build build-tests \"*.tsbuildinfo\"",
"build": "code-infra build --ignore \"**/*.template.js\" --copy .npmignore",
"prebuild": "rimraf --glob build build-tests published-docs \"*.tsbuildinfo\" && node ./scripts/stagePublishedDocs.mjs",
"build": "code-infra build --ignore \"**/*.template.js\" --copy .npmignore --copy \"published-docs/**:docs\"",
"test:package": "publint --pack pnpm && attw --pack ./build --exclude-entrypoints package.json --exclude-entrypoints esm --exclude-entrypoints cjs",
"release": "pnpm build && pnpm publish",
"test": "cross-env VITEST_ENV=jsdom vitest",
Expand Down
24 changes: 24 additions & 0 deletions packages/react/scripts/stagePublishedDocs.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* eslint-disable no-console */
import fs from 'node:fs/promises';
import path from 'node:path';

const PACKAGE_ROOT = path.resolve(import.meta.dirname, '..');
const DOCS_PUBLIC = path.resolve(PACKAGE_ROOT, '../../docs/public');
const STAGE_DIR = path.join(PACKAGE_ROOT, 'published-docs');

await fs.rm(STAGE_DIR, { recursive: true, force: true });

let count = 0;
for await (const entry of fs.glob('**/*.md', { cwd: DOCS_PUBLIC })) {
const src = path.join(DOCS_PUBLIC, entry);
const dst = path.join(STAGE_DIR, entry);
await fs.mkdir(path.dirname(dst), { recursive: true });
await fs.copyFile(src, dst);
count += 1;
}

if (count === 0) {
throw new Error('No markdown files found in docs/public/. Run "pnpm docs:generate-llms" first.');
}

console.log(`[stage-docs] Staged ${count} markdown files into published-docs/.`);
Loading