内置群组插件¶
¥Built-in group plugin¶
组插件允许将插件分组为逻辑单元,以便使用环境变量有条件地为特定环境启用或禁用它们,例如,在持续集成(CI)期间构建项目时仅启用一部分插件。
¥The group plugin allows to group plugins into logical units to conditionally enable or disable them for specific environments with the use of environment variables, e.g., to only enable a subset of plugins when building your project during continuous integration (CI).
客观的¶
¥Objective¶
工作原理¶
¥How it works¶
该插件会以条件方式延迟加载该组中的所有插件,当且仅当该组启用时,这意味着当该组禁用时,该插件不会增加任何开销。这也意味着,只有在启用该组时才需要安装分组内的插件。
¥The plugin conditionally and lazily loads all plugins that are part of a group if and only if the group is enabled, which means that the plugin doesn't add any overhead when the group is disabled. It also means that the grouped plugins only need to be installed when the group is enabled.
组中的插件将按照与在插件列表顶层定义的顺序相同的顺序执行。因此,顺序得以保留且具有确定性。
¥The plugins that are part of the group are executed in the same order as if they were defined at the top-level in the list of plugins. Thus, order is preserved and deterministic.
何时使用¶
¥When to use it¶
每当您使用仅在特定环境中需要的多个插件时(例如,在持续集成(CI)期间构建项目时),该插件是简化配置的完美实用程序,因为它无需将配置拆分为多个文件。
¥Whenever you're using multiple plugins that are only required in specific environments, e.g., when building your project during continuous integration (CI), the plugin is the perfect utility for making configuration simpler, as it removes the need for splitting configuration into multiple files.
它可以与任何内置或第三方插件一起使用。
¥It can be used with any built-in or third-party plugin.
配置¶
¥Configuration¶
9.3.0组 – 内置
与所有内置插件一样,组插件的使用也非常简单。只需将以下几行添加到mkdocs.yml ,然后将插件拆分成逻辑单元即可:
¥As with all built-in plugins, getting started with the group plugin is straightforward. Just add the following lines to mkdocs.yml, and start splitting plugins into logical units:
该组插件内置于 Material for MkDocs 中,无需安装。
¥The group plugin is built into Material for MkDocs and doesn't need to be installed.
一般的¶
¥General¶
可用的设置如下:
¥The following settings are available:
enabled¶
¥enabled¶
9.3.0错误
¥9.3.0 false
使用此设置在构建项目时启用或禁用该插件。该插件的行为与所有其他内置插件不同 -默认情况下处于禁用状态。要启用某个组,请使用:
¥Use this setting to enable or disable the plugin when building your project. The plugin behaves differently than all other built-in plugins – it is disabled by default. To enable a group, use:
如果您只想使用组插件来更好地组织,并且始终希望启用其中的插件,请使用:
plugins: - group: enabled: trueplugins: - group: enabled: trueplugins: - group: enabled: true插件: -组:启用:true
默认禁用插件的决定是为了简化环境变量的使用,因为这样就不需要为环境变量提供默认值。
¥If you only want to use the group plugin for better organization and always want to enable the plugins that are part of it, use:
¥The decision to disable the plugin by default was made to simplify the usage of environment variables, as it removes the need to provide a default value for an environment variable.
plugins¶
¥plugins¶
9.3.0
¥Now, when building your project, you can enable a group by setting the environment variable:
使用此设置列出属于该组的插件。其语法与插件设置完全相同,因此您只需复制要分组的插件列表即可,例如:
这里提到的插件仅用于说明目的。
¥Use this setting to list the plugins that are part of the group. The syntax is exactly the same as for the plugins setting, so you can simply copy the list of plugins that you want to group, e.g: