@xpack/docusaurus-plugin-doxygen
Version:
A Docusaurus plugin to integrate Doxygen into a Docusaurus project.
111 lines • 4.73 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 { ElementLinesRendererBase } from './element-renderer-base.js';
// ----------------------------------------------------------------------------
export class DocS1TypeLinesRenderer extends ElementLinesRendererBase {
renderToMdxLines(element) {
// console.log(util.inspect(element, { compact: false, depth: 999 }))
const lines = [];
// Ignore the H1 header, it is generated automatically by Docusaurus.
// const title = this.workspace.renderElementToMdxText(element.title).trim().replace(/\.$/, '')
// if (title.length > 0) {
// lines.push('')
// lines.push(`## ${title} {#details}`)
// } else {
// lines.push('')
// lines.push('<Link id="details" />')
// }
if (element.title !== undefined && this.workspace.pluginOptions.verbose) {
// console.log(element)
// Note that `.md` files have the sections promoted one level,
// so `## RTOS` is generated as `sect1`.
console.warn('H1 header', this.workspace.renderElementToMdxText(element.title), 'ignored');
}
// Add the anchor referred by the 'More...' link.
// TODO: investigate why this does not work.
lines.push('<Link id="details" />');
lines.push('');
lines.push(...this.workspace.renderElementsToMdxLines(element.children));
return lines;
}
}
export class DocS2TypeLinesRenderer extends ElementLinesRendererBase {
renderToMdxLines(element) {
// console.log(util.inspect(element, { compact: false, depth: 999 }))
const lines = [];
const title = this.workspace.renderElementToMdxText(element.title).trim().replace(/\.$/, '');
if (title.length > 0) {
lines.push('');
lines.push(`## ${title}`);
}
lines.push('');
lines.push(...this.workspace.renderElementsToMdxLines(element.children));
return lines;
}
}
export class DocS3TypeLinesRenderer extends ElementLinesRendererBase {
renderToMdxLines(element) {
// console.log(util.inspect(element, { compact: false, depth: 999 }))
const lines = [];
const title = this.workspace.renderElementToMdxText(element.title).trim().replace(/\.$/, '');
if (title.length > 0) {
lines.push('');
lines.push(`### ${title}`);
}
lines.push('');
lines.push(...this.workspace.renderElementsToMdxLines(element.children));
return lines;
}
}
export class DocS4TypeLinesRenderer extends ElementLinesRendererBase {
renderToMdxLines(element) {
// console.log(util.inspect(element, { compact: false, depth: 999 }))
const lines = [];
const title = this.workspace.renderElementToMdxText(element.title).trim().replace(/\.$/, '');
if (title.length > 0) {
lines.push('');
lines.push(`#### ${title}`);
}
lines.push('');
lines.push(...this.workspace.renderElementsToMdxLines(element.children));
return lines;
}
}
export class DocS5TypeLinesRenderer extends ElementLinesRendererBase {
renderToMdxLines(element) {
// console.log(util.inspect(element, { compact: false, depth: 999 }))
const lines = [];
const title = this.workspace.renderElementToMdxText(element.title).trim().replace(/\.$/, '');
if (title.length > 0) {
lines.push('');
lines.push(`##### ${title}`);
}
lines.push('');
lines.push(...this.workspace.renderElementsToMdxLines(element.children));
return lines;
}
}
export class DocS6TypeLinesRenderer extends ElementLinesRendererBase {
renderToMdxLines(element) {
// console.log(util.inspect(element, { compact: false, depth: 999 }))
const lines = [];
const title = this.workspace.renderElementToMdxText(element.title).trim().replace(/\.$/, '');
if (title.length > 0) {
lines.push('');
lines.push(`###### ${title}`);
}
lines.push('');
lines.push(...this.workspace.renderElementsToMdxLines(element.children));
return lines;
}
}
// ----------------------------------------------------------------------------
//# sourceMappingURL=docinternalstype.js.map