mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
docs(docs-infra): llms-full.txt (#61356)
This includes a basic script to generate the file from the list of markdown files `llms-list.md` PR Close #61356
This commit is contained in:
parent
aa4293871d
commit
74e39ea96a
4 changed files with 13236 additions and 1 deletions
|
|
@ -33,7 +33,13 @@
|
|||
"polyfills": [],
|
||||
"tsConfig": "tsconfig.app.json",
|
||||
"inlineStyleLanguage": "scss",
|
||||
"assets": ["src/favicon.ico", "src/robots.txt", "src/assets", "src/llms.txt"],
|
||||
"assets": [
|
||||
"src/favicon.ico",
|
||||
"src/robots.txt",
|
||||
"src/assets",
|
||||
"src/llms.txt",
|
||||
"src/llms-full.txt"
|
||||
],
|
||||
"styles": ["@angular/docs/styles/global-styles.scss", "./src/local-styles.scss"],
|
||||
"scripts": [],
|
||||
"webWorkerTsConfig": "tsconfig.worker.json",
|
||||
|
|
|
|||
107
adev/scripts/shared/llms-list.md
Normal file
107
adev/scripts/shared/llms-list.md
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
|
||||
## Table of contents
|
||||
|
||||
adev/src/content/introduction/what-is-angular.md
|
||||
adev/src/content/introduction/installation.md
|
||||
adev/src/content/best-practices/style-guide.md
|
||||
|
||||
## Components
|
||||
|
||||
adev/src/content/introduction/essentials/components.md
|
||||
adev/src/content/guide/components/selectors.md
|
||||
adev/src/content/guide/components/styling.md
|
||||
adev/src/content/guide/components/inputs.md
|
||||
adev/src/content/guide/components/outputs.md
|
||||
adev/src/content/guide/components/content-projection.md
|
||||
adev/src/content/guide/components/lifecycle.md
|
||||
|
||||
## Template guides
|
||||
|
||||
adev/src/content/introduction/essentials/templates.md
|
||||
adev/src/content/guide/templates/event-listeners.md
|
||||
adev/src/content/guide/templates/binding.md
|
||||
adev/src/content/guide/templates/control-flow.md
|
||||
adev/src/content/guide/templates/variables.md
|
||||
adev/src/content/guide/templates/defer.md
|
||||
adev/src/content/guide/templates/expression-syntax.md
|
||||
|
||||
## Directives
|
||||
|
||||
adev/src/content/guide/directives/attribute-directives.md
|
||||
adev/src/content/guide/directives/structural-directives.md
|
||||
adev/src/content/guide/directives/directive-composition-api.md
|
||||
adev/src/content/guide/image-optimization.md
|
||||
|
||||
## Signals
|
||||
|
||||
adev/src/content/introduction/essentials/signals.md
|
||||
adev/src/content/guide/signals/linked-signal.md
|
||||
adev/src/content/guide/signals/resource.md
|
||||
|
||||
## Dependency injection
|
||||
|
||||
adev/src/content/guide/di/dependency-injection.md
|
||||
adev/src/content/guide/di/creating-injectable-service.md
|
||||
adev/src/content/guide/di/dependency-injection-providers.md
|
||||
adev/src/content/guide/di/dependency-injection-context.md
|
||||
adev/src/content/guide/di/hierarchical-dependency-injection.md
|
||||
adev/src/content/guide/di/lightweight-injection-tokens.md
|
||||
|
||||
## Rxjs
|
||||
|
||||
adev/src/content/ecosystem/rxjs-interop/signals-interop.md
|
||||
adev/src/content/ecosystem/rxjs-interop/output-interop.md
|
||||
|
||||
## Http
|
||||
|
||||
adev/src/content/guide/http/setup.md
|
||||
adev/src/content/guide/http/making-requests.md
|
||||
adev/src/content/guide/http/interceptors.md
|
||||
adev/src/content/guide/http/testing.md
|
||||
|
||||
## Forms
|
||||
|
||||
adev/src/content/guide/forms/reactive-forms.md
|
||||
adev/src/content/guide/forms/typed-forms.md
|
||||
adev/src/content/guide/forms/template-driven-forms.md
|
||||
adev/src/content/guide/forms/form-validation.md
|
||||
adev/src/content/guide/forms/dynamic-forms.md
|
||||
|
||||
## Routing
|
||||
|
||||
adev/src/content/guide/routing/common-router-tasks.md
|
||||
adev/src/content/guide/routing/router-tutorial.md
|
||||
adev/src/content/guide/routing/routing-with-urlmatcher.md
|
||||
|
||||
## SSR
|
||||
|
||||
adev/src/content/guide/ssr.md
|
||||
adev/src/content/guide/hydration.md
|
||||
adev/src/content/guide/incremental-hydration.md
|
||||
|
||||
## Testing
|
||||
|
||||
adev/src/content/guide/testing/overview.md
|
||||
adev/src/content/guide/testing/code-coverage.md
|
||||
adev/src/content/guide/testing/services.md
|
||||
adev/src/content/guide/testing/components-basics.md
|
||||
adev/src/content/guide/testing/components-scenarios.md
|
||||
adev/src/content/guide/testing/debugging.md
|
||||
adev/src/content/guide/testing/utility-apis.md
|
||||
adev/src/content/guide/testing/component-harnesses-overview.md
|
||||
adev/src/content/guide/testing/using-component-harnesses.md
|
||||
adev/src/content/guide/testing/creating-component-harnesses.md
|
||||
|
||||
## Animations
|
||||
|
||||
adev/src/content/guide/animations/css.md
|
||||
adev/src/content/guide/animations/route-animations.md
|
||||
adev/src/content/guide/animations/migration.md
|
||||
|
||||
## Others
|
||||
|
||||
adev/src/content/guide/zoneless.md
|
||||
adev/src/content/reference/roadmap.md
|
||||
adev/src/content/best-practices/update.md
|
||||
adev/src/content/guide/http/security.md
|
||||
adev/src/content/guide/i18n/overview.md
|
||||
140
adev/scripts/shared/llms.mjs
Normal file
140
adev/scripts/shared/llms.mjs
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
/**
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
// The purpose of this script is to generate a llms-full.txt
|
||||
// Run with `node adev/scripts/shared/llms.mjs` to generate llms-full.txt from the list in llms-list.md
|
||||
|
||||
//tslint:disable:no-console
|
||||
import fs from 'fs/promises';
|
||||
import path from 'path';
|
||||
|
||||
const INPUT_MD_FILENAME = 'adev/scripts/shared/llms-list.md';
|
||||
const OUTPUT_FILENAME = 'adev/src/llms-full.txt';
|
||||
|
||||
function postProcessOutputContent(content) {
|
||||
// Helper to map custom languages to standard Markdown languages
|
||||
const mapLanguage = (lang) => {
|
||||
if (!lang) return ''; // For code blocks without a specified language
|
||||
const lowerLang = lang.trim().toLowerCase();
|
||||
if (lowerLang === 'angular-ts') return 'typescript';
|
||||
if (lowerLang === 'angular-html') return 'html';
|
||||
return lowerLang; // Use as is for other languages like shell, etc.
|
||||
};
|
||||
|
||||
// Process docs-code-multifile and their inner docs-code elements
|
||||
content = content.replace(
|
||||
/<docs-code-multifile>([\s\S]*?)<\/docs-code-multifile>/gs,
|
||||
(match, innerHTML) => {
|
||||
let multifileResult = '';
|
||||
// Regex for <docs-code> within <docs-code-multifile>, expecting 'header' and optional 'language'
|
||||
const codeRegex =
|
||||
/<docs-code\s+header="([^"]+)"(?:\s+language="([^"]*)")?[^>]*>([\s\S]*?)<\/docs-code>/gs;
|
||||
let codeMatch;
|
||||
while ((codeMatch = codeRegex.exec(innerHTML)) !== null) {
|
||||
const header = codeMatch[1].trim();
|
||||
const langAttr = codeMatch[2]; // Language attribute might be undefined
|
||||
const language = mapLanguage(langAttr);
|
||||
let code = codeMatch[3].trim();
|
||||
// Note: If code content includes HTML entities like <, they would need unescaping here.
|
||||
// e.g., code = code.replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&');
|
||||
multifileResult += `\`\`\`${language}\n// ${header}\n${code}\n\`\`\`\n`;
|
||||
}
|
||||
return multifileResult;
|
||||
},
|
||||
);
|
||||
|
||||
// Process standalone docs-code elements
|
||||
content = content.replace(
|
||||
/<docs-code(?:\s+language="([^"]*)")?[^>]*>([\s\S]*?)<\/docs-code>/gs,
|
||||
(match, langAttr, codeContent) => {
|
||||
const language = mapLanguage(langAttr);
|
||||
let code = codeContent.trim();
|
||||
// Note: HTML entity unescaping might be needed here as well.
|
||||
return `\`\`\`${language}\n${code}\n\`\`\`\n`;
|
||||
},
|
||||
);
|
||||
|
||||
// Process code block languages
|
||||
content = content.replace(/```([\w-]+)\s*/gs, (match, lang, code) => {
|
||||
const mappedLang = mapLanguage(lang); // lang can be undefined if no language was specified
|
||||
return `\`\`\`${mappedLang}\n`;
|
||||
});
|
||||
|
||||
// Remove docs-decorative-header elements
|
||||
content = content.replace(
|
||||
/<docs-decorative-header[^>]*>[\s\S]*?<\/docs-decorative-header>/gs,
|
||||
'',
|
||||
);
|
||||
|
||||
// Remove docs-card elements
|
||||
content = content.replace(/<docs-card\b[^>]*>[\s\S]*?<\/docs-card>/gi, '');
|
||||
|
||||
// remove docs-pill-row elements
|
||||
content = content.replace(/<docs-pill-row\b[^>]*>[\s\S]*?<\/docs-pill-row>/gi, '');
|
||||
|
||||
// Remove docs-callout tags, keeping the content within them
|
||||
content = content.replace(/<docs-callout[^>]*>([\s\S]*?)<\/docs-callout>/gis, '$1');
|
||||
|
||||
// Remove docs-card-container tags, keeping the content within them
|
||||
content = content.replace(/<docs-card-container>/g, '');
|
||||
content = content.replace(/<\/docs-card-container>/g, '');
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const inputFilePath = path.resolve(process.cwd(), INPUT_MD_FILENAME);
|
||||
const baseDirForIncludes = path.dirname(inputFilePath);
|
||||
|
||||
console.log(`Starting processing of: ${inputFilePath}`);
|
||||
|
||||
let mainFileContent;
|
||||
try {
|
||||
mainFileContent = await fs.readFile(inputFilePath, 'utf-8');
|
||||
} catch (error) {
|
||||
console.error(`Error: Failed to read input file "${inputFilePath}".`);
|
||||
console.error(error.message);
|
||||
process.exit(1); // Exit with error code
|
||||
}
|
||||
|
||||
let processedContent = mainFileContent;
|
||||
const matches = [...mainFileContent.matchAll(/(.*\.md)/g)];
|
||||
|
||||
console.log(`Found ${matches.length} files`);
|
||||
|
||||
let resultString = '';
|
||||
|
||||
for (const match of matches) {
|
||||
const filePath = match[0];
|
||||
const absolutePathToIncludeFile = path.resolve(filePath);
|
||||
|
||||
try {
|
||||
console.log(` Including content from: ${absolutePathToIncludeFile}`);
|
||||
const includedFileContent = await fs.readFile(absolutePathToIncludeFile, 'utf-8');
|
||||
const processedFile = postProcessOutputContent(includedFileContent);
|
||||
resultString += processedFile; // Append the content of the included file
|
||||
} catch (fileReadError) {
|
||||
console.warn(` Warning: Could not read file "${absolutePathToIncludeFile}"`);
|
||||
}
|
||||
}
|
||||
|
||||
// Basic cleanup of blank lines
|
||||
processedContent = resultString.replace(/(?:\s*\n){3,}/g, '\n');
|
||||
|
||||
const outputFilePath = path.resolve(process.cwd(), OUTPUT_FILENAME);
|
||||
try {
|
||||
await fs.writeFile(outputFilePath, processedContent, 'utf-8');
|
||||
console.log(`Successfully generated combined file: ${outputFilePath}`);
|
||||
} catch (error) {
|
||||
console.error(`Error: Failed to write output file "${outputFilePath}".`);
|
||||
console.error(error.message);
|
||||
process.exit(1); // Exit with error code
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
12982
adev/src/llms-full.txt
Normal file
12982
adev/src/llms-full.txt
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue