feat(c-apidoc-parser): Add description parsing

+fix brief description parsing
This commit is contained in:
2025-09-30 10:44:16 +02:00
parent 882df6d408
commit 46dc6bc2fe

View File

@@ -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 {
const functions: FunctionDoc[] = [];
const typedefs: TypeDefDoc[] = [];
@@ -136,8 +154,9 @@ export class CApiDocParser {
const parsedFile = this.xmlParser.parse(file);
const compounddef = parsedFile?.doxygen?.compounddef;
const compoundName = compounddef?.compoundname;
const briefDescription = compounddef?.briefdescription || "";
const detailedDescription = compounddef?.detaileddescription?.para || "";
const briefDescription = compounddef?.briefdescription?.para || "";
const detailedDescription = this.parseDescriptionSection(compounddef?.detaileddescription?.para || []);
const location = compounddef?.location?.["@_file"] || "";
const sectionDefs = ensureArray(compounddef?.sectiondef);
for (const sectionDef of sectionDefs) {