forked from pyOpenSci/python-package-guide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoxfile.py
49 lines (40 loc) · 1.11 KB
/
noxfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import os
import pathlib
import shutil
import nox
nox.options.reuse_existing_virtualenvs = True
build_command = ["-b", "html", ".", "_build/html"]
@nox.session
def docs(session):
session.install("-r", "requirements.txt")
cmd = ["sphinx-build"]
cmd.extend(build_command + session.posargs)
session.run(*cmd)
@nox.session(name="docs-live")
def docs_live(session):
session.install("-r", "requirements.txt")
AUTOBUILD_IGNORE = [
"_build",
"build_assets",
"tmp",
]
cmd = ["sphinx-autobuild"]
for folder in AUTOBUILD_IGNORE:
cmd.extend(["--ignore", f"*/{folder}/*"])
cmd.extend(build_command + session.posargs)
session.run(*cmd)
docs_dir = os.path.join("_build", "html")
@nox.session(name="docs-clean")
def clean_dir(dir_path=docs_dir):
"""
Clean out the docs directory used in the
live build.
"""
dir_path = pathlib.Path(dir_path)
dir_contents = dir_path.glob('*')
for content in dir_contents:
print(content)
if content.is_dir():
shutil.rmtree(content)
else:
os.remove(content)