jose/tools/typedoc-replace-version.js
2021-08-20 12:01:17 +02:00

19 lines
609 B
JavaScript

const {
Converter: { EVENT_RESOLVE_BEGIN },
} = require("typedoc");
module.exports.load = function load(app) {
const gitRevision = app.options.getValue("gitRevision");
if (gitRevision && gitRevision !== "main") {
app.converter.on(EVENT_RESOLVE_BEGIN, ({ project: { reflections } }) => {
for (const key in reflections) {
const reflection = reflections[key];
if (reflection.comment && reflection.comment.tags) {
for (const tag of reflection.comment.tags) {
tag.text = tag.text.replace(/VERSION/g, gitRevision);
}
}
}
});
}
};