Skip to content

Commit 0ba4cf1

Browse files
committed
refactor(*): bump typedoc and read templateString from options
1 parent 11aa16a commit 0ba4cf1

File tree

5 files changed

+101
-83
lines changed

5 files changed

+101
-83
lines changed

index.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import * as process from 'process';
22
import * as fs from 'fs-extra';
33

4-
import { Application } from 'typedoc'
4+
import { Application, Converter, Renderer } from 'typedoc'
55
import { ConvertComponent } from './components/convert-component';
66
import { RenderComponenet } from './components/render-component';
77
import { Constants } from './utils/constants';
8-
import { GlobalFuncs } from './utils/global-funcs';
98
import { HardcodedStrings } from './utils/template-strings';
109
import { ThemeComponent } from './components/theme-component';
1110
import { pluginOptions } from './utils/options';
@@ -22,6 +21,7 @@ export function load(PluginHost: Application) {
2221
let startConverter = false;
2322
let startRenderer = false;
2423
const processArgs = process.argv;
24+
2525
/**
2626
* Determines it it is necessary to run Conversion or Render process based on the
2727
* Command line arguments(Options).
@@ -61,23 +61,24 @@ export function load(PluginHost: Application) {
6161
* Register theme component.
6262
*/
6363
new ThemeComponent(app);
64-
// app.renderer.addComponent('theme-component', new ThemeComponent(app.renderer));
65-
registerHardcodedTemplateStrings(processArgs);
66-
}
6764

68-
/**
69-
* Build the Cache containing all localized template strings.
70-
*/
71-
function registerHardcodedTemplateStrings(options) {
72-
const shellStringsFilePath = GlobalFuncs.getCmdLineArgumentValue(options, Constants.TEMPLATE_STRINGS_OPTION);
73-
const local = GlobalFuncs.getCmdLineArgumentValue(options, Constants.LOCALIZE_OPTION);
65+
/**
66+
* Build the Cache containing all localized template strings.
67+
*/
68+
const registerTemplateStrings = () => {
69+
const shellStringsFilePath = app.options.getValue(Constants.TEMPLATE_STRINGS_OPTION);
70+
const locale = app.options.getValue(Constants.LOCALIZE_OPTION) as string;
71+
72+
if (!shellStringsFilePath || !locale) {
73+
return;
74+
}
7475

75-
if (!shellStringsFilePath || !local) {
76-
return;
76+
const templateStrings = fs.readJsonSync(shellStringsFilePath);
77+
78+
HardcodedStrings.setLocal(locale);
79+
HardcodedStrings.setTemplateStrings(templateStrings);
7780
}
7881

79-
const templateStrings = fs.readJsonSync(shellStringsFilePath);
80-
81-
HardcodedStrings.setLocal(local);
82-
HardcodedStrings.setTemplateStrings(templateStrings);
83-
}
82+
app.converter.on(Converter.EVENT_RESOLVE, registerTemplateStrings);
83+
app.renderer.on(Renderer.EVENT_BEGIN, registerTemplateStrings);
84+
}

package-lock.json

Lines changed: 77 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"devDependencies": {
2828
"@types/node": "^18.11.0",
29-
"typedoc": "^0.23.21",
30-
"typescript": "^4.9.5"
29+
"typedoc": "^0.25.3",
30+
"typescript": "^5.2.2"
3131
}
3232
}

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
"types": [
2222
"node"
2323
], /* Type declaration files to be included in compilation. */
24-
"esModuleInterop": false, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
24+
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
2525
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
2626

2727
/* Experimental Options */
2828
"experimentalDecorators": true /* Enables experimental support for ES7 decorators. */
2929
}
30-
}
30+
}

utils/template-strings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ export class HardcodedStrings {
2424
public static getTemplateStrings(): string {
2525
return this.templateStrings;
2626
}
27-
}
27+
}

0 commit comments

Comments
 (0)