@@ -150,65 +150,77 @@ pip install --upgrade git+https://${GH_TOKEN}@github.com/squidfunk/mkdocs-materi
150
150
151
151
[ upgrade guide ] : ../upgrade.md
152
152
153
- ## Caveats
153
+ ## Built-in plugins
154
154
155
- This section describes some aspects to consider when using Insiders together
156
- with Material for MkDocs to ensure that users without access to Insiders can
157
- still build your documentation.
155
+ When you're using built-in plugins that are solely available via Insiders,
156
+ outside contributors won't be able to build your documentation project on their
157
+ local machine. This is the reason why we developed the [ built-in group plugin]
158
+ that allows to conditionally load plugins.
158
159
159
- ### Built-in plugins
160
+ [ ^ 1 ] :
161
+ Previously we recommended to use [ configuration inheritance] to work around
162
+ this limitations, but the brand new [ built-in group plugin] is a much better
163
+ approach, as it allows you to use a single configuration file for building
164
+ your project with the community edition and Insiders version of Material
165
+ for MkDocs.
160
166
161
- When using built-in plugins that are solely available via Insiders, it might be
162
- necessary to split the ` mkdocs.yml ` configuration into a base configuration, and
163
- one with plugin overrides. Note that this is a limitation of MkDocs, which can
164
- be mitigated by using [ configuration inheritance] :
167
+ [ built-in group plugin ] : #built-in-group-plugin
168
+ [ configuration inheritance ] : https://www.mkdocs.org/user-guide/configuration/#configuration-inheritance
165
169
166
- === ":octicons-file-code-16: ` mkdocs.insiders.yml ` "
170
+ ### Built-in group plugin
167
171
168
- ``` yaml
169
- INHERIT: mkdocs.yml
170
- plugins:
171
- - search
172
- - social
173
- - tags
174
- ```
172
+ [ :octicons-tag-24: 9.3.0] [ Group plugin support ] ·
173
+ :octicons-cpu-24: Plugin ·
174
+ :octicons-beaker-24: Experimental
175
175
176
- === ":octicons-file-code-16: ` mkdocs.yml ` "
176
+ The built-in group plugin adds support for conditionally loading plugins based
177
+ on environments. This makes enabling and disabling of multiple plugins much
178
+ simpler, as you can group them into logical units and enable or disable them
179
+ with an [ environment variable] :
177
180
178
- ``` yaml
179
- # Configuration with everything except Insiders plugins
180
- ```
181
+ ``` yaml
182
+ plugins :
183
+ - group :
184
+ enabled : !ENV CI
185
+ plugins :
186
+ - optimize
187
+ - minify
188
+ ` ` `
181
189
182
- Now, when you're in an environment with access to Insiders (e.g. in your CI
183
- pipeline), you can build your documentation project with the following lines:
190
+ [` enabled`](#+group.enabled){ # +group.enabled }
184
191
185
- ```
186
- mkdocs build --config-file mkdocs.insiders.yml
187
- ```
192
+ : :octicons-milestone-24 : Default: `false` – This option specifies whether
193
+ the plugin is enabled when building your project. By default, the plugin is
194
+ disabled, so you can use an [environment variable] :
188
195
189
- !!! tip "Sharing plugin and extension configuration"
196
+ ` ` ` yaml
197
+ plugins:
198
+ - group:
199
+ enabled: !ENV CI
200
+ ` ` `
190
201
191
- If you want to share `plugins` or `markdown_extensions` between both
192
- configuration files `mkdocs.insiders.yml` and `mkdocs.yml`, you can use
193
- the alternative key-value syntax in both files. The above example would
194
- then look like:
202
+ Now, If you invoke MkDocs with that environment variable (or export the
203
+ environment variable before invoking MkDocs), the plugin will be enabled :
195
204
196
- === ":octicons-file-code-16: `mkdocs.insiders.yml`"
205
+ ` ` ` sh
206
+ CI=true mkdocs build
207
+ ` ` `
197
208
198
- ``` yaml
199
- INHERIT: mkdocs.yml
200
- plugins:
201
- social: {}
202
- ```
209
+ [`plugins`](#+group.plugins){ # +group.plugins }
203
210
204
- === ":octicons-file-code-16: `mkdocs.yml`"
211
+ : :octicons-milestone-24 : Default: _none_ – This option specifies the plugins
212
+ that the group plugin should load when enabled. Note that the plugins must
213
+ be specified as a list, even if there's only one plugin :
205
214
206
- ``` yaml
207
- # Additional configuration above
208
- plugins:
209
- search: {}
210
- tags: {}
211
- ```
215
+ ` ` ` yaml
216
+ plugins:
217
+ - group:
218
+ plugins:
219
+ - optimize
220
+ - minify
221
+ ` ` `
212
222
223
+ The syntax is exactly the same as for all other plugins.
213
224
214
- [ configuration inheritance ] : https://www.mkdocs.org/user-guide/configuration/#configuration-inheritance
225
+ [Group plugin support] : https://github.com/squidfunk/mkdocs-material/releases/tag/9.3.0
226
+ [environment variable] : https://www.mkdocs.org/user-guide/configuration/#environment-variables
0 commit comments