feat(c-apidoc-parser): Add description parsing
+fix brief description parsing
This commit is contained in:
@@ -124,6 +124,24 @@ export class CApiDocParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Parses a Doxygen description structure into Markdown-formatted string.
|
||||||
|
private parseDescriptionSection(description: any): string {
|
||||||
|
let md = "";
|
||||||
|
const items = ensureArray(description);
|
||||||
|
console.log(JSON.stringify(items, null, 2));
|
||||||
|
|
||||||
|
for (const item of items) {
|
||||||
|
// Handle plain text or detailedDescription
|
||||||
|
if (typeof item === "string") {
|
||||||
|
md += this.escapeMarkdown(item) + "\n\n";
|
||||||
|
} else if (item["#text"]) {
|
||||||
|
md += this.escapeMarkdown(this.extractText(item["#text"])) + "\n\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return md.trim();
|
||||||
|
}
|
||||||
|
|
||||||
private parseDocFile(compound: any): DocFile {
|
private parseDocFile(compound: any): DocFile {
|
||||||
const functions: FunctionDoc[] = [];
|
const functions: FunctionDoc[] = [];
|
||||||
const typedefs: TypeDefDoc[] = [];
|
const typedefs: TypeDefDoc[] = [];
|
||||||
@@ -136,8 +154,9 @@ export class CApiDocParser {
|
|||||||
const parsedFile = this.xmlParser.parse(file);
|
const parsedFile = this.xmlParser.parse(file);
|
||||||
const compounddef = parsedFile?.doxygen?.compounddef;
|
const compounddef = parsedFile?.doxygen?.compounddef;
|
||||||
const compoundName = compounddef?.compoundname;
|
const compoundName = compounddef?.compoundname;
|
||||||
const briefDescription = compounddef?.briefdescription || "";
|
const briefDescription = compounddef?.briefdescription?.para || "";
|
||||||
const detailedDescription = compounddef?.detaileddescription?.para || "";
|
const detailedDescription = this.parseDescriptionSection(compounddef?.detaileddescription?.para || []);
|
||||||
|
|
||||||
const location = compounddef?.location?.["@_file"] || "";
|
const location = compounddef?.location?.["@_file"] || "";
|
||||||
const sectionDefs = ensureArray(compounddef?.sectiondef);
|
const sectionDefs = ensureArray(compounddef?.sectiondef);
|
||||||
for (const sectionDef of sectionDefs) {
|
for (const sectionDef of sectionDefs) {
|
||||||
|
|||||||
Reference in New Issue
Block a user