33# Attribution-ShareAlike license:
44# http://creativecommons.org/licenses/by-sa/3.0.
55
6- import shutil
7- import nox
86
7+ import nox
98
109nox .options .sessions = []
1110
@@ -18,27 +17,26 @@ def translation(session):
1817 session .install ("-r" , "requirements.txt" )
1918 target_dir = "locales"
2019 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
2425 "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
2627 )
2728
29+
2830@nox .session ()
2931def build (session , autobuild = False ):
3032 """
3133 Make the website.
3234 """
3335 session .install ("-r" , "requirements.txt" )
3436
35- target_build_dir = "build"
36-
37- shutil .rmtree (target_build_dir , ignore_errors = True )
38-
3937 if autobuild :
4038 command = "sphinx-autobuild"
41- extra_args = "-H " , "0.0.0.0"
39+ extra_args = "--host " , "0.0.0.0"
4240 else :
4341 # NOTE: This branch adds options that are unsupported by autobuild
4442 command = "sphinx-build"
@@ -48,14 +46,19 @@ def build(session, autobuild=False):
4846 )
4947
5048 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
5457 "-n" , # nitpicky warn about all missing references
5558 "-W" , # Treat warnings as errors.
5659 * session .posargs ,
5760 "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
5962 )
6063
6164
@@ -75,10 +78,29 @@ def linkcheck(session):
7578 """
7679 session .install ("-r" , "requirements.txt" )
7780 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
8086 "--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" ,
84106 )
0 commit comments