@@ -46,7 +46,9 @@ for await (const dir of directories) {
46
46
if ( dir . isDirectory ( ) && dir . name !== '_template' ) {
47
47
const pluginName = dir . name ;
48
48
const pluginDir = path . join ( pluginsDir , pluginName ) ;
49
- const plugin : Plugin = ( await import ( path . join ( pluginDir , 'index.ts' ) ) ) . default ;
49
+ const mod = await import ( path . join ( pluginDir , 'index.ts' ) ) ;
50
+ const plugin : Plugin = mod . default ;
51
+ const docs : undefined | { entry ?: string [ ] ; production ?: string [ ] } = mod . docs ;
50
52
51
53
const { title, enablers, note, args, config, entry, production, project } = plugin ;
52
54
@@ -57,7 +59,10 @@ for await (const dir of directories) {
57
59
const defaults : Record < string , string [ ] > = { } ;
58
60
if ( config && config . length > 0 ) defaults . config = config ;
59
61
if ( entry && entry . length > 0 ) defaults . entry = entry ;
62
+ if ( docs ?. entry && docs . entry . length > 0 ) defaults . entry = [ ...( defaults . entry ?? [ ] ) , ...docs . entry ] ;
60
63
if ( production && production . length > 0 ) defaults . entry = [ ...( defaults . entry ?? [ ] ) , ...production ] ;
64
+ if ( docs ?. production && docs . production . length > 0 )
65
+ defaults . entry = [ ...( defaults . entry ?? [ ] ) , ...docs . production ] ;
61
66
if ( project && project . length > 0 ) defaults . project = project ;
62
67
63
68
const hasDefaultConfig = Object . values ( defaults ) . some ( v => v . length > 0 ) ;
@@ -84,11 +89,12 @@ for await (const dir of directories) {
84
89
const defaultConfig = hasDefaultConfig
85
90
? [
86
91
u ( 'heading' , { depth : 2 } , [ u ( 'text' , 'Default configuration' ) ] ) ,
87
- ...parseFragment ( 'If enabled, this configuration is added automatically:' ) ,
92
+ ...parseFragment ( 'If this plugin is enabled, the following configuration is added automatically:' ) ,
88
93
u ( 'code' , {
89
94
lang : 'json' , // TODO How to set attributes/properties/props properly?
90
95
value : JSON . stringify ( { [ pluginName ] : defaults } , null , 2 ) ,
91
96
} ) ,
97
+ ...parseFragment ( 'Depending on local configuration, plugins may modify the defaults as shown.' ) ,
92
98
...parseFragment ( 'Custom `config` or `entry` options override default values, they are not merged.' ) ,
93
99
...parseFragment (
94
100
'See [Plugins](../../explanations/plugins) for more details about plugins and their `entry` and `config` options.'
0 commit comments