mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-11-25 13:11:36 +00:00
feat(docs): add the documentation site
- Astro and Starlight site in docs/ for https://fairrootgroup.github.io/FairMQ/ - 64 pages in eight groups: start, concepts, guides, shared memory, examples, tools, reference and project - API reference and source browser from the Doxygen XML of fairmq/ - Code samples are snippets of the repository files; the build fails when a snippet does not match - Option tables take the names, types and defaults from the code - Interactive diagrams: state machine, zero-copy transfer, region acknowledgements, session objects, topology and channel anatomy - The 404 page sends the URLs of the Doxygen site to the new pages - scripts/check-pages.mjs checks pages, snippets and links without a build; scripts/check-links.mjs checks all links in dist/ Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
68
docs/scripts/xml.mjs
Normal file
68
docs/scripts/xml.mjs
Normal file
@@ -0,0 +1,68 @@
|
||||
// Small helpers around fast-xml-parser in `preserveOrder` mode.
|
||||
// A node is either { '#text': string } or { tag: [children], ':@': { attributes } }.
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { XMLParser } from 'fast-xml-parser';
|
||||
|
||||
const parser = new XMLParser({
|
||||
preserveOrder: true,
|
||||
ignoreAttributes: false,
|
||||
attributeNamePrefix: '',
|
||||
trimValues: false,
|
||||
parseTagValue: false,
|
||||
parseAttributeValue: false,
|
||||
processEntities: true,
|
||||
htmlEntities: true,
|
||||
});
|
||||
|
||||
export function parseXmlFile(file) {
|
||||
return parser.parse(readFileSync(file, 'utf8'));
|
||||
}
|
||||
|
||||
export function tagOf(node) {
|
||||
for (const k of Object.keys(node)) if (k !== ':@') return k;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function isText(node) {
|
||||
return Object.prototype.hasOwnProperty.call(node, '#text');
|
||||
}
|
||||
|
||||
export function kids(node) {
|
||||
if (!node) return [];
|
||||
const t = tagOf(node);
|
||||
return t && t !== '#text' && Array.isArray(node[t]) ? node[t] : [];
|
||||
}
|
||||
|
||||
export function attr(node, name) {
|
||||
return node && node[':@'] ? node[':@'][name] : undefined;
|
||||
}
|
||||
|
||||
export function children(node, name) {
|
||||
return kids(node).filter((n) => tagOf(n) === name);
|
||||
}
|
||||
|
||||
export function child(node, name) {
|
||||
return kids(node).find((n) => tagOf(n) === name);
|
||||
}
|
||||
|
||||
export function find(nodes, name) {
|
||||
for (const n of nodes) if (tagOf(n) === name) return n;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/** Plain text of a node, with Doxygen's <sp/> as spaces. */
|
||||
export function textOf(node) {
|
||||
if (!node) return '';
|
||||
if (isText(node)) return String(node['#text']);
|
||||
const t = tagOf(node);
|
||||
if (t === 'sp') return ' ';
|
||||
return kids(node).map(textOf).join('');
|
||||
}
|
||||
|
||||
export function escapeHtml(s) {
|
||||
return String(s)
|
||||
.replaceAll('&', '&')
|
||||
.replaceAll('<', '<')
|
||||
.replaceAll('>', '>')
|
||||
.replaceAll('"', '"');
|
||||
}
|
||||
Reference in New Issue
Block a user