Skip to content
This repository was archived by the owner on Jun 28, 2023. It is now read-only.

Commit 02941b0

Browse files
committed
Add script to build docs with folder for different version
1 parent d03ad85 commit 02941b0

File tree

3 files changed

+65
-3
lines changed

3 files changed

+65
-3
lines changed

README.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ Documentation
132132

133133
.. code-block:: sh
134134
135-
sphinx-apidoc -o doc/api everywhere/
136-
python setup.py build_sphinx -s doc/
135+
python build_doc.py
137136
138137
139138

build_doc.py

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env python3
2+
3+
from subprocess import check_output
4+
5+
DOCUMENT_FOLDER = 'doc'
6+
API_DOCUMENT_FOLDER = '{}/{}'.format(DOCUMENT_FOLDER, 'api')
7+
SOURCE = 'everywhere'
8+
MASTER_BRANCH = 'master'
9+
HTML_DIR = 'html'
10+
11+
12+
def run_cmd(cmd):
13+
print('running command: {}'.format(cmd))
14+
result = check_output(cmd.split())
15+
print(result.decode(), end='')
16+
return result
17+
18+
19+
def build_docstring_rst():
20+
run_cmd('sphinx-apidoc -o {} {}'.format(API_DOCUMENT_FOLDER, SOURCE))
21+
22+
23+
def build_html():
24+
run_cmd('python setup.py build_sphinx -s {}'.format(DOCUMENT_FOLDER))
25+
26+
27+
def clean_old_build():
28+
run_cmd('rm -rf build/sphinx/html {} {}'.format(API_DOCUMENT_FOLDER,
29+
HTML_DIR))
30+
31+
32+
def duplicate_old_html():
33+
run_cmd('git clone -b gh-pages . {}'.format(HTML_DIR))
34+
run_cmd('rm -rf {html}/.git {html}/{br}'.format(html=HTML_DIR,
35+
br=MASTER_BRANCH))
36+
37+
38+
def get_git_tags():
39+
return run_cmd('git tag --contains').split()
40+
41+
42+
def update_html():
43+
run_cmd('mv build/sphinx/html {}/{}'.format(HTML_DIR, MASTER_BRANCH))
44+
45+
tags = get_git_tags()
46+
if tags:
47+
destination = tags[0].decode()
48+
run_cmd('rm -rf {}/{}'.format(HTML_DIR, destination))
49+
run_cmd('cp -r {html}/{br} {html}/{dst}'.format(html=HTML_DIR,
50+
br=MASTER_BRANCH,
51+
dst=destination))
52+
53+
54+
def main():
55+
clean_old_build()
56+
build_docstring_rst()
57+
build_html()
58+
duplicate_old_html()
59+
update_html()
60+
61+
62+
if __name__ == '__main__':
63+
main()

everywhere/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
from .base import fib, hello, add42
55

6-
VERSION = "0.0.5"
6+
VERSION = "0.0.6"

0 commit comments

Comments
 (0)