@qualcomm-ui/mdx-vite 2.15.0 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-knowledge/generator/doc-props-plugin.d.ts +1 -1
- package/dist/ai-knowledge/generator/doc-props-plugin.d.ts.map +1 -1
- package/dist/ai-knowledge/generator/section-extractor.d.ts +2 -3
- package/dist/ai-knowledge/generator/section-extractor.d.ts.map +1 -1
- package/dist/ai-knowledge/generator/section.types.d.ts +20 -7
- package/dist/ai-knowledge/generator/section.types.d.ts.map +1 -1
- package/dist/cli.js +69 -59
- package/dist/cli.js.map +3 -3
- package/dist/docs-plugin/remark/remark-extract-meta.d.ts +15 -3
- package/dist/docs-plugin/remark/remark-extract-meta.d.ts.map +1 -1
- package/dist/index.js +69 -59
- package/dist/index.js.map +3 -3
- package/dist/tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -4,14 +4,26 @@ export type MetadataValue = Record<string, string | string[]>;
|
|
|
4
4
|
/**
|
|
5
5
|
* Extracts metadata from MDX files and removes it from the MDX content.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* Supports two formats:
|
|
8
|
+
*
|
|
9
|
+
* @example `::: meta` - YAML-like key-value pairs
|
|
8
10
|
* ```
|
|
9
11
|
* ::: meta
|
|
10
12
|
* component: NumberInput
|
|
11
|
-
* keywords: [forms, input, data entry]
|
|
12
13
|
* :::
|
|
13
14
|
*
|
|
14
|
-
* result: {
|
|
15
|
+
* result: {component: "NumberInput"}
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @example `::: terms` - flat list of terms
|
|
19
|
+
* ```
|
|
20
|
+
* ::: terms
|
|
21
|
+
* forms
|
|
22
|
+
* input
|
|
23
|
+
* data entry
|
|
24
|
+
* :::
|
|
25
|
+
*
|
|
26
|
+
* result: {terms: ["forms", "input", "data entry"]}
|
|
15
27
|
* ```
|
|
16
28
|
*/
|
|
17
29
|
export declare const remarkExtractMeta: Plugin<[MetadataValue], Root>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remark-extract-meta.d.ts","sourceRoot":"","sources":["../../../src/docs-plugin/remark/remark-extract-meta.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAS,IAAI,EAAC,MAAM,OAAO,CAAA;AACvC,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,SAAS,CAAA;AAGnC,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"remark-extract-meta.d.ts","sourceRoot":"","sources":["../../../src/docs-plugin/remark/remark-extract-meta.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAS,IAAI,EAAC,MAAM,OAAO,CAAA;AACvC,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,SAAS,CAAA;AAGnC,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAA;AA4D7D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,CAAC,aAAa,CAAC,EAAE,IAAI,CAgG3D,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -5343,6 +5343,9 @@ function parseMetaContent(content) {
|
|
|
5343
5343
|
}
|
|
5344
5344
|
return result;
|
|
5345
5345
|
}
|
|
5346
|
+
function parseTermsContent(content) {
|
|
5347
|
+
return content.split("\n").map((line) => line.trim()).filter((line) => line && line !== ":::");
|
|
5348
|
+
}
|
|
5346
5349
|
var remarkExtractMeta = (metadata = {}) => {
|
|
5347
5350
|
return (tree) => {
|
|
5348
5351
|
const nodesToRemove = [];
|
|
@@ -5355,16 +5358,27 @@ var remarkExtractMeta = (metadata = {}) => {
|
|
|
5355
5358
|
return;
|
|
5356
5359
|
}
|
|
5357
5360
|
const text = firstChild.value;
|
|
5358
|
-
const
|
|
5359
|
-
|
|
5361
|
+
const metaMatch = text.match(/^:::\s*meta\s*/);
|
|
5362
|
+
const termsMatch = text.match(/^:::\s*terms\s*/);
|
|
5363
|
+
if (!metaMatch && !termsMatch) {
|
|
5360
5364
|
return;
|
|
5361
5365
|
}
|
|
5366
|
+
const openMatch = metaMatch || termsMatch;
|
|
5367
|
+
const isTermsBlock = !!termsMatch;
|
|
5362
5368
|
if (text.includes(":::") && text.lastIndexOf(":::") > openMatch[0].length) {
|
|
5363
5369
|
const afterOpen = text.slice(openMatch[0].length);
|
|
5364
5370
|
const closeIndex = afterOpen.lastIndexOf(":::");
|
|
5365
5371
|
const content = afterOpen.slice(0, closeIndex);
|
|
5366
|
-
|
|
5367
|
-
|
|
5372
|
+
if (isTermsBlock) {
|
|
5373
|
+
const terms = parseTermsContent(content);
|
|
5374
|
+
if (terms.length > 0) {
|
|
5375
|
+
const existing = metadata.terms;
|
|
5376
|
+
metadata.terms = Array.isArray(existing) ? [...existing, ...terms] : terms;
|
|
5377
|
+
}
|
|
5378
|
+
} else {
|
|
5379
|
+
const parsed = parseMetaContent(content);
|
|
5380
|
+
Object.assign(metadata, parsed);
|
|
5381
|
+
}
|
|
5368
5382
|
nodesToRemove.push({ index, parent });
|
|
5369
5383
|
return SKIP;
|
|
5370
5384
|
}
|
|
@@ -5379,8 +5393,16 @@ var remarkExtractMeta = (metadata = {}) => {
|
|
|
5379
5393
|
const closeIndexFull = afterOpenFull.lastIndexOf(":::");
|
|
5380
5394
|
if (closeIndexFull !== -1) {
|
|
5381
5395
|
const content = afterOpenFull.slice(0, closeIndexFull);
|
|
5382
|
-
|
|
5383
|
-
|
|
5396
|
+
if (isTermsBlock) {
|
|
5397
|
+
const terms = parseTermsContent(content);
|
|
5398
|
+
if (terms.length > 0) {
|
|
5399
|
+
const existing = metadata.terms;
|
|
5400
|
+
metadata.terms = Array.isArray(existing) ? [...existing, ...terms] : terms;
|
|
5401
|
+
}
|
|
5402
|
+
} else {
|
|
5403
|
+
const parsed = parseMetaContent(content);
|
|
5404
|
+
Object.assign(metadata, parsed);
|
|
5405
|
+
}
|
|
5384
5406
|
nodesToRemove.push({ index, parent });
|
|
5385
5407
|
return SKIP;
|
|
5386
5408
|
}
|
|
@@ -5791,7 +5813,7 @@ ${tagContent.trim()}
|
|
|
5791
5813
|
* Creates a remark plugin that replaces TypeDocProps JSX elements with
|
|
5792
5814
|
* Markdown tables containing component prop documentation.
|
|
5793
5815
|
*/
|
|
5794
|
-
|
|
5816
|
+
propsToMarkdownList() {
|
|
5795
5817
|
return () => (tree, _file, done) => {
|
|
5796
5818
|
visit7(
|
|
5797
5819
|
tree,
|
|
@@ -5830,15 +5852,18 @@ ${tagContent.trim()}
|
|
|
5830
5852
|
}
|
|
5831
5853
|
return;
|
|
5832
5854
|
}
|
|
5833
|
-
const
|
|
5855
|
+
const propTypes = this.extractProps(
|
|
5856
|
+
componentProps,
|
|
5857
|
+
Boolean(isPartial)
|
|
5858
|
+
);
|
|
5834
5859
|
if (getConfig().verbose) {
|
|
5835
5860
|
console.log(
|
|
5836
5861
|
` Replaced TypeDocProps ${propsName} with API documentation`
|
|
5837
5862
|
);
|
|
5838
5863
|
}
|
|
5839
|
-
const regularProps =
|
|
5840
|
-
const inputs =
|
|
5841
|
-
const outputs =
|
|
5864
|
+
const regularProps = propTypes.filter((p) => p.propType === void 0);
|
|
5865
|
+
const inputs = propTypes.filter((p) => p.propType === "input");
|
|
5866
|
+
const outputs = propTypes.filter((p) => p.propType === "output");
|
|
5842
5867
|
const sections = [];
|
|
5843
5868
|
if (regularProps.length > 0) {
|
|
5844
5869
|
sections.push(propsToDefinitionList(regularProps));
|
|
@@ -5860,9 +5885,8 @@ ${propsToDefinitionList(outputs)}`);
|
|
|
5860
5885
|
}
|
|
5861
5886
|
return;
|
|
5862
5887
|
}
|
|
5863
|
-
const propNames = propsDoc.map((p) => p.name);
|
|
5864
5888
|
Object.assign(node, {
|
|
5865
|
-
data: { typeDocProps: { name: propsName, props:
|
|
5889
|
+
data: { typeDocProps: { name: propsName, props: propTypes } },
|
|
5866
5890
|
lang: null,
|
|
5867
5891
|
meta: null,
|
|
5868
5892
|
type: "code",
|
|
@@ -6063,19 +6087,19 @@ var SectionExtractor = class {
|
|
|
6063
6087
|
return text.trim();
|
|
6064
6088
|
}
|
|
6065
6089
|
buildSectionEntry(section, pageInfo) {
|
|
6066
|
-
const {
|
|
6090
|
+
const { nodes, terms } = this.extractTerms(section.nodes);
|
|
6067
6091
|
if (nodes.length === 0) {
|
|
6068
6092
|
return null;
|
|
6069
6093
|
}
|
|
6070
6094
|
const contentNodes = [];
|
|
6071
6095
|
const codeExamples = [];
|
|
6096
|
+
const sectionTypes = [];
|
|
6072
6097
|
for (const node of nodes) {
|
|
6073
6098
|
if (node.type === "code") {
|
|
6074
6099
|
const codeNode = node;
|
|
6075
6100
|
if (codeNode.data?.typeDocProps) {
|
|
6076
6101
|
const { name, props } = codeNode.data.typeDocProps;
|
|
6077
|
-
|
|
6078
|
-
metadata.type = name;
|
|
6102
|
+
sectionTypes.push({ props, type: name });
|
|
6079
6103
|
}
|
|
6080
6104
|
codeExamples.push({
|
|
6081
6105
|
code: codeNode.value,
|
|
@@ -6091,71 +6115,57 @@ var SectionExtractor = class {
|
|
|
6091
6115
|
const url = pageInfo.url ? `${pageInfo.url}#${this.generateAnchorId(section.headerPath.at(-1) ?? "")}` : void 0;
|
|
6092
6116
|
const hashData = {
|
|
6093
6117
|
headerPath: section.headerPath,
|
|
6094
|
-
metadata: Object.keys(metadata).length ? metadata : void 0,
|
|
6095
6118
|
pageFrontmatter: Object.keys(pageInfo.frontmatter).length ? pageInfo.frontmatter : void 0,
|
|
6096
6119
|
pageId: pageInfo.id,
|
|
6097
|
-
rawContent: rawContent.trim()
|
|
6120
|
+
rawContent: rawContent.trim(),
|
|
6121
|
+
terms: terms.length ? terms : void 0,
|
|
6122
|
+
types: sectionTypes.length ? sectionTypes : void 0,
|
|
6123
|
+
url
|
|
6098
6124
|
};
|
|
6099
|
-
const sectionHash = JSON.stringify(hashData);
|
|
6125
|
+
const sectionHash = computeMd5(JSON.stringify(hashData));
|
|
6100
6126
|
return {
|
|
6101
6127
|
...hashData,
|
|
6102
6128
|
codeExamples: codeExamples.length ? codeExamples : void 0,
|
|
6103
6129
|
content: content.trim(),
|
|
6104
6130
|
hash: sectionHash,
|
|
6105
|
-
sectionId
|
|
6106
|
-
url
|
|
6131
|
+
sectionId
|
|
6107
6132
|
};
|
|
6108
6133
|
}
|
|
6109
|
-
|
|
6110
|
-
const metadata = {};
|
|
6134
|
+
extractTerms(nodes) {
|
|
6111
6135
|
const filteredNodes = [];
|
|
6136
|
+
const terms = [];
|
|
6112
6137
|
for (const node of nodes) {
|
|
6113
6138
|
if (node.type === "paragraph") {
|
|
6114
|
-
const
|
|
6139
|
+
const children = node.children ?? [];
|
|
6140
|
+
const firstChild = children[0];
|
|
6115
6141
|
if (firstChild?.type === "text") {
|
|
6116
|
-
const
|
|
6117
|
-
const
|
|
6118
|
-
if (
|
|
6119
|
-
|
|
6120
|
-
|
|
6142
|
+
const firstText = firstChild.value;
|
|
6143
|
+
const termsMatch = firstText.match(/^:::\s*terms\s*/);
|
|
6144
|
+
if (termsMatch) {
|
|
6145
|
+
let fullText = firstText;
|
|
6146
|
+
for (let i = 1; i < children.length; i++) {
|
|
6147
|
+
const child = children[i];
|
|
6148
|
+
if (child.type === "text") {
|
|
6149
|
+
fullText += child.value;
|
|
6150
|
+
} else if (child.type === "softBreak") {
|
|
6151
|
+
fullText += "\n";
|
|
6152
|
+
}
|
|
6153
|
+
}
|
|
6154
|
+
const parsedTerms = this.parseTermsBlock(fullText);
|
|
6155
|
+
terms.push(...parsedTerms);
|
|
6121
6156
|
continue;
|
|
6122
6157
|
}
|
|
6123
6158
|
}
|
|
6124
6159
|
}
|
|
6125
6160
|
filteredNodes.push(node);
|
|
6126
6161
|
}
|
|
6127
|
-
return {
|
|
6162
|
+
return { nodes: filteredNodes, terms };
|
|
6128
6163
|
}
|
|
6129
|
-
|
|
6130
|
-
const
|
|
6131
|
-
const afterOpen = text.replace(/^:::\s*meta\s*/, "");
|
|
6164
|
+
parseTermsBlock(text) {
|
|
6165
|
+
const afterOpen = text.replace(/^:::\s*terms\s*/, "");
|
|
6132
6166
|
const closeIndex = afterOpen.lastIndexOf(":::");
|
|
6133
6167
|
const content = closeIndex !== -1 ? afterOpen.slice(0, closeIndex) : afterOpen;
|
|
6134
|
-
|
|
6135
|
-
for (const line of lines) {
|
|
6136
|
-
const trimmed = line.trim();
|
|
6137
|
-
if (!trimmed) {
|
|
6138
|
-
continue;
|
|
6139
|
-
}
|
|
6140
|
-
const colonIndex = trimmed.indexOf(":");
|
|
6141
|
-
if (colonIndex === -1) {
|
|
6142
|
-
continue;
|
|
6143
|
-
}
|
|
6144
|
-
const key = trimmed.slice(0, colonIndex).trim();
|
|
6145
|
-
const value = trimmed.slice(colonIndex + 1).trim();
|
|
6146
|
-
if (key && value) {
|
|
6147
|
-
metadata[key] = this.parseValue(value);
|
|
6148
|
-
}
|
|
6149
|
-
}
|
|
6150
|
-
return metadata;
|
|
6151
|
-
}
|
|
6152
|
-
parseValue(value) {
|
|
6153
|
-
const trimmed = value.trim();
|
|
6154
|
-
if (trimmed.startsWith("[") && trimmed.endsWith("]")) {
|
|
6155
|
-
const inner = trimmed.slice(1, -1);
|
|
6156
|
-
return inner.split(",").map((item) => item.trim()).filter(Boolean);
|
|
6157
|
-
}
|
|
6158
|
-
return trimmed;
|
|
6168
|
+
return content.split("\n").map((line) => line.trim()).filter((line) => line && line !== ":::");
|
|
6159
6169
|
}
|
|
6160
6170
|
/**
|
|
6161
6171
|
* Convert links to inline code. URLs are not relevant for text embeddings
|
|
@@ -6398,7 +6408,7 @@ var KnowledgeGenerator = class {
|
|
|
6398
6408
|
* into Markdown, resolving relative links, and cleaning up formatting.
|
|
6399
6409
|
*/
|
|
6400
6410
|
async processMdxContent(mdxContent, pageInfo, frontmatter) {
|
|
6401
|
-
const processor = unified5().use(remarkParse4).use(remarkMdx3).use(remarkFrontmatter2, ["yaml"]).use(this.propFormatter.
|
|
6411
|
+
const processor = unified5().use(remarkParse4).use(remarkMdx3).use(remarkFrontmatter2, ["yaml"]).use(this.propFormatter.propsToMarkdownList()).use(this.formatFrontmatterExpressions(frontmatter)).use(await formatThemeNodes()).use(formatDemos(pageInfo.demosFolder)).use(this.transformRelativeUrls(pageInfo.url));
|
|
6402
6412
|
this.applyPlugins(pageInfo, processor);
|
|
6403
6413
|
processor.use(remarkStringify4);
|
|
6404
6414
|
return await processor.run(processor.parse(mdxContent));
|