3
3
# Attribution-ShareAlike license:
4
4
# http://creativecommons.org/licenses/by-sa/3.0.
5
5
6
- import shutil
7
- import nox
8
6
7
+ import nox
9
8
10
9
nox .options .sessions = []
11
10
@@ -18,27 +17,26 @@ def translation(session):
18
17
session .install ("-r" , "requirements.txt" )
19
18
target_dir = "locales"
20
19
session .run (
21
- "sphinx-build" ,
22
- "-b" , "gettext" , # build gettext-style message catalogs (.pot file)
23
- "-d" , ".nox/.doctrees/" , # path to put the cache
20
+ "sphinx-build" ,
21
+ "-b" ,
22
+ "gettext" , # build gettext-style message catalogs (.pot file)
23
+ "-d" ,
24
+ session .cache_dir / ".doctrees" , # path to put the cache
24
25
"source/" , # where the rst files are located
25
- target_dir , # where to put the .pot file
26
+ target_dir , # where to put the .pot file
26
27
)
27
28
29
+
28
30
@nox .session ()
29
31
def build (session , autobuild = False ):
30
32
"""
31
33
Make the website.
32
34
"""
33
35
session .install ("-r" , "requirements.txt" )
34
36
35
- target_build_dir = "build"
36
-
37
- shutil .rmtree (target_build_dir , ignore_errors = True )
38
-
39
37
if autobuild :
40
38
command = "sphinx-autobuild"
41
- extra_args = "-H " , "0.0.0.0"
39
+ extra_args = "--host " , "0.0.0.0"
42
40
else :
43
41
# NOTE: This branch adds options that are unsupported by autobuild
44
42
command = "sphinx-build"
@@ -48,14 +46,19 @@ def build(session, autobuild=False):
48
46
)
49
47
50
48
session .run (
51
- command , * extra_args ,
52
- "-j" , "auto" , # parallelize the build
53
- "-b" , "html" , # use HTML builder
49
+ command ,
50
+ * extra_args ,
51
+ "-j" ,
52
+ "auto" , # parallelize the build
53
+ "-b" ,
54
+ "html" , # use HTML builder
55
+ "-d" ,
56
+ session .cache_dir / ".doctrees" , # path to put the cache
54
57
"-n" , # nitpicky warn about all missing references
55
58
"-W" , # Treat warnings as errors.
56
59
* session .posargs ,
57
60
"source" , # where the rst files are located
58
- target_build_dir , # where to put the html output
61
+ "build" , # where to put the html output
59
62
)
60
63
61
64
@@ -75,10 +78,29 @@ def linkcheck(session):
75
78
"""
76
79
session .install ("-r" , "requirements.txt" )
77
80
session .run (
78
- "sphinx-build" ,
79
- "-b" , "linkcheck" , # use linkcheck builder
81
+ "sphinx-build" ,
82
+ "-b" ,
83
+ "linkcheck" , # use linkcheck builder
84
+ "-d" ,
85
+ session .cache_dir / ".doctrees" , # path to put the cache
80
86
"--color" ,
81
- "-n" , "-W" , "--keep-going" , # be strict
82
- "source" , # where the rst files are located
83
- "build" , # where to put the check output
87
+ "-n" ,
88
+ "-W" ,
89
+ "--keep-going" , # be strict
90
+ "source" , # where the rst files are located
91
+ "build" , # where to put the check output
92
+ )
93
+
94
+
95
+ @nox .session ()
96
+ def checkqa (session ):
97
+ """
98
+ Format the guide using pre-commit.
99
+ """
100
+ session .install ("pre-commit" )
101
+ session .run (
102
+ "pre-commit" ,
103
+ "run" ,
104
+ "--all-files" ,
105
+ "--show-diff-on-failure" ,
84
106
)
0 commit comments