1
1
import click
2
2
3
3
from mkdocs .__main__ import cli as mkdocs_cli
4
- from pulp_docs .context import ctx_blog , ctx_draft
4
+ from pulp_docs .context import ctx_blog , ctx_docstrings , ctx_draft
5
5
6
6
7
7
def blog_callback (ctx : click .Context , param : click .Parameter , value : bool ) -> bool :
8
8
ctx_blog .set (value )
9
9
return value
10
10
11
11
12
+ def docstrings_callback (
13
+ ctx : click .Context , param : click .Parameter , value : bool
14
+ ) -> bool :
15
+ ctx_docstrings .set (value )
16
+ return value
17
+
18
+
12
19
def draft_callback (ctx : click .Context , param : click .Parameter , value : bool ) -> bool :
13
20
ctx_draft .set (value )
14
21
return value
@@ -19,7 +26,14 @@ def draft_callback(ctx: click.Context, param: click.Parameter, value: bool) -> b
19
26
default = True ,
20
27
expose_value = False ,
21
28
callback = blog_callback ,
22
- help = "Don't fail if repositories are missing." ,
29
+ help = "Build blog." ,
30
+ )
31
+ docstrings_option = click .option (
32
+ "--docstrings/--no-docstrings" ,
33
+ default = True ,
34
+ expose_value = False ,
35
+ callback = docstrings_callback ,
36
+ help = "Enable mkdocstrings plugin." ,
23
37
)
24
38
25
39
draft_option = click .option (
@@ -31,9 +45,8 @@ def draft_callback(ctx: click.Context, param: click.Parameter, value: bool) -> b
31
45
32
46
main = mkdocs_cli
33
47
34
- build_command = main .commands .get ("build" )
35
- serve_command = main .commands .get ("serve" )
36
- draft_option (build_command )
37
- draft_option (serve_command )
38
- blog_option (build_command )
39
- blog_option (serve_command )
48
+ for command_name in ["build" , "serve" ]:
49
+ sub_command = main .commands .get (command_name )
50
+ draft_option (sub_command )
51
+ blog_option (sub_command )
52
+ docstrings_option (sub_command )
0 commit comments