docs(docs-infra): generate llms-full.txt at build time (#61864)

PR Close #61864
This commit is contained in:
Matthieu Riegler
2025-06-10 20:45:44 -04:00
committed by Andrew Kushnir
parent 1a8297bf9e
commit 46d3bb56ea
29 changed files with 253 additions and 14065 deletions
+1
View File
@@ -15,6 +15,7 @@ exports_files([
])
APPLICATION_FILES = [
"//adev/src/context:llms_full",
"//adev/src/assets/images",
"//adev/src/assets/others",
"//adev/src/assets/previews",
+3 -7
View File
@@ -32,14 +32,10 @@
"src/favicon.ico",
"src/robots.txt",
"src/assets",
"src/llms.txt",
"src/llms-full.txt",
"src/context"
],
"styles": [
"@angular/docs/styles/global-styles.scss",
"./src/local-styles.scss"
"src/context",
"src/llms.txt"
],
"styles": ["@angular/docs/styles/global-styles.scss", "./src/local-styles.scss"],
"scripts": [],
"webWorkerTsConfig": "tsconfig.worker.json",
"optimization": {
+13
View File
@@ -1,3 +1,4 @@
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -8,3 +9,15 @@ generate_guides(
data = [],
visibility = ["//adev:__subpackages__"],
)
js_library(
name = "guide_files",
srcs = [
"//adev/src/content/best-practices:guide_files",
"//adev/src/content/ecosystem:guide_files",
"//adev/src/content/guide:guide_files",
"//adev/src/content/introduction:guide_files",
"//adev/src/content/reference:guide_files",
] + glob(["**/*.md"]),
visibility = ["//visibility:public"],
)
+1 -1
View File
@@ -31,6 +31,6 @@ Several editors, such as <a href="https://studio.firebase.google.com?utm_source=
* <a href="/llms.txt" target="_blank">llms.txt</a> - an index file providing links to key files and resources.
* <a href="/llms-full.txt" target="_blank">llms-full.txt</a> - a more robust compiled set of resources describing how Angular works and how to build Angular applications.
* <a href="/context/llm-files/llms-full.txt" target="_blank">llms-full.txt</a> - a more robust compiled set of resources describing how Angular works and how to build Angular applications.
Be sure [to check out the overview page](/ai) for more information on how to integrate AI into your Angular applications.
@@ -1,3 +1,4 @@
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -11,3 +12,9 @@ generate_guides(
],
visibility = ["//adev:__subpackages__"],
)
js_library(
name = "guide_files",
srcs = glob(["**/*.md"]),
visibility = ["//adev:__subpackages__"],
)
+7
View File
@@ -1,3 +1,4 @@
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -7,3 +8,9 @@ generate_guides(
]),
visibility = ["//adev:__subpackages__"],
)
js_library(
name = "guide_files",
srcs = ["//adev/src/content/ecosystem/rxjs-interop:guide_files"] + glob(["**/*.md"]),
visibility = ["//adev:__subpackages__"],
)
@@ -1,3 +1,4 @@
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -7,3 +8,9 @@ generate_guides(
]),
visibility = ["//adev:__subpackages__"],
)
js_library(
name = "guide_files",
srcs = glob(["**/*.md"]),
visibility = ["//adev:__subpackages__"],
)
+20
View File
@@ -1,3 +1,4 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -10,3 +11,22 @@ generate_guides(
],
visibility = ["//adev:__subpackages__"],
)
copy_to_bin(
name = "guide_files",
srcs = [
"//adev/src/content/guide/animations:guide_files",
"//adev/src/content/guide/components:guide_files",
"//adev/src/content/guide/di:guide_files",
"//adev/src/content/guide/directives:guide_files",
"//adev/src/content/guide/forms:guide_files",
"//adev/src/content/guide/http:guide_files",
"//adev/src/content/guide/i18n:guide_files",
"//adev/src/content/guide/performance:guide_files",
"//adev/src/content/guide/routing:guide_files",
"//adev/src/content/guide/signals:guide_files",
"//adev/src/content/guide/templates:guide_files",
"//adev/src/content/guide/testing:guide_files",
] + glob(["**/*.md"]),
visibility = ["//adev:__subpackages__"],
)
@@ -1,3 +1,4 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -10,3 +11,9 @@ generate_guides(
],
visibility = ["//adev:__subpackages__"],
)
copy_to_bin(
name = "guide_files",
srcs = glob(["**/*.md"]),
visibility = ["//adev:__subpackages__"],
)
@@ -1,3 +1,4 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -11,3 +12,9 @@ generate_guides(
mermaid_blocks = True,
visibility = ["//adev:__subpackages__"],
)
copy_to_bin(
name = "guide_files",
srcs = glob(["**/*.md"]),
visibility = ["//adev:__subpackages__"],
)
+7
View File
@@ -1,3 +1,4 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -12,3 +13,9 @@ generate_guides(
mermaid_blocks = True,
visibility = ["//adev:__subpackages__"],
)
copy_to_bin(
name = "guide_files",
srcs = glob(["**/*.md"]),
visibility = ["//adev:__subpackages__"],
)
@@ -1,3 +1,4 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -11,3 +12,9 @@ generate_guides(
],
visibility = ["//adev:__subpackages__"],
)
copy_to_bin(
name = "guide_files",
srcs = glob(["**/*.md"]),
visibility = ["//adev:__subpackages__"],
)
+7
View File
@@ -1,3 +1,4 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -12,3 +13,9 @@ generate_guides(
mermaid_blocks = True,
visibility = ["//adev:__subpackages__"],
)
copy_to_bin(
name = "guide_files",
srcs = glob(["**/*.md"]),
visibility = ["//adev:__subpackages__"],
)
+7
View File
@@ -1,3 +1,4 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -7,3 +8,9 @@ generate_guides(
]),
visibility = ["//adev:__subpackages__"],
)
copy_to_bin(
name = "guide_files",
srcs = glob(["**/*.md"]),
visibility = ["//adev:__subpackages__"],
)
+7
View File
@@ -1,3 +1,4 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -10,3 +11,9 @@ generate_guides(
],
visibility = ["//adev:__subpackages__"],
)
copy_to_bin(
name = "guide_files",
srcs = glob(["**/*.md"]),
visibility = ["//adev:__subpackages__"],
)
@@ -1,3 +1,4 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -9,3 +10,9 @@ generate_guides(
],
visibility = ["//adev:__subpackages__"],
)
copy_to_bin(
name = "guide_files",
srcs = glob(["**/*.md"]),
visibility = ["//adev:__subpackages__"],
)
@@ -1,3 +1,4 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -10,3 +11,9 @@ generate_guides(
],
visibility = ["//adev:__subpackages__"],
)
copy_to_bin(
name = "guide_files",
srcs = glob(["**/*.md"]),
visibility = ["//adev:__subpackages__"],
)
@@ -1,3 +1,4 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -11,3 +12,9 @@ generate_guides(
],
visibility = ["//adev:__subpackages__"],
)
copy_to_bin(
name = "guide_files",
srcs = glob(["**/*.md"]),
visibility = ["//adev:__subpackages__"],
)
@@ -1,3 +1,4 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -10,3 +11,9 @@ generate_guides(
],
visibility = ["//adev:__subpackages__"],
)
copy_to_bin(
name = "guide_files",
srcs = glob(["**/*.md"]),
visibility = ["//adev:__subpackages__"],
)
@@ -1,3 +1,4 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -10,3 +11,9 @@ generate_guides(
],
visibility = ["//adev:__subpackages__"],
)
copy_to_bin(
name = "guide_files",
srcs = glob(["**/*.md"]),
visibility = ["//adev:__subpackages__"],
)
@@ -1,3 +1,4 @@
load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -10,3 +11,9 @@ generate_guides(
],
visibility = ["//adev:__subpackages__"],
)
copy_to_bin(
name = "guide_files",
srcs = glob(["**/*.md"]),
visibility = ["//adev:__subpackages__"],
)
@@ -1,3 +1,4 @@
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -10,3 +11,9 @@ generate_guides(
],
visibility = ["//adev:__subpackages__"],
)
js_library(
name = "guide_files",
srcs = ["//adev/src/content/introduction/essentials:guide_files"] + glob(["**/*.md"]),
visibility = ["//adev:__subpackages__"],
)
@@ -1,3 +1,4 @@
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -18,3 +19,9 @@ generate_guides(
mermaid_blocks = True,
visibility = ["//adev:__subpackages__"],
)
js_library(
name = "guide_files",
srcs = glob(["**/*.md"]),
visibility = ["//adev:__subpackages__"],
)
+7
View File
@@ -1,3 +1,4 @@
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//adev/shared-docs:index.bzl", "generate_guides")
generate_guides(
@@ -10,3 +11,9 @@ generate_guides(
],
visibility = ["//adev:__subpackages__"],
)
js_library(
name = "guide_files",
srcs = glob(["**/*.md"]),
visibility = ["//adev:__subpackages__"],
)
+46
View File
@@ -1,3 +1,7 @@
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_run_binary")
load("//tools:defaults2.bzl", "ts_config", "ts_project")
package(default_visibility = ["//adev:__subpackages__"])
filegroup(
@@ -5,3 +9,45 @@ filegroup(
srcs = glob(["**"]),
visibility = ["//visibility:public"],
)
ts_config(
name = "tsconfig_build",
src = "tsconfig.json",
deps = ["//tools:tsconfig_build"],
)
filegroup(
name = "llms_src",
srcs = ["llms-list.md"],
visibility = ["//visibility:public"],
)
ts_project(
name = "llms_lib",
srcs = ["llms.mts"],
tsconfig = ":tsconfig_build",
deps = [":llms_src"],
)
js_binary(
name = "generate_llms_full",
data = [
"llms.mjs",
"llms-list.md",
":llms_lib_rjs",
"//adev/src/content:guide_files",
],
entry_point = ":llms.mjs",
)
js_run_binary(
name = "run_generate_llms_full",
outs = ["llms-full.txt"],
tool = ":generate_llms_full",
)
copy_to_directory(
name = "llms_full",
srcs = [":run_generate_llms_full"],
out = "llm-files",
)
@@ -10,15 +10,15 @@
// 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';
import {readFile, writeFile} from 'fs/promises';
import {resolve, dirname} from 'path';
const INPUT_MD_FILENAME = 'adev/scripts/shared/llms-list.md';
const OUTPUT_FILENAME = 'adev/src/llms-full.txt';
const INPUT_MD_FILENAME = 'adev/src/context/llms-list.md';
const OUTPUT_FILENAME = 'adev/src/context/llms-full.txt';
function postProcessOutputContent(content) {
function postProcessOutputContent(content: string) {
// Helper to map custom languages to standard Markdown languages
const mapLanguage = (lang) => {
const mapLanguage = (lang: string) => {
if (!lang) return ''; // For code blocks without a specified language
const lowerLang = lang.trim().toLowerCase();
if (lowerLang === 'angular-ts') return 'typescript';
@@ -88,21 +88,21 @@ function postProcessOutputContent(content) {
}
async function main() {
const inputFilePath = path.resolve(process.cwd(), INPUT_MD_FILENAME);
const baseDirForIncludes = path.dirname(inputFilePath);
const inputFilePath = resolve(process.cwd(), INPUT_MD_FILENAME);
const baseDirForIncludes = dirname(inputFilePath);
console.log(`Starting processing of: ${inputFilePath}`);
let mainFileContent;
let mainFileContent: string;
try {
mainFileContent = await fs.readFile(inputFilePath, 'utf-8');
} catch (error) {
mainFileContent = await readFile(inputFilePath, 'utf-8');
} catch (error: unknown) {
console.error(`Error: Failed to read input file "${inputFilePath}".`);
console.error(error.message);
console.error((error as Error).message);
process.exit(1); // Exit with error code
}
let processedContent = mainFileContent;
let processedContent: string = mainFileContent;
const matches = [...mainFileContent.matchAll(/(.*\.md)/g)];
console.log(`Found ${matches.length} files`);
@@ -111,28 +111,30 @@ async function main() {
for (const match of matches) {
const filePath = match[0];
const absolutePathToIncludeFile = path.resolve(filePath);
const absolutePathToIncludeFile = resolve(filePath);
try {
console.log(` Including content from: ${absolutePathToIncludeFile}`);
const includedFileContent = await fs.readFile(absolutePathToIncludeFile, 'utf-8');
const includedFileContent = await 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}"`);
} catch (fileReadError: any) {
console.warn(
` Warning: Could not read file "${absolutePathToIncludeFile}" - ${fileReadError.message}`,
);
}
}
// Basic cleanup of blank lines
processedContent = resultString.replace(/(?:\s*\n){3,}/g, '\n');
const outputFilePath = path.resolve(process.cwd(), OUTPUT_FILENAME);
const outputFilePath = resolve(process.cwd(), OUTPUT_FILENAME);
try {
await fs.writeFile(outputFilePath, processedContent, 'utf-8');
await writeFile(outputFilePath, processedContent, 'utf-8');
console.log(`Successfully generated combined file: ${outputFilePath}`);
} catch (error) {
} catch (error: unknown) {
console.error(`Error: Failed to write output file "${outputFilePath}".`);
console.error(error.message);
console.error((error as Error).message);
process.exit(1); // Exit with error code
}
}
+13
View File
@@ -0,0 +1,13 @@
{
"compilerOptions": {
"strict": true,
"skipLibCheck": true,
"declaration": true,
"sourceMap": true,
"module": "esnext",
"moduleResolution": "node",
"target": "esnext",
"types": ["node"],
"paths": {}
}
}
-14036
View File
File diff suppressed because it is too large Load Diff