Skip to content

Commit

Permalink
Fix typedoc: Migrate to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
saberduck committed Nov 29, 2024
1 parent 4ad3e46 commit 38c8a85
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/typedoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
ARTIFACTORY_URL: https://repox.jfrog.io/artifactory
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Get vault secrets
id: secrets
uses: SonarSource/vault-action-wrapper@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
* You should have received a copy of the Sonar Source-Available License
* along with this program; if not, see https://sonarsource.com/license/ssal/
*/
const { Renderer } = require('typedoc');
import { Renderer } from 'typedoc';

module.exports.load = function load(app) {
export function load(app) {
app.renderer.on(Renderer.EVENT_PREPARE_INDEX, event => {
for (const [index, result] of event.searchResults.entries()) {
// To see what is available on a event.searchResults element, see the reflections.json in the generated files
Expand All @@ -34,7 +34,7 @@ module.exports.load = function load(app) {
// https://github.com/TypeStrong/typedoc/blob/56813c0cb201f0c248a0cc43ef6e7578d680191c/src/lib/output/plugins/JavascriptIndexPlugin.ts#L89
event.searchFieldWeights.parameters = 5;
});
};
}

/**
* Initialises object[propName] to ''
Expand Down
4 changes: 2 additions & 2 deletions typedoc/searchable-parameters-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "searchable-parameters-plugin",
"version": "1.0.0",
"description": "Plugin for Typedoc that makes functions searchable by parameter types",
"main": "index.js",
"main": "index.mjs",
"scripts": {
"setup": "node setup.js"
"setup": "node setup.mjs"
},
"keywords": [
"typedoc-plugin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@
*/
// typedoc looks for plugins in node_modules/, therefore we create a symlink to this folder in node_modules/

const fs = require('fs');
const path = require('path');
import fs from 'fs';
import path from 'path';
import url from 'url';

// Directory name of the current module
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));

const linkPath = path.join(__dirname, '..', '..', 'node_modules', 'searchable-parameters-plugin');
const targetPath = path.join(__dirname);

if (fs.existsSync(linkPath)) return;
fs.symlinkSync(targetPath, linkPath);
if (!fs.existsSync(linkPath)) {
fs.symlinkSync(targetPath, linkPath);
}

0 comments on commit 38c8a85

Please sign in to comment.