forked from openwisp/openwisp-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] Added prototype for generating comprehensive docs openwisp#107
Closes openwisp#107
- Loading branch information
Showing
8 changed files
with
163 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
_build/ | ||
|
||
.vscode/ | ||
modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<style> | ||
.rst-versions.shift-up { | ||
background: #ddd; | ||
} | ||
|
||
span.rst-current-version { | ||
background: #fff !important; | ||
color: #df5d43 !important; | ||
} | ||
|
||
.rst-other-versions dt { | ||
font-weight: bold !important; | ||
} | ||
|
||
.rst-versions .rst-other-versions dd a { | ||
color: #777; | ||
} | ||
|
||
.rst-versions .rst-other-versions dd a:hover, | ||
.rst-versions .rst-other-versions dd.selected a { | ||
color: #df5d43 !important; | ||
} | ||
</style> | ||
|
||
|
||
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions"> | ||
<span class="rst-current-version" data-toggle="rst-current-version"> | ||
Version: {{ current_ow_version }} | ||
<span class="fa fa-caret-down"></span> | ||
</span> | ||
<div class="rst-other-versions"> | ||
<dl> | ||
<dt>{{ _('Versions') }}</dt> | ||
{% for ow_version, ow_version_root_url in ow_versions %} | ||
<dd class="{% if ow_version == current_ow_version %}selected{% endif %}"> | ||
<a href="{{ ow_version_root_url }}/{{ pagename }}.html">{{ ow_version }}</a> | ||
</dd> | ||
{% endfor %} | ||
</dl> | ||
<dl> | ||
<dt>{{ _('Versions') }}</dt> | ||
<dd><a href="//openwisp-radius.readthedocs.io/_/downloads/en/stable/pdf/">PDF</a></dd> | ||
|
||
<dd><a href="//openwisp-radius.readthedocs.io/_/downloads/en/stable/htmlzip/">HTML</a></dd> | ||
|
||
<dd><a href="//openwisp-radius.readthedocs.io/_/downloads/en/stable/epub/">Epub</a></dd> | ||
|
||
</dl> | ||
<br> | ||
</dl> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
|
||
versions: | ||
- name: latest | ||
modules: | ||
- name: openwisp-firmware-upgrader | ||
branch: reorder-docs | ||
- name: openwisp-controller | ||
branch: reorder-docs | ||
- name: stable | ||
modules: | ||
- name: openwisp-firmware-upgrader | ||
branch: reorder-docs-stable | ||
- name: openwisp-controller | ||
branch: reorder-docs-stable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import os | ||
import subprocess | ||
|
||
import yaml | ||
|
||
|
||
def clone_or_update_repo(module_name, branch): | ||
repo_url = f'git@github.com:openwisp/{module_name}.git' | ||
repo_path = f'modules/{module_name}' | ||
|
||
if os.path.exists(repo_path): | ||
print(f"Repository '{module_name}' already exists. Updating...") | ||
subprocess.run(['git', 'remote', 'set-branches', 'origin', branch], cwd=repo_path, check=True) | ||
subprocess.run(['git', 'fetch', '--update-shallow', 'origin', branch], cwd=repo_path, check=True) | ||
subprocess.run(['git', 'checkout', branch], cwd=repo_path, check=True) | ||
else: | ||
print(f"Cloning repository '{module_name}'...") | ||
subprocess.run( | ||
[ | ||
'git', | ||
'clone', | ||
# '--single-branch', | ||
'--branch', | ||
branch, | ||
'--depth', | ||
'1', | ||
repo_url, | ||
repo_path, | ||
], | ||
check=True, | ||
) | ||
subprocess.run( | ||
['git', 'sparse-checkout', 'init', '--cone'], cwd=repo_path, check=True | ||
) | ||
subprocess.run( | ||
['git', 'sparse-checkout', 'set', 'docs'], cwd=repo_path, check=True | ||
) | ||
|
||
|
||
def main(): | ||
with open('config.yml') as f: | ||
config = yaml.safe_load(f) | ||
|
||
for version in config['versions']: | ||
for module in version['modules']: | ||
module_name = module['name'] | ||
branch = module['branch'] | ||
clone_or_update_repo(module_name, branch) | ||
version_name = version['name'] | ||
|
||
os.makedirs(f'_build/{version_name}', exist_ok=True) | ||
os.environ['OPENWISP2_VERSION'] = version_name | ||
subprocess.run( | ||
['sphinx-build', '-b', 'html', '.', f'_build/{version_name}'], check=True | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
# Sphinx temporarily pinned because of this issue | ||
# https://github.com/sphinx-doc/sphinx/issues/11633 | ||
sphinx~=7.1.2 | ||
svglib | ||
rst2pdf | ||
sphinxcontrib | ||
sphinx-notfound-page | ||
openwisp-sphinx-theme~=1.0.0 | ||
openwisp-utils[qa] @ https://github.com/openwisp/openwisp-utils/tarball/master |