docs: use sphinx-multiversion for version selector
This commit is contained in:
parent
a7431ce424
commit
2ed91f6a74
6 changed files with 58 additions and 48 deletions
31
.github/workflows/ci.yaml
vendored
31
.github/workflows/ci.yaml
vendored
|
|
@ -101,37 +101,10 @@ jobs:
|
||||||
- name: Build Python package
|
- name: Build Python package
|
||||||
run: maturin develop --release --manifest-path pyargus/Cargo.toml
|
run: maturin develop --release --manifest-path pyargus/Cargo.toml
|
||||||
- name: Build HTML docs
|
- name: Build HTML docs
|
||||||
run: sphinx-build -b html docs docs/_build/
|
run: sphinx-multiversion -b html docs _site
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
if: github.ref == 'refs/heads/dev' || startsWith(github.ref, 'refs/tags/')
|
if: github.ref == 'refs/heads/dev' || startsWith(github.ref, 'refs/tags/')
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: docs/_build/
|
publish_dir: _site/
|
||||||
destination_dir: ${{ github.ref_name }}
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
ref: 'gh-pages'
|
|
||||||
- name: Install tree
|
|
||||||
run: |
|
|
||||||
sudo apt-get update -y
|
|
||||||
sudo apt-get install -y tree
|
|
||||||
- run: |
|
|
||||||
tree -H '.' \
|
|
||||||
-L 1 \
|
|
||||||
--noreport \
|
|
||||||
--dirsfirst \
|
|
||||||
--charset utf-8 \
|
|
||||||
--ignore-case \
|
|
||||||
--timefmt '%d-%b-%Y %H:%M' \
|
|
||||||
-I "index.html" \
|
|
||||||
-T 'Argus Python Documentation versions' \
|
|
||||||
-s -D \
|
|
||||||
-o index.html
|
|
||||||
git config user.name github-actions
|
|
||||||
git config user.email actions@github.com
|
|
||||||
git add .
|
|
||||||
if [[ ! $(git diff --quiet) ]]; then
|
|
||||||
git commit -m "update index.html"
|
|
||||||
git push
|
|
||||||
fi
|
|
||||||
|
|
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,3 +1,5 @@
|
||||||
|
### Docs ###
|
||||||
|
/_site/
|
||||||
### Lcov ###
|
### Lcov ###
|
||||||
|
|
||||||
*.lcov
|
*.lcov
|
||||||
|
|
|
||||||
30
docs/_templates/versions.html
vendored
Normal file
30
docs/_templates/versions.html
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
{%- if current_version %}
|
||||||
|
<div class="rst-versions" data-toggle="rst-versions" role="note" aria-label="versions">
|
||||||
|
<details open="true">
|
||||||
|
<summary>
|
||||||
|
<span class="fa fa-book"> Current Version</span>
|
||||||
|
{{ current_version.name }}
|
||||||
|
<span class="fa fa-caret-down"></span>
|
||||||
|
</summary>
|
||||||
|
|
||||||
|
<div class="rst-other-versions">
|
||||||
|
{%- if versions.tags %}
|
||||||
|
<dl>
|
||||||
|
<dt>Tags</dt>
|
||||||
|
{%- for item in versions.tags %}
|
||||||
|
<dd><a href="{{ item.url }}">{{ item.name }}</a></dd>
|
||||||
|
{%- endfor %}
|
||||||
|
</dl>
|
||||||
|
{%- endif %}
|
||||||
|
{%- if versions.branches %}
|
||||||
|
<dl>
|
||||||
|
<dt>Branches</dt>
|
||||||
|
{%- for item in versions.branches %}
|
||||||
|
<dd><a href="{{ item.url }}">{{ item.name }}</a></dd>
|
||||||
|
{%- endfor %}
|
||||||
|
</dl>
|
||||||
|
{%- endif %}
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
</div>
|
||||||
|
{%- endif %}
|
||||||
34
docs/conf.py
34
docs/conf.py
|
|
@ -27,29 +27,29 @@ extensions = [
|
||||||
"myst_parser",
|
"myst_parser",
|
||||||
"sphinx_copybutton",
|
"sphinx_copybutton",
|
||||||
"sphinx.ext.inheritance_diagram",
|
"sphinx.ext.inheritance_diagram",
|
||||||
|
"sphinx_multiversion",
|
||||||
]
|
]
|
||||||
|
|
||||||
templates_path = ["_templates"]
|
templates_path = ["_templates"]
|
||||||
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
|
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
|
||||||
|
|
||||||
html_theme = "pydata_sphinx_theme"
|
html_theme = "furo"
|
||||||
html_static_path = ["_static"]
|
html_static_path = ["_static"]
|
||||||
html_theme_options = {
|
html_theme_options = {
|
||||||
"use_edit_page_button": True,
|
"source_repository": "https://github.com/anand-bala/argus/",
|
||||||
"github_url": "https://github.com/anand-bala/argus",
|
"source_branch": "dev",
|
||||||
"switcher": {
|
"source_directory": "docs/",
|
||||||
"json_url": "https://anand-bala.github.io/argus/dev/_static/switcher.json",
|
|
||||||
"version_match": version,
|
|
||||||
},
|
|
||||||
"check_switcher": False,
|
|
||||||
"navbar_align": "left", # [left, content, right] For testing that the navbar items align properly
|
|
||||||
"navbar_center": ["version-switcher", "navbar-nav"],
|
|
||||||
}
|
}
|
||||||
html_context = {
|
html_sidebars = {
|
||||||
"github_user": "anand-bala",
|
"**": [
|
||||||
"github_repo": "argus",
|
"sidebar/brand.html",
|
||||||
"github_version": "v0.1.1",
|
"sidebar/search.html",
|
||||||
"doc_path": "docs",
|
"sidebar/scroll-start.html",
|
||||||
|
"sidebar/navigation.html",
|
||||||
|
"sidebar/ethical-ads.html",
|
||||||
|
"sidebar/scroll-end.html",
|
||||||
|
"versions.html",
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
source_suffix = {
|
source_suffix = {
|
||||||
|
|
@ -58,6 +58,10 @@ source_suffix = {
|
||||||
".md": "markdown",
|
".md": "markdown",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Whitelist pattern for branches (set to None to ignore all branches)
|
||||||
|
smv_branch_whitelist = r"^dev$"
|
||||||
|
|
||||||
autoapi_dirs = ["../pyargus/argus"]
|
autoapi_dirs = ["../pyargus/argus"]
|
||||||
autoapi_root = "api"
|
autoapi_root = "api"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,11 @@ dependencies:
|
||||||
- lark # hypothesis[lark]
|
- lark # hypothesis[lark]
|
||||||
- pip
|
- pip
|
||||||
- sphinx
|
- sphinx
|
||||||
- pydata-sphinx-theme
|
- furo
|
||||||
- sphinx-copybutton
|
- sphinx-copybutton
|
||||||
- myst-parser
|
- myst-parser
|
||||||
- pip:
|
- pip:
|
||||||
- sphinx-autoapi
|
- sphinx-autoapi
|
||||||
|
- sphinx-multiversion
|
||||||
|
|
||||||
category: dev
|
category: dev
|
||||||
|
|
|
||||||
|
|
@ -41,14 +41,14 @@ def dev(session: nox.Session):
|
||||||
def docs(session: nox.Session):
|
def docs(session: nox.Session):
|
||||||
session.conda_install(
|
session.conda_install(
|
||||||
"sphinx",
|
"sphinx",
|
||||||
"pydata-sphinx-theme",
|
"furo",
|
||||||
"sphinx-copybutton",
|
"sphinx-copybutton",
|
||||||
"myst-parser",
|
"myst-parser",
|
||||||
)
|
)
|
||||||
session.install("sphinx-autoapi")
|
session.install("sphinx-autoapi", "sphinx-multiversion")
|
||||||
with session.chdir(CURRENT_DIR / "pyargus"):
|
with session.chdir(CURRENT_DIR / "pyargus"):
|
||||||
session.install("-e", ".")
|
session.install("-e", ".")
|
||||||
session.run("sphinx-build", "-b", "html", "docs", "docs/_build/html")
|
session.run("sphinx-multiversion", "-b", "html", "docs", "_site")
|
||||||
|
|
||||||
|
|
||||||
@nox.session(tags=["style", "fix", "rust"], python=False)
|
@nox.session(tags=["style", "fix", "rust"], python=False)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue