This repository was archived by the owner on Jun 28, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +65
-3
lines changed Expand file tree Collapse file tree 3 files changed +65
-3
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 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 ()
Original file line number Diff line number Diff line change 33
44from .base import fib , hello , add42
55
6- VERSION = "0.0.5 "
6+ VERSION = "0.0.6 "
You can’t perform that action at this time.
0 commit comments