Skip to content

Commit 18a0635

Browse files
committed
Add script to generate entire Github pages repository.
Generates docs for v0.5.1 and up
1 parent ea24ba5 commit 18a0635

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

docs/README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,18 @@ This directory contains the tools used to generate this [project's documentation
55

66
## Build instructions
77

8+
To build documentation for the current working tree (assuming same directory layout as git repo):
89
```
910
pip install pdoc
1011
python docs/make.py
11-
```
12+
```
13+
14+
To build documentation for "all versions" of this project (assuming git tags are present):
15+
```
16+
pip install pdoc
17+
python docs/build_full_documentation.py
18+
```
19+
By "all versions" I mean from v0.5.1 and up because that is the first version with docstrings that enable documentation.
20+
21+
---
22+
The resulting documentation from both of these scripts will be located in `docs/docs/`

docs/build_full_documentation.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/python
2+
# flake8: noqa: E501
3+
4+
import os
5+
import subprocess
6+
import tarfile
7+
from pathlib import Path
8+
import shutil
9+
import sys
10+
11+
from packaging import version
12+
13+
here = Path(__file__).parent
14+
temp = here / 'temp'
15+
os.makedirs(temp, exist_ok=True)
16+
17+
# get list of all versions from git tag
18+
all_versions = subprocess.check_output(['git', 'tag', '-l']).decode().rstrip('\n').split('\n')
19+
20+
# download any versions after v0.5.0
21+
for v in filter(lambda a: version.Version(a) > version.Version('0.5.0'), all_versions):
22+
v = version.Version(v.replace('v', ''))
23+
if not os.path.isfile(temp / f'screen_brightness_control-{v}.tar.gz'):
24+
subprocess.check_output(['pip', 'download', '--no-deps', '--no-binary', ':all:', '-d', str(temp), f'screen_brightness_control=={v}'])
25+
26+
for file in os.listdir(temp):
27+
if os.path.isdir(temp / file):
28+
continue
29+
30+
# extract each downloaded version
31+
with tarfile.open(temp / file) as t:
32+
out = temp / file.replace('screen_brightness_control-', '').replace('.tar.gz', '')
33+
if os.path.isdir(out):
34+
shutil.rmtree(out)
35+
t.extractall(out)
36+
37+
# now find the __init__.py file in there and generate the docs for that module
38+
for root, _, files in os.walk(out):
39+
for f in files:
40+
if f == '__init__.py':
41+
subprocess.check_output([sys.executable, str(here / 'make.py'), '-p', root])
42+
break

0 commit comments

Comments
 (0)