@@ -3,62 +3,62 @@ title: Built-in group plugin
33icon : material/format-list-group
44---
55
6- # Built-in group plugin
6+ # 内置群组插件
77
8- The group plugin allows to group plugins into logical units to conditionally
9- enable or disable them for specific environments with the use of
10- [ environment variables ] [ mkdocs.env ] , e.g., to only enable a subset of
11- plugins when [ building your project ] during continuous integration (CI).
8+ 组插件允许将插件有条件地分组到逻辑单元中
9+ 使用以下命令为特定环境启用或禁用它们
10+ [ 环境变量 ] [ mkdocs.env ] ,例如,仅启用
11+ 在持续集成(CI)期间 [ 构建项目 ] 时使用插件。
1212
1313 [ building your project ] : ../creating-your-site.md#building-your-site
1414
1515## Objective
1616
17- ### How it works
17+ ### 工作原理
1818
19- The plugin conditionally and lazily loads all plugins that are part of a group
20- if and only if the group is enabled, which means that the plugin doesn't add any
21- overhead when the group is disabled. It also means that the grouped plugins
22- only need to be installed when the group is enabled.
19+ 该插件有条件地延迟加载属于某个组的所有插件
20+ if and only if组已启用,这意味着插件不会添加任何
21+ 禁用组时的开销。这也意味着分组插件
22+ 仅在启用组时才需要安装。
2323
24- The plugins that are part of the group are executed in the same order as if
25- they were defined at the top-level in the list of [ ` plugins ` ] [ mkdocs.plugins ] .
26- Thus, order is preserved and deterministic.
24+ 属于该组的插件以相同的顺序执行,就像
25+ 它们是在 [ `plugins] [ mkdocs.plugins ] 列表的顶层定义的。
26+ 因此,秩序得以保留和确定。
2727
28- ### When to use it
28+ ### 何时使用
2929
30- Whenever you're using multiple plugins that are only required in specific
31- environments, e.g., when building your project during continuous integration
32- (CI), the plugin is the perfect utility for making configuration simpler, as it
33- removes the need for splitting configuration into multiple files.
30+ 每当您使用仅在特定情况下需要的多个插件时
31+ 环境,例如在持续集成期间构建项目时
32+ (CI),该插件是使配置更简单的完美工具,因为它
33+ 消除了将配置拆分为多个文件的需要。
3434
35- It can be used with any built-in or third-party plugin.
35+ 它可以与任何内置或第三方插件一起使用。
3636
37- ## Configuration
37+ ## 配置
3838
3939<!-- md:version 9.3.0 -->
4040<!-- md:plugin [group] – built-in -->
4141<!-- md:flag multiple -->
4242<!-- md:flag experimental -->
4343
44- As with all [ built-in plugins ] , getting started with the group plugin is
45- straightforward. Just add the following lines to ` mkdocs.yml ` , and start
46- splitting plugins into logical units:
44+ 与所有 [ 内置插件 ] 一样,开始使用组插件是
45+ 直截了当。只需将以下行添加到 ` mkdocs.yml ` 中,然后开始
46+ 将插件拆分为逻辑单元:
4747
4848``` yaml
4949plugins :
5050 - group
5151` ` `
5252
53- The group plugin is built into Material for MkDocs and doesn't need to be
54- installed.
53+ 组插件内置于MkDocs的Material中,不需要
54+ 安装。
5555
5656 [group]: group.md
5757 [built-in plugins]: index.md
5858
59- ### General
59+ ### 一般的
6060
61- The following settings are available:
61+ 以下设置可用:
6262
6363---
6464
@@ -67,31 +67,31 @@ The following settings are available:
6767<!-- md:version 9.3.0 -->
6868<!-- md:default ` false` -->
6969
70- Use this setting to enable or disable the plugin when [building your project].
71- The plugin behaves differently than all other built-in plugins – __it is
72- disabled by default__. To enable a group, use :
70+ 使用此设置可在[构建项目]时启用或禁用插件。
71+ 该插件的行为与所有其他内置插件不同——它是
72+ 默认禁用__。要启用组,请使用:
7373
7474` ` ` yaml
7575plugins:
7676 - group:
7777 enabled: !ENV CI # (1)!
7878` ` `
7979
80- 1. If you only want to use the group plugin for better organization and
81- always want to enable the plugins that are part of it, use :
80+ 1. 如果你只想使用组插件来更好地组织和
81+ 总是想启用其中的插件,请使用:
8282
8383 ` ` ` yaml
8484 plugins:
8585 - group:
8686 enabled: true
8787 ` ` `
8888
89- The decision to disable the plugin by default was made to simplify the usage
90- of environment variables, as it removes the need to provide a default value for
91- an environment variable.
89+ 默认情况下禁用插件的决定是为了简化使用
90+ 环境变量,因为它消除了为提供默认值的需要
91+ 环境变量。
9292
93- Now, when [building your project], you can enable a group by setting the
94- [environment variable ][mkdocs.env] :
93+ 现在,在[构建项目]时,您可以通过设置
94+ [环境变量 ][mkdocs.env]:
9595
9696` ` ` sh
9797CI=true mkdocs build
@@ -106,9 +106,9 @@ CI=true mkdocs build
106106<!-- md:version 9.3.0 -->
107107<!-- md:default none -->
108108
109- Use this setting to list the plugins that are part of the group. The syntax is
110- exactly the same as for the [`plugins` ][mkdocs.plugins] setting, so you can
111- simply copy the list of plugins that you want to group, e.g :
109+ 使用此设置列出属于该组的插件。语法是
110+ 与 [`plugins][mkdocs.plugins]设置完全相同,因此您可以
111+ 只需复制您要分组的插件列表,例如:
112112
113113` ` ` yaml
114114plugins:
@@ -118,4 +118,4 @@ plugins:
118118 - minify
119119` ` `
120120
121- The plugins mentioned here are just used for illustration purposes.
121+ 这里提到的插件仅用于说明目的。
0 commit comments