3
3
*
4
4
* @module core
5
5
*/
6
- import { getTranslatable } from '@plugin/internationalization/translatable .js' ;
6
+ import { setupInternationalization } from '@plugin/internationalization/index .js' ;
7
7
import { declarations } from '@plugin/options/index.js' ;
8
- import { resolvePackages } from '@plugin/renderer/packages .js' ;
9
- import { MarkdownRendererHooks , MarkdownTheme } from 'public-api .js' ;
8
+ import { render , setupRenderer } from '@plugin/renderer/index .js' ;
9
+ import { MarkdownRenderer } from '@plugin/types/index .js' ;
10
10
import {
11
11
Application ,
12
- Context ,
13
- Converter ,
14
12
DeclarationOption ,
15
- EventHooks ,
16
13
ParameterHint ,
17
14
ParameterType ,
18
15
} from 'typedoc' ;
19
- import { render } from './renderer/render.js' ;
20
16
21
17
/**
22
18
* The function that is called by TypeDoc to bootstrap the plugin.
@@ -27,13 +23,6 @@ import { render } from './renderer/render.js';
27
23
*
28
24
* This method is not intended to be consumed in any other context that via the `plugin` option.
29
25
*
30
- * The load functions:
31
- *
32
- * 1. Bootstrap the plugin options
33
- * 2. Configures markdown outputs
34
- * 3. Configures localization
35
- * 4. Applies any other behaviour
36
- *
37
26
* The module also exports anything that is available publicly.
38
27
*
39
28
*/
@@ -43,22 +32,13 @@ export function load(app: Application) {
43
32
* 1. Bootstrap options
44
33
* ====================
45
34
*/
46
-
47
- // Iterate over declaration definitions and to the container.
48
35
Object . entries ( declarations ) . forEach ( ( [ name , declaration ] ) => {
49
36
app . options . addDeclaration ( {
50
37
name,
51
38
...declaration ,
52
39
} as DeclarationOption ) ;
53
40
} ) ;
54
41
55
- app . renderer . defineTheme ( 'markdown' , MarkdownTheme ) ;
56
-
57
- /**
58
- * =============================
59
- * 2. Configure markdown outputs
60
- * =============================
61
- */
62
42
app . options . addDeclaration ( {
63
43
name : 'markdown' ,
64
44
outputShortcut : 'markdown' ,
@@ -68,48 +48,24 @@ export function load(app: Application) {
68
48
defaultValue : './docs' ,
69
49
} ) ;
70
50
71
- app . outputs . addOutput ( 'markdown' , async ( out , project ) => {
72
- await render ( app . renderer , project , out ) ;
73
- } ) ;
74
-
75
- app . outputs . setDefaultOutputName ( 'markdown' ) ;
76
-
77
- Object . defineProperty ( app . renderer , 'markdownHooks' , {
78
- value : new EventHooks < MarkdownRendererHooks , string > ( ) ,
79
- } ) ;
80
-
81
51
/**
82
- * =========================
83
- * 3 . Configure localization
84
- * =========================
52
+ * =============================
53
+ * 2 . Configure markdown outputs
54
+ * =============================
85
55
*/
86
-
87
- // Load the additional translations used by the theme for the selected language.
88
- app . converter . on ( Converter . EVENT_BEGIN , ( ) => {
89
- app . internationalization . addTranslations (
90
- app . options . getValue ( 'lang' ) ,
91
- { ...getTranslatable ( app ) } ,
92
- true ,
93
- ) ;
56
+ app . outputs . addOutput ( 'markdown' , async ( out , project ) => {
57
+ await render ( app . renderer as unknown as MarkdownRenderer , project , out ) ;
94
58
} ) ;
95
59
96
- /**
97
- * ============================
98
- * 4. Apply any other behaviour
99
- * ============================
100
- */
60
+ app . outputs . setDefaultOutputName ( 'markdown' ) ;
101
61
102
62
/**
103
- * Currently options set for packages are only stored on the converter and are destroyed before being passed to the {@link Renderer}.
104
- *
105
- * By intercepting the package options set in the converter and storing them on the renderer we can use them later in the theme.
106
- *
63
+ * =====================================
64
+ * 3. Setup up renderer and translations
65
+ * ======================================
107
66
*/
108
- app . converter . on ( Converter . EVENT_RESOLVE_END , ( context : Context ) => {
109
- if ( app . options . packageDir ) {
110
- resolvePackages ( app , context , app . options . packageDir ) ;
111
- }
112
- } ) ;
67
+ setupRenderer ( app ) ;
68
+ setupInternationalization ( app ) ;
113
69
}
114
70
115
71
/**
0 commit comments