Skip to content

Commit 1d90195

Browse files
committed
simplify
1 parent 7b13b03 commit 1d90195

File tree

5 files changed

+6
-70
lines changed

5 files changed

+6
-70
lines changed

package-lock.json

Lines changed: 1 addition & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/generators/mdx/constants.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ export const STABILITY_LEVELS = [
22
'danger', // Deprecated
33
'warning', // Experimental
44
'success', // Stable
5-
'info', //
5+
'info', // Legacy
66
];

src/generators/mdx/index.mjs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { mdxJsxToMarkdown } from 'mdast-util-mdx-jsx';
1111
* @type {GeneratorMetadata<Input, string>}
1212
*/
1313
export default {
14-
name: 'llms-txt',
14+
name: 'mdx',
1515
version: '1.0.0',
1616
description: 'Generates a MDX file from the input AST',
1717
dependsOn: 'ast',
@@ -23,16 +23,8 @@ export default {
2323
* @returns {Promise<string[]>} Array of generated content
2424
*/
2525
async generate(entries) {
26-
// Pre-process all data once
27-
const headNodes = entries
28-
.filter(node => node.heading.depth === 1)
29-
.sort((a, b) => a.heading.data.name.localeCompare(b.heading.data.name));
30-
31-
const modules = groupNodesByModule(entries);
32-
33-
// Process nodes in parallel for better performance
3426
const results = await Promise.all(
35-
headNodes.map(node => buildContent(headNodes, modules.get(node.api)))
27+
Array.from(groupNodesByModule(entries).values()).map(buildContent)
3628
);
3729

3830
console.log(toMarkdown(results[0], { extensions: [mdxJsxToMarkdown()] }));

src/generators/mdx/utils/buildContent.mjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const visitStabilityNode = (node, index, parent) => {
1919
createTree('paragraph', {
2020
children: [
2121
createJSXElement('AlertBox', {
22-
inline: true,
2322
children: node.data.description,
2423
level: STABILITY_LEVELS[node.data.index],
2524
title: node.data.index,
@@ -43,11 +42,10 @@ const processContent = content => {
4342

4443
/**
4544
* Transforms API metadata entries into markdown content with special handling for stability nodes
46-
* @param {any} _ Unused parameter
4745
* @param {Array<ApiDocMetadataEntry>} metadataEntries Entries to transform
4846
* @returns {import('unist').Node} Root node with processed content
4947
*/
50-
export default (_, metadataEntries) => {
48+
export default metadataEntries => {
5149
const rootNode = createTree(
5250
'root',
5351
metadataEntries.map(entry => processContent(entry.content))

src/generators/mdx/utils/mdxUtilities.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { u as createTree } from 'unist-builder';
1515
*/
1616
export const createJSXElement = (
1717
name,
18-
{ inline = false, children = [], ...attributes } = {}
18+
{ inline = true, children = [], ...attributes } = {}
1919
) => {
2020
const processedChildren =
2121
typeof children === 'string'

0 commit comments

Comments
 (0)