Skip to content

Commit ebc4828

Browse files
committed
refactor: some changes
1 parent 419dcd6 commit ebc4828

File tree

5 files changed

+7
-45
lines changed

5 files changed

+7
-45
lines changed

src/generators/llms-txt/constants.mjs

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/generators/llms-txt/index.mjs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { readFile, writeFile } from 'node:fs/promises';
22
import { join } from 'node:path';
33

44
import { buildApiDocLink } from './utils/buildApiDocLink.mjs';
5-
import { ENTRY_IGNORE_LIST } from './constants.mjs';
6-
import { getIntroLinks } from './utils/getIntroLinks.mjs';
75

86
/**
97
* This generator generates a llms.txt file to provide information to LLMs at
@@ -36,24 +34,13 @@ export default {
3634
'utf-8'
3735
);
3836

39-
const introLinks = getIntroLinks().join('\n');
40-
4137
const apiDocsLinks = entries
42-
.filter(entry => {
43-
// Filter non top-level headings and ignored entries
44-
return (
45-
entry.heading.depth === 1 || ENTRY_IGNORE_LIST.includes(entry.path)
46-
);
47-
})
48-
.map(entry => {
49-
const link = buildApiDocLink(entry);
50-
return `- ${link}`;
51-
})
38+
// Filter non top-level headings
39+
.filter(entry => entry.heading.depth === 1)
40+
.map(entry => `- ${buildApiDocLink(entry)}`)
5241
.join('\n');
5342

54-
const filledTemplate = template
55-
.replace('__INTRODUCTION__', introLinks)
56-
.replace('__API_DOCS__', apiDocsLinks);
43+
const filledTemplate = template.replace('__API_DOCS__', apiDocsLinks);
5744

5845
if (output) {
5946
await writeFile(join(output, 'llms.txt'), filledTemplate);

src/generators/llms-txt/template.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
> Node.js is an open-source, cross-platform JavaScript runtime environment that executes JavaScript code outside a web browser. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient for building scalable network applications.
44

5-
## Introduction
6-
__INTRODUCTION__
5+
Below are the sections of the API documentation. Look out especially towards the links that point towards guidance/introductioon to the structure of this documentation.
76

87
## API Documentations
98
__API_DOCS__

src/generators/llms-txt/utils/getIntroLinks.mjs

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/types.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import type { SemVer } from 'semver';
44
import type { Data, Node, Parent, Position } from 'unist';
55

66
// Unist Node with typed Data, which allows better type inference
7-
type NodeWithData<T extends Node, J extends Data> = T & {
7+
interface NodeWithData<T extends Node, J extends Data> extends T {
88
data: J;
9-
};
9+
}
1010

1111
declare global {
1212
export interface StabilityIndexMetadataEntry {

0 commit comments

Comments
 (0)