chore: cleanup typedoc plugin (#2801)

* chore: added gitignore for typedoc plugin

* remove unnecessary files

* docs: added a note about building the plugin

* chore: added .yarn to gitignore

Co-authored-by: olivermrbl <oliver@mrbltech.com>
This commit is contained in:
Shahed Nasser
2022-12-14 19:48:48 +02:00
committed by GitHub
parent 6b73d087b6
commit c1659f81ac
4 changed files with 10 additions and 50 deletions

View File

@@ -0,0 +1,2 @@
dist
.yarn

View File

@@ -33,3 +33,11 @@ frontmatterData: {
pagesPattern: "internal\\.",
},
```
## Building the Plugin
Before using any command that makes use of this plugin, make sure to run the `build` command:
```bash
yarn build
```

View File

@@ -1,49 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.load = void 0;
const typedoc_1 = require("typedoc");
function load(app) {
app.options.addDeclaration({
name: "frontmatterData",
help: "An object of key-value pairs to be added to frontmatter",
type: typedoc_1.ParameterType.Mixed,
defaultValue: {},
validate: (value) => {
if (typeof value === 'string') {
//decode it with JSON to check if it's an object
value = JSON.parse(value);
}
if (!(typeof value === 'object' &&
!Array.isArray(value) &&
value !== null)) {
throw new Error("Value should be an object");
}
}
});
app.options.addDeclaration({
name: "pagesPattern",
help: "A string of pages pattern. The pattern will be tested using RegExp to determine whether the frontmatterData will be added or not.",
type: typedoc_1.ParameterType.String,
defaultValue: ""
});
app.renderer.on(typedoc_1.PageEvent.END, (page) => {
const patternStr = app.options.getValue("pagesPattern");
const pattern = new RegExp(patternStr);
let frontmatterData = app.options.getValue("frontmatterData");
if (typeof frontmatterData === 'string') {
frontmatterData = JSON.parse(frontmatterData);
}
const frontmatterDataEntries = Object.entries(frontmatterData);
if (!frontmatterDataEntries.length || !pattern.test(page.filename)) {
return;
}
let frontmatterStr = `---\n`;
for (const [key, value] of frontmatterDataEntries) {
frontmatterStr += `${key}: ${value}\n`;
}
frontmatterStr += `---\n\n`;
page.contents = frontmatterStr + page.contents;
});
}
exports.load = load;
//# sourceMappingURL=index.js.map

View File

@@ -1 +0,0 @@
{"version":3,"file":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