-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscripts.py
55 lines (38 loc) · 1.24 KB
/
scripts.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
50
51
52
53
54
55
#!/usr/bin/env python
import logging
import os
import subprocess
import sys
import webbrowser
from pathlib import Path
from typing import Union
from generate_changelog import arg_main as generate_changelog
from generate_changelog import main as generate_changelog_main
BASE_PATH = Path(__file__).resolve().parent
CWD = Path().resolve()
def _cwd_or_base_path(file: Union[str, Path]) -> Path:
final_file = CWD / file
if final_file.exists():
return final_file
return BASE_PATH / file
def build_docs() -> None:
logging.basicConfig(level=logging.INFO, format="%(message)s")
generate_changelog()
docs_dir = _cwd_or_base_path("docs")
os.chdir(docs_dir)
subprocess.run(["make", "html"])
def open_docs() -> None:
index_path = _cwd_or_base_path("docs/build/html/index.html")
webbrowser.open(f"file://{index_path}")
def check() -> None:
subprocess.run(["pre-commit", "run", "--all-files"])
def build_changelog() -> None:
generate_changelog_main()
def change_version() -> None:
args = sys.argv[1:]
file = str(BASE_PATH / "change-version-doc.sh")
subprocess.run([file, *args])
def release() -> None:
args = sys.argv[1:]
file = str(BASE_PATH / "release.sh")
subprocess.run([file, *args])