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
@@ -19,10 +18,12 @@ def translation(session):
1918 target_dir = "locales"
2019 session .run (
2120 "sphinx-build" ,
22- "-b" , "gettext" , # build gettext-style message catalogs (.pot file)
23- "-d" , ".nox/.doctrees/" , # path to put the cache
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
2829
@@ -33,10 +34,6 @@ def build(session, autobuild=False):
3334 """
3435 session .install ("-r" , "requirements.txt" )
3536
36- target_build_dir = "build"
37-
38- shutil .rmtree (target_build_dir , ignore_errors = True )
39-
4037 if autobuild :
4138 command = "sphinx-autobuild"
4239 extra_args = "--host" , "0.0.0.0"
@@ -49,14 +46,19 @@ def build(session, autobuild=False):
4946 )
5047
5148 session .run (
52- command , * extra_args ,
53- "-j" , "auto" , # parallelize the build
54- "-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
5557 "-n" , # nitpicky warn about all missing references
5658 "-W" , # Treat warnings as errors.
5759 * session .posargs ,
5860 "source" , # where the rst files are located
59- target_build_dir , # where to put the html output
61+ "build" , # where to put the html output
6062 )
6163
6264
@@ -77,11 +79,16 @@ def linkcheck(session):
7779 session .install ("-r" , "requirements.txt" )
7880 session .run (
7981 "sphinx-build" ,
80- "-b" , "linkcheck" , # use linkcheck builder
82+ "-b" ,
83+ "linkcheck" , # use linkcheck builder
84+ "-d" ,
85+ session .cache_dir / ".doctrees" , # path to put the cache
8186 "--color" ,
82- "-n" , "-W" , "--keep-going" , # be strict
83- "source" , # where the rst files are located
84- "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
8592 )
8693
8794
0 commit comments