@xpack/doxygen2docusaurus 2.1.0 → 2.2.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.
Files changed (121) hide show
  1. package/README.md +2 -1
  2. package/bin/doxygen2docusaurus.js +4 -4
  3. package/dist/docusaurus/renderers/conceptparts.d.ts +9 -0
  4. package/dist/docusaurus/renderers/conceptparts.d.ts.map +1 -0
  5. package/dist/docusaurus/renderers/conceptparts.js +21 -0
  6. package/dist/docusaurus/renderers/conceptparts.js.map +1 -0
  7. package/dist/docusaurus/renderers/renderers.d.ts.map +1 -1
  8. package/dist/docusaurus/renderers/renderers.js +11 -2
  9. package/dist/docusaurus/renderers/renderers.js.map +1 -1
  10. package/dist/docusaurus/view-model/concepts-vm.d.ts +1 -0
  11. package/dist/docusaurus/view-model/concepts-vm.d.ts.map +1 -1
  12. package/dist/docusaurus/view-model/concepts-vm.js +11 -3
  13. package/dist/docusaurus/view-model/concepts-vm.js.map +1 -1
  14. package/dist/docusaurus/view-model/namespaces-vm.d.ts +1 -0
  15. package/dist/docusaurus/view-model/namespaces-vm.d.ts.map +1 -1
  16. package/dist/docusaurus/view-model/namespaces-vm.js +8 -2
  17. package/dist/docusaurus/view-model/namespaces-vm.js.map +1 -1
  18. package/dist/docusaurus/view-model/pages-vm.d.ts.map +1 -1
  19. package/dist/docusaurus/view-model/pages-vm.js +39 -0
  20. package/dist/docusaurus/view-model/pages-vm.js.map +1 -1
  21. package/dist/doxygen/data-model/compounds/compounddef-dm.d.ts +2 -0
  22. package/dist/doxygen/data-model/compounds/compounddef-dm.d.ts.map +1 -1
  23. package/dist/doxygen/data-model/compounds/compounddef-dm.js +5 -0
  24. package/dist/doxygen/data-model/compounds/compounddef-dm.js.map +1 -1
  25. package/dist/doxygen/data-model/compounds/concepts-dm.d.ts +23 -0
  26. package/dist/doxygen/data-model/compounds/concepts-dm.d.ts.map +1 -0
  27. package/dist/doxygen/data-model/compounds/concepts-dm.js +94 -0
  28. package/dist/doxygen/data-model/compounds/concepts-dm.js.map +1 -0
  29. package/dist/doxygen/data-model/compounds/descriptiontype-dm.d.ts.map +1 -1
  30. package/dist/doxygen/data-model/compounds/descriptiontype-dm.js.map +1 -1
  31. package/dist/doxygen/data-model/compounds/memberdeftype-dm.d.ts.map +1 -1
  32. package/dist/doxygen/data-model/compounds/memberdeftype-dm.js.map +1 -1
  33. package/dist/doxygen/data-model/compounds/requirements-dm.d.ts +2 -0
  34. package/dist/doxygen/data-model/compounds/requirements-dm.d.ts.map +1 -0
  35. package/dist/doxygen/data-model/compounds/requirements-dm.js +2 -0
  36. package/dist/doxygen/data-model/compounds/requirements-dm.js.map +1 -0
  37. package/dist/doxygen/data-model/compounds/tableofcontentstype-dm.d.ts.map +1 -1
  38. package/dist/doxygen/data-model/compounds/tableofcontentstype-dm.js.map +1 -1
  39. package/dist/doxygen/data-model/data-model.d.ts.map +1 -1
  40. package/dist/doxygen/data-model/data-model.js +4 -3
  41. package/dist/doxygen/data-model/data-model.js.map +1 -1
  42. package/dist/index.d.ts +2 -1
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +2 -1
  45. package/dist/index.js.map +1 -1
  46. package/package.json +8 -5
  47. package/src/cli/main.ts +4 -4
  48. package/src/docusaurus/cli-options.ts +4 -4
  49. package/src/docusaurus/generator.ts +4 -4
  50. package/src/docusaurus/renderers/conceptparts.ts +119 -0
  51. package/src/docusaurus/renderers/descriptiontype.ts +4 -4
  52. package/src/docusaurus/renderers/docinternalstype.ts +4 -4
  53. package/src/docusaurus/renderers/doclisttype.ts +4 -4
  54. package/src/docusaurus/renderers/doctabletype.ts +4 -4
  55. package/src/docusaurus/renderers/doctitletype.ts +4 -4
  56. package/src/docusaurus/renderers/docvariablelisttype.ts +4 -4
  57. package/src/docusaurus/renderers/docxrefsecttype.ts +4 -4
  58. package/src/docusaurus/renderers/element-renderer-base.ts +4 -4
  59. package/src/docusaurus/renderers/inctype.ts +4 -4
  60. package/src/docusaurus/renderers/linkedtexttype.ts +4 -4
  61. package/src/docusaurus/renderers/listingtype.ts +4 -4
  62. package/src/docusaurus/renderers/paramtype.ts +4 -4
  63. package/src/docusaurus/renderers/referencetype.ts +4 -4
  64. package/src/docusaurus/renderers/reftexttype.ts +4 -4
  65. package/src/docusaurus/renderers/reftype.ts +4 -4
  66. package/src/docusaurus/renderers/renderers.ts +66 -10
  67. package/src/docusaurus/renderers/substringtype.ts +4 -4
  68. package/src/docusaurus/renderers/tableofcontentstype.ts +4 -4
  69. package/src/docusaurus/types.ts +4 -4
  70. package/src/docusaurus/utils.ts +4 -4
  71. package/src/docusaurus/view-model/classes-vm.ts +4 -4
  72. package/src/docusaurus/view-model/collection-base.ts +4 -4
  73. package/src/docusaurus/view-model/compound-base-vm.ts +4 -4
  74. package/src/docusaurus/view-model/concepts-vm.ts +37 -7
  75. package/src/docusaurus/view-model/description-anchors.ts +4 -4
  76. package/src/docusaurus/view-model/files-and-folders-vm.ts +4 -4
  77. package/src/docusaurus/view-model/groups-vm.ts +4 -4
  78. package/src/docusaurus/view-model/members-vm.ts +4 -4
  79. package/src/docusaurus/view-model/namespaces-vm.ts +25 -6
  80. package/src/docusaurus/view-model/options.ts +4 -4
  81. package/src/docusaurus/view-model/pages-vm.ts +53 -6
  82. package/src/docusaurus/view-model/tree-entries-vm.ts +4 -4
  83. package/src/docusaurus/view-model/view-model.ts +4 -4
  84. package/src/docusaurus/workspace.ts +4 -4
  85. package/src/doxygen/data-model/compounds/compounddef-dm.ts +78 -4
  86. package/src/doxygen/data-model/compounds/compoundreftype-dm.ts +4 -4
  87. package/src/doxygen/data-model/compounds/concepts-dm.ts +362 -0
  88. package/src/doxygen/data-model/compounds/descriptiontype-dm.ts +12 -5
  89. package/src/doxygen/data-model/compounds/docvarlistentrytype-dm.ts +4 -4
  90. package/src/doxygen/data-model/compounds/doxygentype-dm.ts +4 -4
  91. package/src/doxygen/data-model/compounds/enumvaluetype-dm.ts +4 -4
  92. package/src/doxygen/data-model/compounds/inctype-dm.ts +4 -4
  93. package/src/doxygen/data-model/compounds/linkedtexttype-dm.ts +4 -4
  94. package/src/doxygen/data-model/compounds/listofallmemberstype-dm.ts +4 -4
  95. package/src/doxygen/data-model/compounds/locationtype-dm.ts +4 -4
  96. package/src/doxygen/data-model/compounds/memberdeftype-dm.ts +11 -4
  97. package/src/doxygen/data-model/compounds/memberreftype-dm.ts +4 -4
  98. package/src/doxygen/data-model/compounds/membertype-dm.ts +4 -4
  99. package/src/doxygen/data-model/compounds/paramtype-dm.ts +4 -4
  100. package/src/doxygen/data-model/compounds/referencetype-dm.ts +4 -4
  101. package/src/doxygen/data-model/compounds/reftexttype-dm.ts +4 -4
  102. package/src/doxygen/data-model/compounds/reftype-dm.ts +4 -4
  103. package/src/doxygen/data-model/compounds/reimplementtype-dm.ts +4 -4
  104. package/src/doxygen/data-model/compounds/requirements-dm.ts +50 -0
  105. package/src/doxygen/data-model/compounds/sectiondeftype-dm.ts +4 -4
  106. package/src/doxygen/data-model/compounds/tableofcontentstype-dm.ts +6 -5
  107. package/src/doxygen/data-model/compounds/templateparamlisttype-dm.ts +4 -4
  108. package/src/doxygen/data-model/data-model.ts +9 -8
  109. package/src/doxygen/data-model/doxyfile/doxyfileoptiontype-dm.ts +4 -4
  110. package/src/doxygen/data-model/doxyfile/doxyfiletype-dm.ts +4 -4
  111. package/src/doxygen/data-model/doxygen-xml-parser.ts +4 -4
  112. package/src/doxygen/data-model/index/indexcompoundtype-dm.ts +4 -4
  113. package/src/doxygen/data-model/index/indexdoxygentype-dm.ts +4 -4
  114. package/src/doxygen/data-model/index/indexmembertype-dm.ts +4 -4
  115. package/src/doxygen/data-model/types.ts +4 -4
  116. package/src/doxygen/data-model/xsds/README.md +3 -3
  117. package/src/doxygen/data-model/xsds/compound.xsd +91 -2
  118. package/src/doxygen/data-model/xsds/doxyfile.xsd +11 -1
  119. package/src/doxygen/data-model/xsds/index.xsd +3 -1
  120. package/src/index.ts +10 -4
  121. package/src/tsconfig.json +3 -1
@@ -2,11 +2,11 @@
2
2
  * This file is part of the xPack project (http://xpack.github.io).
3
3
  * Copyright (c) 2025-2026 Liviu Ionescu. All rights reserved.
4
4
  *
5
- * Permission to use, copy, modify, and/or distribute this software
6
- * for any purpose is hereby granted, under the terms of the MIT license.
5
+ * Permission to use, copy, modify, and/or distribute this software for any
6
+ * purpose is hereby granted, under the terms of the MIT license.
7
7
  *
8
- * If a copy of the license was not distributed with this file, it can
9
- * be obtained from https://opensource.org/licenses/MIT.
8
+ * If a copy of the license was not distributed with this file, it can be
9
+ * obtained from https://opensource.org/licenses/mit.
10
10
  */
11
11
 
12
12
  // ----------------------------------------------------------------------------
@@ -103,7 +103,10 @@ export class Pages extends CollectionBase {
103
103
  const pagesCategory: SidebarCategoryItem = {
104
104
  type: 'category',
105
105
  label: 'Pages',
106
- // There is no index page.
106
+ link: {
107
+ type: 'doc',
108
+ id: `${this.workspace.sidebarBaseId}indices/pages/index`,
109
+ },
107
110
  collapsed: true,
108
111
  items: [],
109
112
  }
@@ -213,7 +216,51 @@ export class Pages extends CollectionBase {
213
216
  * @returns Promise that resolves immediately
214
217
  */
215
218
  override async generateIndexDotMdFile(): Promise<void> {
216
- // There is no pages index.
219
+ if (this.collectionCompoundsById.size === 0) {
220
+ return
221
+ }
222
+
223
+ const filePath = `${this.workspace.outputFolderPath}indices/pages/index.md`
224
+ const permalink = 'pages'
225
+
226
+ const frontMatter: FrontMatter = {
227
+ title: 'Pages',
228
+ slug: `${this.workspace.slugBaseUrl}${permalink}`,
229
+ description: 'The pages that contributed content to this site',
230
+ custom_edit_url: null,
231
+ keywords: ['doxygen', 'pages', 'reference'],
232
+ }
233
+
234
+ const lines: string[] = []
235
+
236
+ lines.push('The Doxygen contributed pages are:')
237
+ lines.push('')
238
+
239
+ for (const [pageId, page] of this.collectionCompoundsById) {
240
+ // console.log(`Page: ${pageId} (${page.compoundName})`)
241
+ if (pageId === 'indexpage') {
242
+ continue
243
+ }
244
+ if (
245
+ page.sidebarLabel === undefined ||
246
+ page.sidebarId === undefined ||
247
+ page.relativePermalink === undefined
248
+ ) {
249
+ continue
250
+ }
251
+ const pagePermalink = this.workspace.pageBaseUrl + page.relativePermalink
252
+ lines.push(`- [${page.sidebarLabel}](${pagePermalink})`)
253
+ }
254
+
255
+ if (this.workspace.options.verbose) {
256
+ console.log(`Writing pages index file '${filePath}'...`)
257
+ }
258
+
259
+ await this.workspace.writeOutputMdFile({
260
+ filePath,
261
+ frontMatter,
262
+ bodyLines: lines,
263
+ })
217
264
  }
218
265
  }
219
266
 
@@ -2,11 +2,11 @@
2
2
  * This file is part of the xPack project (http://xpack.github.io).
3
3
  * Copyright (c) 2025-2026 Liviu Ionescu. All rights reserved.
4
4
  *
5
- * Permission to use, copy, modify, and/or distribute this software
6
- * for any purpose is hereby granted, under the terms of the MIT license.
5
+ * Permission to use, copy, modify, and/or distribute this software for any
6
+ * purpose is hereby granted, under the terms of the MIT license.
7
7
  *
8
- * If a copy of the license was not distributed with this file, it can
9
- * be obtained from https://opensource.org/licenses/MIT.
8
+ * If a copy of the license was not distributed with this file, it can be
9
+ * obtained from https://opensource.org/licenses/mit.
10
10
  */
11
11
 
12
12
  // ----------------------------------------------------------------------------
@@ -2,11 +2,11 @@
2
2
  * This file is part of the xPack project (http://xpack.github.io).
3
3
  * Copyright (c) 2025-2026 Liviu Ionescu. All rights reserved.
4
4
  *
5
- * Permission to use, copy, modify, and/or distribute this software
6
- * for any purpose is hereby granted, under the terms of the MIT license.
5
+ * Permission to use, copy, modify, and/or distribute this software for any
6
+ * purpose is hereby granted, under the terms of the MIT license.
7
7
  *
8
- * If a copy of the license was not distributed with this file, it can
9
- * be obtained from https://opensource.org/licenses/MIT.
8
+ * If a copy of the license was not distributed with this file, it can be
9
+ * obtained from https://opensource.org/licenses/mit.
10
10
  */
11
11
 
12
12
  // ----------------------------------------------------------------------------
@@ -2,11 +2,11 @@
2
2
  * This file is part of the xPack project (http://xpack.github.io).
3
3
  * Copyright (c) 2025-2026 Liviu Ionescu. All rights reserved.
4
4
  *
5
- * Permission to use, copy, modify, and/or distribute this software
6
- * for any purpose is hereby granted, under the terms of the MIT license.
5
+ * Permission to use, copy, modify, and/or distribute this software for any
6
+ * purpose is hereby granted, under the terms of the MIT license.
7
7
  *
8
- * If a copy of the license was not distributed with this file, it can
9
- * be obtained from https://opensource.org/licenses/MIT.
8
+ * If a copy of the license was not distributed with this file, it can be
9
+ * obtained from https://opensource.org/licenses/mit.
10
10
  */
11
11
 
12
12
  // ----------------------------------------------------------------------------
@@ -2,11 +2,11 @@
2
2
  * This file is part of the xPack project (http://xpack.github.io).
3
3
  * Copyright (c) 2025-2026 Liviu Ionescu. All rights reserved.
4
4
  *
5
- * Permission to use, copy, modify, and/or distribute this software
6
- * for any purpose is hereby granted, under the terms of the MIT license.
5
+ * Permission to use, copy, modify, and/or distribute this software for any
6
+ * purpose is hereby granted, under the terms of the MIT license.
7
7
  *
8
- * If a copy of the license was not distributed with this file, it can
9
- * be obtained from https://opensource.org/licenses/MIT.
8
+ * If a copy of the license was not distributed with this file, it can be
9
+ * obtained from https://opensource.org/licenses/mit.
10
10
  */
11
11
 
12
12
  // ----------------------------------------------------------------------------
@@ -47,6 +47,7 @@ import {
47
47
  InitializerDataModel,
48
48
  RequiresClauseDataModel,
49
49
  } from './linkedtexttype-dm.js'
50
+ import { ConceptPartsDataModel } from './concepts-dm.js'
50
51
 
51
52
  // ----------------------------------------------------------------------------
52
53
 
@@ -282,15 +283,25 @@ export class XyzDataModel extends AbstractXyzType {
282
283
  // <xsd:element name="tableofcontents" type="tableofcontentsType" minOccurs="0" maxOccurs="1" />
283
284
  // <xsd:element name="requiresclause" type="linkedTextType" minOccurs="0" />
284
285
  // <xsd:element name="initializer" type="linkedTextType" minOccurs="0" />
286
+
287
+ // <xsd:element name="conceptparts" type="conceptParts" minOccurs="0" />
288
+
285
289
  // <xsd:element name="briefdescription" type="descriptionType" minOccurs="0" />
286
290
  // <xsd:element name="detaileddescription" type="descriptionType" minOccurs="0" />
287
291
  // <xsd:element name="exports" type="exportsType" minOccurs="0" maxOccurs="1"/>
288
292
  // <xsd:element name="inheritancegraph" type="graphType" minOccurs="0" />
289
293
  // <xsd:element name="collaborationgraph" type="graphType" minOccurs="0" />
290
294
  // <xsd:element name="programlisting" type="listingType" minOccurs="0" />
295
+
296
+ // <xsd:element name="satisfies" type="requirementRefsType" minOccurs="0" maxOccurs="1" />
297
+ // <xsd:element name="verifies" type="requirementRefsType" minOccurs="0" maxOccurs="1" />
298
+
291
299
  // <xsd:element name="location" type="locationType" minOccurs="0" />
292
300
  // <xsd:element name="listofallmembers" type="listofallmembersType" minOccurs="0" />
301
+
302
+ // <xsd:element name="requirementslist" type="requirementslistType" minOccurs="0" />
293
303
  // </xsd:sequence>
304
+
294
305
  // <xsd:attribute name="id" type="xsd:string" />
295
306
  // <xsd:attribute name="kind" type="DoxCompoundKind" />
296
307
  // <xsd:attribute name="language" type="DoxLanguage" use="optional"/>
@@ -321,6 +332,8 @@ export class XyzDataModel extends AbstractXyzType {
321
332
  // <xsd:enumeration value="example" />
322
333
  // <xsd:enumeration value="dir" />
323
334
  // <xsd:enumeration value="concept" />
335
+ // <xsd:enumeration value="requirement" />
336
+ // <xsd:enumeration value="requirements" />
324
337
  // </xsd:restriction>
325
338
  // </xsd:simpleType>
326
339
 
@@ -483,6 +496,18 @@ export abstract class AbstractCompoundDefType extends AbstractDataModelBase {
483
496
  */
484
497
  initializer?: InitializerDataModel | undefined
485
498
 
499
+ /**
500
+ * Concept parts associated with the compound.
501
+ *
502
+ * @remarks
503
+ * Contains the structured `conceptparts` content emitted by Doxygen for
504
+ * concept definitions. This property captures the ordered mixture of code
505
+ * fragments and documentation fragments extracted from 'conceptparts'
506
+ * XML elements, preserving their original sequence for later rendering in
507
+ * the generated documentation.
508
+ */
509
+ conceptParts?: ConceptPartsDataModel | undefined
510
+
486
511
  /**
487
512
  * Inner folder references contained within this compound.
488
513
  *
@@ -791,6 +816,8 @@ export abstract class AbstractCompoundDefType extends AbstractDataModelBase {
791
816
  this.requiresClause = new RequiresClauseDataModel(xml, innerElement)
792
817
  } else if (xml.hasInnerElement(innerElement, 'initializer')) {
793
818
  this.initializer = new InitializerDataModel(xml, innerElement)
819
+ } else if (xml.hasInnerElement(innerElement, 'conceptparts')) {
820
+ this.conceptParts = new ConceptPartsDataModel(xml, innerElement)
794
821
  } else if (xml.hasInnerElement(innerElement, 'inheritancegraph')) {
795
822
  // TODO: Ignored, not used for now.
796
823
  } else if (xml.hasInnerElement(innerElement, 'collaborationgraph')) {
@@ -1154,3 +1181,50 @@ export class DocBookOnlyDataModel extends AbstractStringType {
1154
1181
  }
1155
1182
 
1156
1183
  // ----------------------------------------------------------------------------
1184
+
1185
+ // <xsd:complexType name="docMermaidType" mixed="true">
1186
+ // <xsd:group ref="docTitleCmdGroup" minOccurs="0" maxOccurs="unbounded" />
1187
+ // <xsd:attribute name="name" type="xsd:string" use="optional"/>
1188
+ // <xsd:attribute name="width" type="xsd:string" use="optional"/>
1189
+ // <xsd:attribute name="height" type="xsd:string" use="optional"/>
1190
+ // <xsd:attribute name="caption" type="xsd:string" use="optional"/>
1191
+ // </xsd:complexType>
1192
+
1193
+ // <xsd:complexType name="tableofcontentsNameType">
1194
+ // <xsd:sequence>
1195
+ // <xsd:element name="para" type="docParaType" minOccurs="0" maxOccurs="unbounded" />
1196
+ // </xsd:sequence>
1197
+ // </xsd:complexType>
1198
+
1199
+ // <xsd:simpleType name="DoxPlantumlEngine">
1200
+ // <xsd:restriction base="xsd:string">
1201
+ // <xsd:enumeration value="uml"/>
1202
+ // <xsd:enumeration value="bpm"/>
1203
+ // <xsd:enumeration value="wire"/>
1204
+ // <xsd:enumeration value="dot"/>
1205
+ // <xsd:enumeration value="ditaa"/>
1206
+ // <xsd:enumeration value="salt"/>
1207
+ // <xsd:enumeration value="math"/>
1208
+ // <xsd:enumeration value="latex"/>
1209
+ // <xsd:enumeration value="gantt"/>
1210
+ // <xsd:enumeration value="mindmap"/>
1211
+ // <xsd:enumeration value="wbs"/>
1212
+ // <xsd:enumeration value="yaml"/>
1213
+ // <xsd:enumeration value="creole"/>
1214
+ // <xsd:enumeration value="json"/>
1215
+ // <xsd:enumeration value="flow"/>
1216
+ // <xsd:enumeration value="board"/>
1217
+ // <xsd:enumeration value="git"/>
1218
+ // <xsd:enumeration value="hcl"/>
1219
+ // <xsd:enumeration value="regex"/>
1220
+ // <xsd:enumeration value="ebnf"/>
1221
+ // <xsd:enumeration value="files"/>
1222
+ // <xsd:enumeration value="chart"/>
1223
+ // <xsd:enumeration value="nwdiag"/>
1224
+ // <xsd:enumeration value="packetdiag"/>
1225
+ // <xsd:enumeration value="project"/>
1226
+ // <xsd:enumeration value="sprites"/>
1227
+ // </xsd:restriction>
1228
+ // </xsd:simpleType>
1229
+
1230
+ // ----------------------------------------------------------------------------
@@ -2,11 +2,11 @@
2
2
  * This file is part of the xPack project (http://xpack.github.io).
3
3
  * Copyright (c) 2025-2026 Liviu Ionescu. All rights reserved.
4
4
  *
5
- * Permission to use, copy, modify, and/or distribute this software
6
- * for any purpose is hereby granted, under the terms of the MIT license.
5
+ * Permission to use, copy, modify, and/or distribute this software for any
6
+ * purpose is hereby granted, under the terms of the MIT license.
7
7
  *
8
- * If a copy of the license was not distributed with this file, it can
9
- * be obtained from https://opensource.org/licenses/MIT.
8
+ * If a copy of the license was not distributed with this file, it can be
9
+ * obtained from https://opensource.org/licenses/mit.
10
10
  */
11
11
 
12
12
  // ----------------------------------------------------------------------------
@@ -0,0 +1,362 @@
1
+ /*
2
+ * This file is part of the xPack project (http://xpack.github.io).
3
+ * Copyright (c) 2026 Liviu Ionescu. All rights reserved.
4
+ *
5
+ * Permission to use, copy, modify, and/or distribute this software for any
6
+ * purpose is hereby granted, under the terms of the MIT license.
7
+ *
8
+ * If a copy of the license was not distributed with this file, it can be
9
+ * obtained from https://opensource.org/licenses/mit.
10
+ */
11
+
12
+ import assert from 'node:assert'
13
+ import * as util from 'node:util'
14
+
15
+ import { DoxygenXmlParser } from '../doxygen-xml-parser.js'
16
+ import { AbstractDataModelBase } from '../types.js'
17
+ import {
18
+ AbstractDescriptionType,
19
+ ProgramListingDataModel,
20
+ } from './descriptiontype-dm.js'
21
+
22
+ // ----------------------------------------------------------------------------
23
+
24
+ // <xsd:complexType name="conceptParts">
25
+ // <xsd:sequence>
26
+ // <xsd:choice minOccurs="0" maxOccurs="unbounded">
27
+ // <xsd:element name="codepart" type="conceptCodePart"/>
28
+ // <xsd:element name="docpart" type="conceptDocPart"/>
29
+ // </xsd:choice>
30
+ // </xsd:sequence>
31
+ // </xsd:complexType>
32
+
33
+ // ----------------------------------------------------------------------------
34
+
35
+ /**
36
+ * Abstract base class for concept parts containers.
37
+ *
38
+ * @remarks
39
+ * This class is useful because Doxygen emits concept parts as an ordered
40
+ * mixture of code fragments and documentation fragments, and that order must
41
+ * be preserved for later rendering. Use this class as the common parser for
42
+ * `conceptparts`-style elements that contain repeated `codepart` and
43
+ * `docpart` children. The parsed children are stored in the inherited
44
+ * `children` collection.
45
+ */
46
+ export abstract class AbstractConceptParts extends AbstractDataModelBase {
47
+ /**
48
+ * Creates a new abstract concept parts data model instance.
49
+ *
50
+ * @remarks
51
+ * This constructor is useful because it parses the ordered child sequence
52
+ * of a concept parts element and instantiates the corresponding concrete
53
+ * child data models. Use it from subclasses that represent XML elements
54
+ * following the `conceptParts` schema shape. The original ordering of
55
+ * `codepart` and `docpart` elements is preserved in `children`.
56
+ *
57
+ * @param xml - The XML parser instance for processing elements.
58
+ * @param element - The XML element object to parse.
59
+ * @param elementName - The name of the XML element being processed.
60
+ */
61
+ constructor(xml: DoxygenXmlParser, element: object, elementName: string) {
62
+ super(elementName)
63
+
64
+ // console.log(
65
+ // elementName,
66
+ // util.inspect(element, { compact: false, depth: 999 })
67
+ // )
68
+
69
+ // ------------------------------------------------------------------------
70
+ // Process elements.
71
+
72
+ // A sequence of codepart, docpart, in any order.
73
+ const innerElements = xml.getInnerElements(element, elementName)
74
+ assert(innerElements.length > 0)
75
+
76
+ this.children = []
77
+ for (const innerElement of innerElements) {
78
+ if (xml.hasInnerText(innerElement)) {
79
+ // Ignore texts.
80
+ } else if (xml.hasInnerElement(innerElement, 'codepart')) {
81
+ this.children.push(new ConceptCodePartDataModel(xml, innerElement))
82
+ } else if (xml.hasInnerElement(innerElement, 'docpart')) {
83
+ this.children.push(new ConceptDocPartDataModel(xml, innerElement))
84
+ } else {
85
+ console.error(util.inspect(innerElement))
86
+ console.error(
87
+ `${elementName} element:`,
88
+ Object.keys(innerElement),
89
+ 'not implemented yet in',
90
+ this.constructor.name
91
+ )
92
+ }
93
+ }
94
+ }
95
+ }
96
+
97
+ // ----------------------------------------------------------------------------
98
+
99
+ // <xsd:element name="conceptparts" type="conceptParts" minOccurs="0" />
100
+
101
+ /**
102
+ * Data model for `conceptparts` elements.
103
+ *
104
+ * @remarks
105
+ * This class is useful because it provides the concrete entry point for
106
+ * parsing Doxygen `conceptparts` XML nodes into the internal data model.
107
+ * Use it when a compound definition contains a `conceptparts` child. The
108
+ * inherited parsing logic stores the ordered code and documentation parts in
109
+ * the `children` collection.
110
+ */
111
+ export class ConceptPartsDataModel extends AbstractConceptParts {
112
+ /**
113
+ * Creates a new `conceptparts` data model instance.
114
+ *
115
+ * @remarks
116
+ * This constructor is useful because it binds the generic concept parts
117
+ * parser to the concrete `conceptparts` XML element name. Use it when
118
+ * parsing a Doxygen compound that includes concept parts content.
119
+ *
120
+ * @param xml - The XML parser instance for processing elements.
121
+ * @param element - The XML element object to parse.
122
+ */
123
+ constructor(xml: DoxygenXmlParser, element: object) {
124
+ super(xml, element, 'conceptparts')
125
+ }
126
+ }
127
+
128
+ // ----------------------------------------------------------------------------
129
+
130
+ // <xsd:complexType name="conceptCodePart">
131
+ // <xsd:sequence>
132
+ // <xsd:element name="programlisting" type="listingType"/>
133
+ // </xsd:sequence>
134
+ // <xsd:attribute name="line" type="xsd:integer"/>
135
+ // </xsd:complexType>
136
+
137
+ // ----------------------------------------------------------------------------
138
+
139
+ /**
140
+ * Abstract base class for concept code parts.
141
+ *
142
+ * @remarks
143
+ * This class is useful because concept code fragments combine a mandatory
144
+ * program listing with source-location metadata, and both must be parsed
145
+ * together from the XML. Use this class as the common parser for elements
146
+ * shaped like `conceptCodePart`. Subclasses provide the concrete XML element
147
+ * name.
148
+ */
149
+ export abstract class AbstractConceptCodePart extends AbstractDataModelBase {
150
+ /**
151
+ * Program listing contained in the concept code part.
152
+ *
153
+ * @remarks
154
+ * This property is useful because it preserves the code fragment associated
155
+ * with a concept part as a structured listing data model for later
156
+ * rendering. It is populated from the `programlisting` child element.
157
+ */
158
+ programListing?: ProgramListingDataModel | undefined
159
+
160
+ /**
161
+ * Source line number of the concept code part.
162
+ *
163
+ * @remarks
164
+ * This property is useful because it records the original source location
165
+ * reported by Doxygen for the code fragment. It is populated from the
166
+ * `line` XML attribute and is required to be greater than zero.
167
+ */
168
+ line: number | undefined
169
+
170
+ /**
171
+ * Creates a new abstract concept code part data model instance.
172
+ *
173
+ * @remarks
174
+ * This constructor is useful because it parses both the embedded program
175
+ * listing and the source line metadata for a concept code part. Use it from
176
+ * subclasses representing concrete XML elements that follow the
177
+ * `conceptCodePart` schema definition. The constructor validates that the
178
+ * required `line` attribute is present and positive.
179
+ *
180
+ * @param xml - The XML parser instance for processing elements.
181
+ * @param element - The XML element object to parse.
182
+ * @param elementName - The name of the XML element being processed.
183
+ */
184
+ constructor(xml: DoxygenXmlParser, element: object, elementName: string) {
185
+ super(elementName)
186
+
187
+ // console.log(
188
+ // elementName,
189
+ // util.inspect(element, { compact: false, depth: 999 })
190
+ // )
191
+
192
+ // ------------------------------------------------------------------------
193
+ // Process elements.
194
+
195
+ const innerElements = xml.getInnerElements(element, elementName)
196
+
197
+ for (const innerElement of innerElements) {
198
+ if (xml.hasInnerText(innerElement)) {
199
+ // Ignore texts.
200
+ } else if (xml.hasInnerElement(innerElement, 'programlisting')) {
201
+ this.programListing = new ProgramListingDataModel(xml, innerElement)
202
+ } else {
203
+ console.error(util.inspect(innerElement))
204
+ console.error(
205
+ `${elementName} element:`,
206
+ Object.keys(innerElement),
207
+ 'not implemented yet in',
208
+ this.constructor.name
209
+ )
210
+ }
211
+ }
212
+
213
+ // ------------------------------------------------------------------------
214
+ // Process attributes.
215
+
216
+ assert(xml.hasAttributes(element))
217
+ const attributesNames = xml.getAttributesNames(element)
218
+ // console.log(attributesNames)
219
+ for (const attributeName of attributesNames) {
220
+ // console.log(attributeName)
221
+ if (attributeName === '@_line') {
222
+ this.line = xml.getAttributeNumberValue(element, '@_line')
223
+ } else {
224
+ console.error(util.inspect(element, { compact: false, depth: 999 }))
225
+ console.error(
226
+ `${elementName} attribute:`,
227
+ attributeName,
228
+ 'not implemented yet in',
229
+ this.constructor.name
230
+ )
231
+ }
232
+ }
233
+
234
+ assert(this.line !== undefined)
235
+ assert(this.line > 0)
236
+ }
237
+ }
238
+
239
+ /**
240
+ * Data model for `codepart` elements within concept parts.
241
+ *
242
+ * @remarks
243
+ * This class is useful because it provides the concrete parser for concept
244
+ * code fragments emitted by Doxygen. Use it when a `conceptparts` element
245
+ * contains a `codepart` child. The parsed data includes both the code listing
246
+ * and the source line metadata.
247
+ */
248
+ export class ConceptCodePartDataModel extends AbstractConceptCodePart {
249
+ /**
250
+ * Creates a new `codepart` data model instance.
251
+ *
252
+ * @remarks
253
+ * This constructor is useful because it binds the abstract concept code
254
+ * part parser to the concrete `codepart` XML element name. Use it when
255
+ * parsing concept-part content from Doxygen output.
256
+ *
257
+ * @param xml - The XML parser instance for processing elements.
258
+ * @param element - The XML element object to parse.
259
+ */
260
+ constructor(xml: DoxygenXmlParser, element: object) {
261
+ super(xml, element, 'codepart')
262
+ }
263
+ }
264
+
265
+ // ----------------------------------------------------------------------------
266
+
267
+ // <xsd:complexType name="conceptDocPart">
268
+ // <xsd:complexContent>
269
+ // <xsd:extension base="descriptionType">
270
+ // <xsd:attribute name="line" type="xsd:integer"/>
271
+ // <xsd:attribute name="col" type="xsd:integer"/>
272
+ // </xsd:extension>
273
+ // </xsd:complexContent>
274
+ // </xsd:complexType>
275
+
276
+ // ----------------------------------------------------------------------------
277
+
278
+ /**
279
+ * Data model for `docpart` elements within concept parts.
280
+ *
281
+ * @remarks
282
+ * This class is useful because it extends the standard description model
283
+ * with source-location metadata specific to concept documentation fragments.
284
+ * Use it when a `conceptparts` element contains a `docpart` child. The class
285
+ * preserves both the rich description content and the line and column
286
+ * position reported by Doxygen.
287
+ */
288
+ export class ConceptDocPartDataModel extends AbstractDescriptionType {
289
+ /**
290
+ * Source line number of the documentation fragment.
291
+ *
292
+ * @remarks
293
+ * This property is useful because it records where the documentation part
294
+ * originated in the source file. It is populated from the `line` XML
295
+ * attribute and is required to be greater than zero.
296
+ */
297
+ line: number | undefined
298
+
299
+ /**
300
+ * Source column number of the documentation fragment.
301
+ *
302
+ * @remarks
303
+ * This property is useful because it complements {@link line} with the
304
+ * column position reported by Doxygen for the documentation part. It is
305
+ * populated from the `col` XML attribute and is required to be greater than
306
+ * zero.
307
+ */
308
+ col: number | undefined
309
+
310
+ /**
311
+ * Creates a new `docpart` data model instance.
312
+ *
313
+ * @remarks
314
+ * This constructor is useful because it parses description content using
315
+ * the existing description-type logic, then extends that parsing with the
316
+ * additional line and column attributes required by concept documentation
317
+ * parts. Use it when parsing a `docpart` child from a `conceptparts`
318
+ * element.
319
+ *
320
+ * @param xml - The XML parser instance for processing elements.
321
+ * @param element - The XML element object to parse.
322
+ */
323
+ constructor(xml: DoxygenXmlParser, element: object) {
324
+ super(xml, element, 'docpart')
325
+
326
+ // console.log(
327
+ // 'docpart',
328
+ // util.inspect(element, { compact: false, depth: 999 })
329
+ // )
330
+
331
+ // ------------------------------------------------------------------------
332
+ // Process attributes.
333
+
334
+ // AbstractDescriptionType has no attributes, so all attributes are
335
+ // processed here.
336
+ assert(xml.hasAttributes(element))
337
+ const attributesNames = xml.getAttributesNames(element)
338
+ // console.log(attributesNames)
339
+ for (const attributeName of attributesNames) {
340
+ // console.log(attributeName)
341
+ if (attributeName === '@_line') {
342
+ this.line = xml.getAttributeNumberValue(element, '@_line')
343
+ } else if (attributeName === '@_col') {
344
+ this.col = xml.getAttributeNumberValue(element, '@_col')
345
+ } else {
346
+ console.error(util.inspect(element, { compact: false, depth: 999 }))
347
+ console.error(
348
+ `docpart attribute:`,
349
+ attributeName,
350
+ 'not implemented yet in',
351
+ this.constructor.name
352
+ )
353
+ }
354
+ }
355
+
356
+ assert(this.line !== undefined)
357
+ assert(this.line > 0)
358
+ assert(this.col !== undefined)
359
+ assert(this.col > 0)
360
+ }
361
+ }
362
+ // ----------------------------------------------------------------------------