@xpack/docusaurus-plugin-doxygen
Version:
A Docusaurus plugin to integrate Doxygen into a Docusaurus project.
991 lines • 123 kB
JavaScript
/*
* This file is part of the xPack project (http://xpack.github.io).
* Copyright (c) 2025 Liviu Ionescu. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software
* for any purpose is hereby granted, under the terms of the MIT license.
*
* If a copy of the license was not distributed with this file, it can
* be obtained from https://opensource.org/licenses/MIT.
*/
// ----------------------------------------------------------------------------
import assert from 'assert';
import * as util from 'node:util';
import { AbstractDataModelBase } from '../types.js';
import { RefTextDataModel } from './reftexttype-dm.js';
import { VariableListDataModel } from './docvarlistentrytype-dm.js';
// ----------------------------------------------------------------------------
// <xsd:complexType name="descriptionType" mixed="true"> <-- Character data is allowed to appear between the child elements!
// <xsd:sequence>
// <xsd:element name="title" type="xsd:string" minOccurs="0"/>
// <xsd:element name="para" type="docParaType" minOccurs="0" maxOccurs="unbounded" />
// <xsd:element name="internal" type="docInternalType" minOccurs="0" maxOccurs="unbounded"/>
// <xsd:element name="sect1" type="docSect1Type" minOccurs="0" maxOccurs="unbounded" />
// </xsd:sequence>
// </xsd:complexType>
export class AbstractDescriptionType extends AbstractDataModelBase {
constructor(xml, element, elementName) {
super(elementName);
// Any sequence of them.
this.children = [];
// console.log(elementName, util.inspect(element, { compact: false, depth: 999 }))
// ------------------------------------------------------------------------
// Process elements.
const innerElements = xml.getInnerElements(element, elementName);
assert(innerElements.length > 0);
for (const innerElement of innerElements) {
if (xml.hasInnerText(innerElement)) {
this.children.push(xml.getInnerText(innerElement));
}
else if (xml.isInnerElementText(innerElement, 'title')) {
assert(this.title === undefined);
this.title = xml.getInnerElementText(innerElement, 'title');
}
else if (xml.hasInnerElement(innerElement, 'para')) {
this.children.push(new ParaDataModel(xml, innerElement));
}
else if (xml.hasInnerElement(innerElement, 'internal')) {
this.children.push(new InternalDataModel(xml, innerElement));
}
else if (xml.hasInnerElement(innerElement, 'sect1')) {
this.children.push(new Sect1DataModel(xml, innerElement));
}
else {
console.error(util.inspect(innerElement));
console.error(`${elementName} element:`, Object.keys(innerElement), 'not implemented yet in', this.constructor.name);
}
}
// ------------------------------------------------------------------------
// Process attributes.
assert(!xml.hasAttributes(element));
// ------------------------------------------------------------------------
// console.log(util.inspect(this, { compact: false, depth: 999 }))
}
}
// ----------------------------------------------------------------------------
// <xsd:complexType name="listingType">
// <xsd:sequence>
// <xsd:element name="codeline" type="codelineType" minOccurs="0" maxOccurs="unbounded" />
// </xsd:sequence>
// <xsd:attribute name="filename" type="xsd:string" use="optional"/>
// </xsd:complexType>
export class AbstractListingType extends AbstractDataModelBase {
constructor(xml, element, elementName) {
super(elementName);
// console.log(elementName, util.inspect(element, { compact: false, depth: 999 }))
// ------------------------------------------------------------------------
// Process elements.
const innerElements = xml.getInnerElements(element, elementName);
assert(innerElements.length > 0);
for (const innerElement of innerElements) {
if (xml.hasInnerText(innerElement)) {
// Ignore texts.
}
else if (xml.hasInnerElement(innerElement, 'codeline')) {
if (this.codelines === undefined) {
this.codelines = [];
}
this.codelines.push(new CodeLineDataModel(xml, innerElement));
}
else {
console.error(util.inspect(innerElement));
console.error(`${elementName} element:`, Object.keys(innerElement), 'not implemented yet in', this.constructor.name);
}
}
// ------------------------------------------------------------------------
// Process attributes.
if (xml.hasAttributes(element)) {
const attributesNames = xml.getAttributesNames(element);
for (const attributeName of attributesNames) {
if (attributeName === '@_filename') {
this.filename = xml.getAttributeStringValue(element, '@_filename');
}
else {
console.error(util.inspect(element, { compact: false, depth: 999 }));
console.error(`${elementName} attribute:`, attributeName, 'not implemented yet in', this.constructor.name);
}
}
}
// ------------------------------------------------------------------------
// console.log(util.inspect(this, { compact: false, depth: 999 }))
}
}
// <xsd:element name="programlisting" type="listingType" />
export class ProgramListingDataModel extends AbstractListingType {
constructor(xml, element) {
super(xml, element, 'programlisting');
}
}
// WARNING: attributes are all optional
// <xsd:complexType name="codelineType">
// <xsd:sequence>
// <xsd:element name="highlight" type="highlightType" minOccurs="0" maxOccurs="unbounded" />
// </xsd:sequence>
// <xsd:attribute name="lineno" type="xsd:integer" />
// <xsd:attribute name="refid" type="xsd:string" />
// <xsd:attribute name="refkind" type="DoxRefKind" />
// <xsd:attribute name="external" type="DoxBool" />
// </xsd:complexType>
export class AbstractCodeLineType extends AbstractDataModelBase {
constructor(xml, element, elementName) {
super(elementName);
// console.log(elementName, util.inspect(element, { compact: false, depth: 999 }))
// ------------------------------------------------------------------------
// Process elements.
// May be empty, like `<codeline></codeline>`
const innerElements = xml.getInnerElements(element, elementName);
for (const innerElement of innerElements) {
if (xml.hasInnerText(innerElement)) {
// Ignore texts.
}
else if (xml.hasInnerElement(innerElement, 'highlight')) {
if (this.highlights === undefined) {
this.highlights = [];
}
this.highlights.push(new HighlightDataModel(xml, innerElement));
}
else {
console.error(util.inspect(innerElement));
console.error(`${elementName} element:`, Object.keys(innerElement), 'not implemented yet in', this.constructor.name);
}
}
// ------------------------------------------------------------------------
// Process attributes.
if (xml.hasAttributes(element)) {
const attributesNames = xml.getAttributesNames(element);
for (const attributeName of attributesNames) {
if (attributeName === '@_lineno') {
this.lineno = Number(xml.getAttributeNumberValue(element, '@_lineno'));
}
else if (attributeName === '@_refid') {
this.refid = xml.getAttributeStringValue(element, '@_refid');
}
else if (attributeName === '@_refkind') {
this.refkind = xml.getAttributeStringValue(element, '@_refkind');
}
else if (attributeName === '@_external') {
this.external = Boolean(xml.getAttributeBooleanValue(element, '@_external'));
}
else {
console.error(util.inspect(element, { compact: false, depth: 999 }));
console.error(`${elementName} attribute:`, attributeName, 'not implemented yet in', this.constructor.name);
}
}
}
// ------------------------------------------------------------------------
// console.log(util.inspect(this, { compact: false, depth: 999 }))
}
}
// <xsd:element name="codeline" type="codelineType" minOccurs="0" maxOccurs="unbounded" />
export class CodeLineDataModel extends AbstractCodeLineType {
constructor(xml, element) {
super(xml, element, 'codeline');
}
}
export class AbstractHighlightType extends AbstractDataModelBase {
constructor(xml, element, elementName) {
super(elementName);
// Any sequence of them.
this.children = [];
// Mandatory attributes.
this.classs = '';
// console.log(elementName, util.inspect(element, { compact: false, depth: 999 }))
// ------------------------------------------------------------------------
// Process elements.
const innerElements = xml.getInnerElements(element, elementName);
if (innerElements.length > 0) {
for (const innerElement of innerElements) {
if (xml.hasInnerText(innerElement)) {
this.children.push(xml.getInnerText(innerElement));
}
else if (xml.isInnerElementText(innerElement, 'sp')) {
this.children.push(new SpDataModel(xml, innerElement));
}
else if (xml.hasInnerElement(innerElement, 'ref')) {
this.children.push(new RefTextDataModel(xml, innerElement));
}
else {
console.error(util.inspect(innerElement));
console.error(`${elementName} element:`, Object.keys(innerElement), 'not implemented yet in', this.constructor.name);
}
}
}
// ------------------------------------------------------------------------
// Process attributes.
assert(xml.hasAttributes(element));
const attributesNames = xml.getAttributesNames(element);
for (const attributeName of attributesNames) {
if (attributeName === '@_class') {
this.classs = xml.getAttributeStringValue(element, '@_class');
}
else {
console.error(util.inspect(element, { compact: false, depth: 999 }));
console.error(`${elementName} attribute:`, attributeName, 'not implemented yet in', this.constructor.name);
}
}
assert(this.classs.length > 0);
// ------------------------------------------------------------------------
// console.log(util.inspect(this, { compact: false, depth: 999 }))
}
}
// <xsd:element name="highlight" type="highlightType" minOccurs="0" maxOccurs="unbounded" />
export class HighlightDataModel extends AbstractHighlightType {
constructor(xml, element) {
super(xml, element, 'highlight');
}
}
// <xsd:complexType name="spType" mixed="true"> <-- Character data is allowed to appear between the child elements!
// <xsd:attribute name="value" type="xsd:integer" use="optional"/>
// </xsd:complexType>
export class AbstractSpType extends AbstractDataModelBase {
constructor(xml, element, elementName) {
super(elementName);
this.text = '';
// console.log(elementName, util.inspect(element, { compact: false, depth: 999 }))
// ------------------------------------------------------------------------
// Process elements.
const innerElements = xml.getInnerElements(element, elementName);
assert(innerElements.length === 0);
// ------------------------------------------------------------------------
// Process attributes.
if (xml.hasAttributes(element)) {
const attributesNames = xml.getAttributesNames(element);
for (const attributeName of attributesNames) {
if (attributeName === '@_value') {
this.value = Number(xml.getAttributeNumberValue(element, '@_value'));
}
else {
console.error(util.inspect(element, { compact: false, depth: 999 }));
console.error(`${elementName} attribute:`, attributeName, 'not implemented yet in', this.constructor.name);
}
}
}
// ------------------------------------------------------------------------
// console.log(util.inspect(this, { compact: false, depth: 999 }))
}
}
// <xsd:element name="sp" type="spType" />
export class SpDataModel extends AbstractSpType {
constructor(xml, element) {
super(xml, element, 'sp');
}
}
// ----------------------------------------------------------------------------
// <xsd:complexType name="docSect1Type" mixed="true"> <-- Character data is allowed to appear between the child elements!
// <xsd:sequence>
// <xsd:element name="title" type="docTitleType" minOccurs="0" />
// <xsd:choice maxOccurs="unbounded">
// <xsd:element name="para" type="docParaType" minOccurs="0" maxOccurs="unbounded" />
// <xsd:element name="internal" type="docInternalS1Type" minOccurs="0" maxOccurs="unbounded" />
// <xsd:element name="sect2" type="docSect2Type" minOccurs="0" maxOccurs="unbounded" />
// </xsd:choice>
// </xsd:sequence>
// <xsd:attribute name="id" type="xsd:string" />
// </xsd:complexType>
export class AbstractDocSect1Type extends AbstractDataModelBase {
constructor(xml, element, elementName) {
super(elementName);
// Any sequence of them.
this.children = [];
// console.log(elementName, util.inspect(element, { compact: false, depth: 999 }))
// ------------------------------------------------------------------------
// Process elements.
const innerElements = xml.getInnerElements(element, elementName);
assert(innerElements.length > 0);
for (const innerElement of innerElements) {
if (xml.hasInnerText(innerElement)) {
this.children.push(xml.getInnerText(innerElement));
}
else if (xml.isInnerElementText(innerElement, 'title')) {
assert(this.title === undefined);
this.title = new TitleDataModel(xml, innerElement);
}
else if (xml.hasInnerElement(innerElement, 'para')) {
this.children.push(new ParaDataModel(xml, innerElement));
}
else if (xml.hasInnerElement(innerElement, 'internal')) {
this.children.push(new InternalS1DataModel(xml, innerElement));
}
else if (xml.hasInnerElement(innerElement, 'sect2')) {
this.children.push(new Sect2DataModel(xml, innerElement));
}
else {
console.error(util.inspect(innerElement));
console.error(`${elementName} element:`, Object.keys(innerElement), 'not implemented yet in', this.constructor.name);
}
}
// ------------------------------------------------------------------------
// Process attributes.
if (xml.hasAttributes(element)) {
const attributesNames = xml.getAttributesNames(element);
for (const attributeName of attributesNames) {
if (attributeName === '@_id') {
this.id = xml.getAttributeStringValue(element, '@_id');
}
else {
console.error(util.inspect(element, { compact: false, depth: 999 }));
console.error(`${elementName} attribute:`, attributeName, 'not implemented yet in', this.constructor.name);
}
}
}
// ------------------------------------------------------------------------
// console.log(util.inspect(this, { compact: false, depth: 999 }))
}
}
// ----------------------------------------------------------------------------
// <xsd:complexType name="docSect2Type" mixed="true"> <-- Character data is allowed to appear between the child elements!
// <xsd:sequence>
// <xsd:element name="title" type="docTitleType" minOccurs="0" />
// <xsd:choice maxOccurs="unbounded">
// <xsd:element name="para" type="docParaType" minOccurs="0" maxOccurs="unbounded" />
// <xsd:element name="sect3" type="docSect3Type" minOccurs="0" maxOccurs="unbounded" />
// <xsd:element name="internal" type="docInternalS2Type" minOccurs="0" />
// </xsd:choice>
// </xsd:sequence>
// <xsd:attribute name="id" type="xsd:string" />
// </xsd:complexType>
export class AbstractDocSect2Type extends AbstractDataModelBase {
constructor(xml, element, elementName) {
super(elementName);
// Any sequence of them.
this.children = [];
// console.log(elementName, util.inspect(element, { compact: false, depth: 999 }))
// ------------------------------------------------------------------------
// Process elements.
const innerElements = xml.getInnerElements(element, elementName);
assert(innerElements.length > 0);
for (const innerElement of innerElements) {
if (xml.hasInnerText(innerElement)) {
this.children.push(xml.getInnerText(innerElement));
}
else if (xml.isInnerElementText(innerElement, 'title')) {
assert(this.title === undefined);
this.title = new TitleDataModel(xml, innerElement);
}
else if (xml.hasInnerElement(innerElement, 'para')) {
this.children.push(new ParaDataModel(xml, innerElement));
}
else if (xml.hasInnerElement(innerElement, 'internal')) {
this.children.push(new InternalS2DataModel(xml, innerElement));
}
else if (xml.hasInnerElement(innerElement, 'sect3')) {
this.children.push(new Sect3DataModel(xml, innerElement));
}
else {
console.error(util.inspect(innerElement));
console.error(`${elementName} element:`, Object.keys(innerElement), 'not implemented yet in', this.constructor.name);
}
}
// ------------------------------------------------------------------------
// Process attributes.
if (xml.hasAttributes(element)) {
const attributesNames = xml.getAttributesNames(element);
for (const attributeName of attributesNames) {
if (attributeName === '@_id') {
this.id = xml.getAttributeStringValue(element, '@_id');
}
else {
console.error(util.inspect(element, { compact: false, depth: 999 }));
console.error(`${elementName} attribute:`, attributeName, 'not implemented yet in', this.constructor.name);
}
}
}
// ------------------------------------------------------------------------
// console.log(util.inspect(this, { compact: false, depth: 999 }))
}
}
// ----------------------------------------------------------------------------
// <xsd:complexType name="docSect3Type" mixed="true"> <-- Character data is allowed to appear between the child elements!
// <xsd:sequence>
// <xsd:element name="title" type="docTitleType" minOccurs="0" />
// <xsd:choice maxOccurs="unbounded">
// <xsd:element name="para" type="docParaType" minOccurs="0" maxOccurs="unbounded" />
// <xsd:element name="sect4" type="docSect4Type" minOccurs="0" maxOccurs="unbounded" />
// <xsd:element name="internal" type="docInternalS3Type" minOccurs="0" />
// </xsd:choice>
// </xsd:sequence>
// <xsd:attribute name="id" type="xsd:string" />
// </xsd:complexType>
export class AbstractDocSect3Type extends AbstractDataModelBase {
constructor(xml, element, elementName) {
super(elementName);
// Any sequence of them.
this.children = [];
// console.log(elementName, util.inspect(element, { compact: false, depth: 999 }))
// ------------------------------------------------------------------------
// Process elements.
const innerElements = xml.getInnerElements(element, elementName);
assert(innerElements.length > 0);
for (const innerElement of innerElements) {
if (xml.hasInnerText(innerElement)) {
this.children.push(xml.getInnerText(innerElement));
}
else if (xml.isInnerElementText(innerElement, 'title')) {
assert(this.title === undefined);
this.title = new TitleDataModel(xml, innerElement);
}
else if (xml.hasInnerElement(innerElement, 'para')) {
this.children.push(new ParaDataModel(xml, innerElement));
}
else if (xml.hasInnerElement(innerElement, 'internal')) {
this.children.push(new InternalS3DataModel(xml, innerElement));
}
else if (xml.hasInnerElement(innerElement, 'sect4')) {
this.children.push(new Sect4DataModel(xml, innerElement));
}
else {
console.error(util.inspect(innerElement));
console.error(`${elementName} element:`, Object.keys(innerElement), 'not implemented yet in', this.constructor.name);
}
}
// ------------------------------------------------------------------------
// Process attributes.
if (xml.hasAttributes(element)) {
const attributesNames = xml.getAttributesNames(element);
for (const attributeName of attributesNames) {
if (attributeName === '@_id') {
this.id = xml.getAttributeStringValue(element, '@_id');
}
else {
console.error(util.inspect(element, { compact: false, depth: 999 }));
console.error(`${elementName} attribute:`, attributeName, 'not implemented yet in', this.constructor.name);
}
}
}
// ------------------------------------------------------------------------
// console.log(util.inspect(this, { compact: false, depth: 999 }))
}
}
// ----------------------------------------------------------------------------
// <xsd:complexType name="docSect4Type" mixed="true"> <-- Character data is allowed to appear between the child elements!
// <xsd:sequence>
// <xsd:element name="title" type="docTitleType" minOccurs="0" />
// <xsd:choice maxOccurs="unbounded">
// <xsd:element name="para" type="docParaType" minOccurs="0" maxOccurs="unbounded" />
// <xsd:element name="sect5" type="docSect5Type" minOccurs="0" maxOccurs="unbounded" />
// <xsd:element name="internal" type="docInternalS4Type" minOccurs="0" />
// </xsd:choice>
// </xsd:sequence>
// <xsd:attribute name="id" type="xsd:string" />
// </xsd:complexType>
export class AbstractDocSect4Type extends AbstractDataModelBase {
constructor(xml, element, elementName) {
super(elementName);
// Any sequence of them.
this.children = [];
// console.log(elementName, util.inspect(element, { compact: false, depth: 999 }))
// ------------------------------------------------------------------------
// Process elements.
const innerElements = xml.getInnerElements(element, elementName);
assert(innerElements.length > 0);
for (const innerElement of innerElements) {
if (xml.hasInnerText(innerElement)) {
this.children.push(xml.getInnerText(innerElement));
}
else if (xml.isInnerElementText(innerElement, 'title')) {
assert(this.title === undefined);
this.title = new TitleDataModel(xml, innerElement);
}
else if (xml.hasInnerElement(innerElement, 'para')) {
this.children.push(new ParaDataModel(xml, innerElement));
}
else if (xml.hasInnerElement(innerElement, 'internal')) {
this.children.push(new InternalS4DataModel(xml, innerElement));
}
else if (xml.hasInnerElement(innerElement, 'sect5')) {
this.children.push(new Sect5DataModel(xml, innerElement));
}
else {
console.error(util.inspect(innerElement));
console.error(`${elementName} element:`, Object.keys(innerElement), 'not implemented yet in', this.constructor.name);
}
}
// ------------------------------------------------------------------------
// Process attributes.
if (xml.hasAttributes(element)) {
const attributesNames = xml.getAttributesNames(element);
for (const attributeName of attributesNames) {
if (attributeName === '@_id') {
this.id = xml.getAttributeStringValue(element, '@_id');
}
else {
console.error(util.inspect(element, { compact: false, depth: 999 }));
console.error(`${elementName} attribute:`, attributeName, 'not implemented yet in', this.constructor.name);
}
}
}
// ------------------------------------------------------------------------
// console.log(util.inspect(this, { compact: false, depth: 999 }))
}
}
// ----------------------------------------------------------------------------
// <xsd:complexType name="docSect5Type" mixed="true"> <-- Character data is allowed to appear between the child elements!
// <xsd:sequence>
// <xsd:element name="title" type="docTitleType" minOccurs="0" />
// <xsd:choice maxOccurs="unbounded">
// <xsd:element name="para" type="docParaType" minOccurs="0" maxOccurs="unbounded" />
// <xsd:element name="sect6" type="docSect6Type" minOccurs="0" maxOccurs="unbounded" />
// <xsd:element name="internal" type="docInternalS5Type" minOccurs="0" />
// </xsd:choice>
// </xsd:sequence>
// <xsd:attribute name="id" type="xsd:string" />
// </xsd:complexType>
export class AbstractDocSect5Type extends AbstractDataModelBase {
constructor(xml, element, elementName) {
super(elementName);
// Any sequence of them.
this.children = [];
// console.log(elementName, util.inspect(element, { compact: false, depth: 999 }))
// ------------------------------------------------------------------------
// Process elements.
const innerElements = xml.getInnerElements(element, elementName);
assert(innerElements.length > 0);
for (const innerElement of innerElements) {
if (xml.hasInnerText(innerElement)) {
this.children.push(xml.getInnerText(innerElement));
}
else if (xml.isInnerElementText(innerElement, 'title')) {
assert(this.title === undefined);
this.title = new TitleDataModel(xml, innerElement);
}
else if (xml.hasInnerElement(innerElement, 'para')) {
this.children.push(new ParaDataModel(xml, innerElement));
}
else if (xml.hasInnerElement(innerElement, 'internal')) {
this.children.push(new InternalS5DataModel(xml, innerElement));
}
else if (xml.hasInnerElement(innerElement, 'sect6')) {
this.children.push(new Sect6DataModel(xml, innerElement));
}
else {
console.error(util.inspect(innerElement));
console.error(`${elementName} element:`, Object.keys(innerElement), 'not implemented yet in', this.constructor.name);
}
}
// ------------------------------------------------------------------------
// Process attributes.
if (xml.hasAttributes(element)) {
const attributesNames = xml.getAttributesNames(element);
for (const attributeName of attributesNames) {
if (attributeName === '@_id') {
this.id = xml.getAttributeStringValue(element, '@_id');
}
else {
console.error(util.inspect(element, { compact: false, depth: 999 }));
console.error(`${elementName} attribute:`, attributeName, 'not implemented yet in', this.constructor.name);
}
}
}
// ------------------------------------------------------------------------
// console.log(util.inspect(this, { compact: false, depth: 999 }))
}
}
// ----------------------------------------------------------------------------
// <xsd:complexType name="docSect6Type" mixed="true"> <-- Character data is allowed to appear between the child elements!
// <xsd:sequence>
// <xsd:element name="title" type="docTitleType" minOccurs="0" />
// <xsd:choice maxOccurs="unbounded">
// <xsd:element name="para" type="docParaType" minOccurs="0" maxOccurs="unbounded" />
// <xsd:element name="internal" type="docInternalS6Type" minOccurs="0" />
// </xsd:choice>
// </xsd:sequence>
// <xsd:attribute name="id" type="xsd:string" />
// </xsd:complexType>
export class AbstractDocSect6Type extends AbstractDataModelBase {
constructor(xml, element, elementName) {
super(elementName);
// Any sequence of them.
this.children = [];
// console.log(elementName, util.inspect(element, { compact: false, depth: 999 }))
// ------------------------------------------------------------------------
// Process elements.
const innerElements = xml.getInnerElements(element, elementName);
assert(innerElements.length > 0);
for (const innerElement of innerElements) {
if (xml.hasInnerText(innerElement)) {
this.children.push(xml.getInnerText(innerElement));
}
else if (xml.isInnerElementText(innerElement, 'title')) {
assert(this.title === undefined);
this.title = new TitleDataModel(xml, innerElement);
}
else if (xml.hasInnerElement(innerElement, 'para')) {
this.children.push(new ParaDataModel(xml, innerElement));
}
else if (xml.hasInnerElement(innerElement, 'internal')) {
this.children.push(new InternalS6DataModel(xml, innerElement));
}
else {
console.error(util.inspect(innerElement));
console.error(`${elementName} element:`, Object.keys(innerElement), 'not implemented yet in', this.constructor.name);
}
}
// ------------------------------------------------------------------------
// Process attributes.
if (xml.hasAttributes(element)) {
const attributesNames = xml.getAttributesNames(element);
for (const attributeName of attributesNames) {
if (attributeName === '@_id') {
this.id = xml.getAttributeStringValue(element, '@_id');
}
else {
console.error(util.inspect(element, { compact: false, depth: 999 }));
console.error(`${elementName} attribute:`, attributeName, 'not implemented yet in', this.constructor.name);
}
}
}
// ------------------------------------------------------------------------
// console.log(util.inspect(this, { compact: false, depth: 999 }))
}
}
// ----------------------------------------------------------------------------
// <xsd:complexType name="docInternalType" mixed="true"> <-- Character data is allowed to appear between the child elements!
// <xsd:sequence>
// <xsd:element name="para" type="docParaType" minOccurs="0" maxOccurs="unbounded" />
// <xsd:element name="sect1" type="docSect1Type" minOccurs="0" maxOccurs="unbounded" />
// </xsd:sequence>
// </xsd:complexType>
export class AbstractDocInternalType extends AbstractDataModelBase {
constructor(xml, element, elementName) {
super(elementName);
// Any sequence of them.
this.children = [];
// console.log(elementName, util.inspect(element, { compact: false, depth: 999 }))
// ------------------------------------------------------------------------
// Process elements.
const innerElements = xml.getInnerElements(element, elementName);
assert(innerElements.length > 0);
for (const innerElement of innerElements) {
if (xml.hasInnerText(innerElement)) {
this.children.push(xml.getInnerText(innerElement));
}
else if (xml.hasInnerElement(innerElement, 'para')) {
this.children.push(new ParaDataModel(xml, innerElement));
}
else if (xml.hasInnerElement(innerElement, 'sect1')) {
this.children.push(new Sect1DataModel(xml, innerElement));
}
else {
console.error(util.inspect(innerElement));
console.error(`${elementName} element:`, Object.keys(innerElement), 'not implemented yet in', this.constructor.name);
}
}
// ------------------------------------------------------------------------
// Process attributes.
assert(!xml.hasAttributes(element));
// ------------------------------------------------------------------------
// console.log(util.inspect(this, { compact: false, depth: 999 }))
}
}
// ----------------------------------------------------------------------------
// <xsd:complexType name="docInternalS1Type" mixed="true"> <-- Character data is allowed to appear between the child elements!
// <xsd:sequence>
// <xsd:element name="para" type="docParaType" minOccurs="0" maxOccurs="unbounded" />
// <xsd:element name="sect2" type="docSect2Type" minOccurs="0" maxOccurs="unbounded" />
// </xsd:sequence>
// </xsd:complexType>
export class AbstractDocInternalS1Type extends AbstractDataModelBase {
constructor(xml, element, elementName) {
super(elementName);
// Any sequence of them.
this.children = [];
// console.log(elementName, util.inspect(element, { compact: false, depth: 999 }))
// ------------------------------------------------------------------------
// Process elements.
const innerElements = xml.getInnerElements(element, elementName);
assert(innerElements.length > 0);
for (const innerElement of innerElements) {
if (xml.hasInnerText(innerElement)) {
this.children.push(xml.getInnerText(innerElement));
}
else if (xml.hasInnerElement(innerElement, 'para')) {
this.children.push(new ParaDataModel(xml, innerElement));
}
else if (xml.hasInnerElement(innerElement, 'sect2')) {
this.children.push(new Sect2DataModel(xml, innerElement));
}
else {
console.error(util.inspect(innerElement));
console.error(`${elementName} element:`, Object.keys(innerElement), 'not implemented yet in', this.constructor.name);
}
}
// ------------------------------------------------------------------------
// Process attributes.
assert(!xml.hasAttributes(element));
// ------------------------------------------------------------------------
// console.log(util.inspect(this, { compact: false, depth: 999 }))
}
}
// ----------------------------------------------------------------------------
// <xsd:complexType name="docInternalS2Type" mixed="true"> <-- Character data is allowed to appear between the child elements!
// <xsd:sequence>
// <xsd:element name="para" type="docParaType" minOccurs="0" maxOccurs="unbounded" />
// <xsd:element name="sect3" type="docSect3Type" minOccurs="0" maxOccurs="unbounded" />
// </xsd:sequence>
// </xsd:complexType>
export class AbstractDocInternalS2Type extends AbstractDataModelBase {
constructor(xml, element, elementName) {
super(elementName);
// Any sequence of them.
this.children = [];
// console.log(elementName, util.inspect(element, { compact: false, depth: 999 }))
// ------------------------------------------------------------------------
// Process elements.
const innerElements = xml.getInnerElements(element, elementName);
assert(innerElements.length > 0);
for (const innerElement of innerElements) {
if (xml.hasInnerText(innerElement)) {
this.children.push(xml.getInnerText(innerElement));
}
else if (xml.hasInnerElement(innerElement, 'para')) {
this.children.push(new ParaDataModel(xml, innerElement));
}
else if (xml.hasInnerElement(innerElement, 'sect3')) {
this.children.push(new Sect3DataModel(xml, innerElement));
}
else {
console.error(util.inspect(innerElement));
console.error(`${elementName} element:`, Object.keys(innerElement), 'not implemented yet in', this.constructor.name);
}
}
// ------------------------------------------------------------------------
// Process attributes.
assert(!xml.hasAttributes(element));
// ------------------------------------------------------------------------
// console.log(util.inspect(this, { compact: false, depth: 999 }))
}
}
// ----------------------------------------------------------------------------
// <xsd:complexType name="docInternalS3Type" mixed="true"> <-- Character data is allowed to appear between the child elements!
// <xsd:sequence>
// <xsd:element name="para" type="docParaType" minOccurs="0" maxOccurs="unbounded" />
// <xsd:element name="sect4" type="docSect4Type" minOccurs="0" maxOccurs="unbounded" />
// </xsd:sequence>
// </xsd:complexType>
export class AbstractDocInternalS3Type extends AbstractDataModelBase {
constructor(xml, element, elementName) {
super(elementName);
// Any sequence of them.
this.children = [];
// console.log(elementName, util.inspect(element, { compact: false, depth: 999 }))
// ------------------------------------------------------------------------
// Process elements.
const innerElements = xml.getInnerElements(element, elementName);
assert(innerElements.length > 0);
for (const innerElement of innerElements) {
if (xml.hasInnerText(innerElement)) {
this.children.push(xml.getInnerText(innerElement));
}
else if (xml.hasInnerElement(innerElement, 'para')) {
this.children.push(new ParaDataModel(xml, innerElement));
}
else if (xml.hasInnerElement(innerElement, 'sect4')) {
this.children.push(new Sect4DataModel(xml, innerElement));
}
else {
console.error(util.inspect(innerElement));
console.error(`${elementName} element:`, Object.keys(innerElement), 'not implemented yet in', this.constructor.name);
}
}
// ------------------------------------------------------------------------
// Process attributes.
assert(!xml.hasAttributes(element));
// ------------------------------------------------------------------------
// console.log(util.inspect(this, { compact: false, depth: 999 }))
}
}
// ----------------------------------------------------------------------------
// <xsd:complexType name="docInternalS4Type" mixed="true"> <-- Character data is allowed to appear between the child elements!
// <xsd:sequence>
// <xsd:element name="para" type="docParaType" minOccurs="0" maxOccurs="unbounded" />
// <xsd:element name="sect5" type="docSect5Type" minOccurs="0" maxOccurs="unbounded" />
// </xsd:sequence>
// </xsd:complexType>
export class AbstractDocInternalS4Type extends AbstractDataModelBase {
constructor(xml, element, elementName) {
super(elementName);
// Any sequence of them.
this.children = [];
// console.log(elementName, util.inspect(element, { compact: false, depth: 999 }))
// ------------------------------------------------------------------------
// Process elements.
const innerElements = xml.getInnerElements(element, elementName);
assert(innerElements.length > 0);
for (const innerElement of innerElements) {
if (xml.hasInnerText(innerElement)) {
this.children.push(xml.getInnerText(innerElement));
}
else if (xml.hasInnerElement(innerElement, 'para')) {
this.children.push(new ParaDataModel(xml, innerElement));
}
else if (xml.hasInnerElement(innerElement, 'sect5')) {
this.children.push(new Sect5DataModel(xml, innerElement));
}
else {
console.error(util.inspect(innerElement));
console.error(`${elementName} element:`, Object.keys(innerElement), 'not implemented yet in', this.constructor.name);
}
}
// ------------------------------------------------------------------------
// Process attributes.
assert(!xml.hasAttributes(element));
// ------------------------------------------------------------------------
// console.log(util.inspect(this, { compact: false, depth: 999 }))
}
}
// ----------------------------------------------------------------------------
// WARNING: should be "sect6"
// <xsd:complexType name="docInternalS5Type" mixed="true"> <-- Character data is allowed to appear between the child elements!
// <xsd:sequence>
// <xsd:element name="para" type="docParaType" minOccurs="0" maxOccurs="unbounded" />
// <xsd:element name="sect5" type="docSect6Type" minOccurs="0" maxOccurs="unbounded" />
// </xsd:sequence>
// </xsd:complexType>
export class AbstractDocInternalS5Type extends AbstractDataModelBase {
constructor(xml, element, elementName) {
super(elementName);
// Any sequence of them.
this.children = [];
// console.log(elementName, util.inspect(element, { compact: false, depth: 999 }))
// ------------------------------------------------------------------------
// Process elements.
const innerElements = xml.getInnerElements(element, elementName);
assert(innerElements.length > 0);
for (const innerElement of innerElements) {
if (xml.hasInnerText(innerElement)) {
this.children.push(xml.getInnerText(innerElement));
}
else if (xml.hasInnerElement(innerElement, 'para')) {
this.children.push(new ParaDataModel(xml, innerElement));
}
else if (xml.hasInnerElement(innerElement, 'sect6')) {
this.children.push(new Sect6DataModel(xml, innerElement));
}
else {
console.error(util.inspect(innerElement));
console.error(`${elementName} element:`, Object.keys(innerElement), 'not implemented yet in', this.constructor.name);
}
}
// ------------------------------------------------------------------------
// Process attributes.
assert(!xml.hasAttributes(element));
// ------------------------------------------------------------------------
// console.log(util.inspect(this, { compact: false, depth: 999 }))
}
}
// ----------------------------------------------------------------------------
// <xsd:complexType name="docInternalS6Type" mixed="true"> <-- Character data is allowed to appear between the child elements!
// <xsd:sequence>
// <xsd:element name="para" type="docParaType" minOccurs="0" maxOccurs="unbounded" />
// </xsd:sequence>
// </xsd:complexType>
export class AbstractDocInternalS6Type extends AbstractDataModelBase {
constructor(xml, element, elementName) {
super(elementName);
// Any sequence of them.
this.children = [];
// console.log(elementName, util.inspect(element, { compact: false, depth: 999 }))
// ------------------------------------------------------------------------
// Process elements.
const innerElements = xml.getInnerElements(element, elementName);
assert(innerElements.length > 0);
for (const innerElement of innerElements) {
if (xml.hasInnerText(innerElement)) {
this.children.push(xml.getInnerText(innerElement));
}
else if (xml.hasInnerElement(innerElement, 'para')) {
this.children.push(new ParaDataModel(xml, innerElement));
}
else {
console.error(util.inspect(innerElement));
console.error(`${elementName} element:`, Object.keys(innerElement), 'not implemented yet in', this.constructor.name);
}
}
// ------------------------------------------------------------------------
// Process attributes.
assert(!xml.hasAttributes(element));
// ------------------------------------------------------------------------
// console.log(util.inspect(this, { compact: false, depth: 999 }))
}
}
function parseDocTitleCmdGroup(xml, element, elementName) {
const children = [];
// console.log(elementName, util.inspect(element, { compact: false, depth: 999 }))
if (xml.hasInnerElement(element, 'bold')) {
children.push(new BoldDataModel(xml, element));
}
else if (xml.hasInnerElement(element, 'emphasis')) {
children.push(new EmphasisDataModel(xml, element));
}
else if (xml.hasInnerElement(element, 'underline')) {
children.push(new UnderlineDataModel(xml, element));
}
else if (xml.hasInnerElement(element, 'computeroutput')) {
children.push(new ComputerOutputDataModel(xml, element));
}
else if (xml.hasInnerElement(element, 'ref')) {
children.push(new RefDataModel(xml, element));
}
else if (xml.hasInnerElement(element, 'linebreak')) {
children.push(new LineBreakDataModel(xml, element));
}
else if (xml.hasInnerElement(element, 'ulink')) {
children.push(new UlinkDataModel(xml, element));
}
else if (xml.hasInnerElement(element, 'anchor')) {
children.push(new AnchorDataModel(xml, element));
}
else if (xml.hasInnerElement(element, 'image')) {
children.push(new ImageDataModel(xml, element));
}
else if (xml.hasInnerElement(element, 'formula')) {
children.push(new FormulaDataModel(xml, element));
// Substring elements.
}
else if (xml.hasInnerElement(element, 'nzwj')) {
children.push(new NzwjDocMarkupDataModel(xml, element));
}
else if (xml.hasInnerElement(element, 'zwj')) {
children.push(new ZwjDocMarkupDataModel(xml, element));
}
else if (xml.hasInnerElement(element, 'ndash')) {
children.push(new NdashDocMarkupDataModel(xml, element));
}
else if (xml.hasInnerElement(element, 'mdash')) {
children.push(new MdashDocMarkupDataModel(xml, element));
}
else if (xml.hasInnerElement(element, 'lsquo')) {
children.push(new LsquoDocMarkupDataModel(xml, element));
}
else if (xml.hasInnerElement(element, 'rsquo')) {
children.push(new RsquoDocMarkupDataModel(xml, element));
}
else {
console.error(util.inspect(element, { compact: false, depth: 999 }));
console.error(`${elementName} element:`, Object.keys(element), 'not implemented yet by parseDocTitleCmdGroup()');
}
return children;
}
// ----------------------------------------------------------------------------
// <xsd:complexType name="docTitleType" mixed="true"> <-- Character data is allowed to appear between the child elements!
// <xsd:group ref="docTitleCmdGroup" minOccurs="0" maxOccurs="unbounded" />
// </xsd:complexType>
export class AbstractDocTitleType extends AbstractDataModelBase {
constructor(xml, element, elementName) {
super(elementName);
// Any sequence of them.
this.children = [];
// console.log(elementName, util.inspect(element, { compact: false, depth: 999 }))
// ------------------------------------------------------------------------
// Process elements.
const innerElements = xml.getInnerElements(element, elementName);
assert(innerElements.length > 0);
for (const innerElement of innerElements) {
if (xml.hasInnerText(innerElement)) {
this.children.push(xml.getInnerText(innerElement));
}
else {
this.children.push(...parseDocTitleCmdGroup(xml, innerElement, elementName));
}
}
// ----------------------------------------------------