Skip to content

Commit 10e94c8

Browse files
authored
Merge pull request #504 from takaebato/fix-tutorial-link
Replace tutorial section with handbook link in llms.txt
2 parents b1f9dd3 + 1f1fd54 commit 10e94c8

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

build/build-llms.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ const OUTPUT_DIR_NAME = 'llms-documents';
2626
const MAX_HEADING_DEPTH = 6;
2727

2828
const SECTION_LABELS = {
29-
en: {'option-parts': 'Option', 'option-gl-parts': 'Option GL', 'api-parts': 'API', 'tutorial-parts': 'Tutorial'},
30-
zh: {'option-parts': '配置项 (Option)', 'option-gl-parts': 'GL配置项 (Option GL)', 'api-parts': 'API', 'tutorial-parts': '教程 (Tutorial)'}
29+
en: {'option-parts': 'Option', 'option-gl-parts': 'Option GL', 'api-parts': 'API'},
30+
zh: {'option-parts': '配置项 (Option)', 'option-gl-parts': 'GL配置项 (Option GL)', 'api-parts': 'API'}
3131
};
3232

33+
// Tutorial parts are excluded because they have been replaced by the echarts-handbook.
34+
// A link to the handbook is included in the llms.txt instead.
35+
const EXCLUDED_PARTS = new Set(['tutorial-parts']);
36+
3337
const LLMS_TXT_HEADER = [
3438
'# Apache ECharts Documentation',
3539
'',
@@ -66,7 +70,7 @@ function htmlToMd(html) {
6670
* e.g. { "option.title.show": {type: "boolean", default: "true"} }
6771
*/
6872
function buildTypeMap(schemaJsonPath, docName) {
69-
if (docName === 'tutorial' || !fs.existsSync(schemaJsonPath)) return {};
73+
if (!fs.existsSync(schemaJsonPath)) return {};
7074
const schema = JSON.parse(fs.readFileSync(schemaJsonPath, 'utf-8'));
7175
const typeMap = {};
7276
traverse(schema, docName, (schemaPath, node) => {
@@ -304,7 +308,7 @@ function generateDocsForLang(lang) {
304308
cwd: docsDir,
305309
absolute: true,
306310
onlyDirectories: true
307-
});
311+
}).filter(dir => !EXCLUDED_PARTS.has(path.basename(dir)));
308312
const jsonFilesByDir = collectPartJsonFiles(partsDirs);
309313
const partKeysByDoc = buildPartKeysByDoc(partsDirs, jsonFilesByDir);
310314

@@ -348,7 +352,13 @@ function writeLlmsTxt(lang, files) {
348352
''
349353
]);
350354

351-
const content = [LLMS_TXT_HEADER, ...sections].join('\n').trimEnd() + '\n';
355+
const handbookSection = [
356+
'## Handbook', '',
357+
`- [ECharts Handbook](https://echarts.apache.org/handbook/${lang}/get-started)`,
358+
''
359+
];
360+
361+
const content = [LLMS_TXT_HEADER, ...sections, ...handbookSection].join('\n').trimEnd() + '\n';
352362
fs.writeFileSync(path.join(langDir, 'llms.txt'), content, 'utf-8');
353363
console.log(`Generated ${lang}/llms.txt`);
354364
}

0 commit comments

Comments
 (0)