Skip to content

Commit

Permalink
docs: use sphinx-multiversion for version selector
Browse files Browse the repository at this point in the history
  • Loading branch information
anand-bala committed Oct 13, 2023
1 parent a7431ce commit 2ed91f6
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 48 deletions.
31 changes: 2 additions & 29 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,37 +101,10 @@ jobs:
- name: Build Python package
run: maturin develop --release --manifest-path pyargus/Cargo.toml
- name: Build HTML docs
run: sphinx-build -b html docs docs/_build/
run: sphinx-multiversion -b html docs _site
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/dev' || startsWith(github.ref, 'refs/tags/')
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/_build/
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 [email protected]
git add .
if [[ ! $(git diff --quiet) ]]; then
git commit -m "update index.html"
git push
fi
publish_dir: _site/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
### Docs ###
/_site/
### Lcov ###

*.lcov
Expand Down
30 changes: 30 additions & 0 deletions docs/_templates/versions.html
Original file line number Diff line number Diff line change
@@ -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 changes: 19 additions & 15 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,29 @@
"myst_parser",
"sphinx_copybutton",
"sphinx.ext.inheritance_diagram",
"sphinx_multiversion",
]

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

html_theme = "pydata_sphinx_theme"
html_theme = "furo"
html_static_path = ["_static"]
html_theme_options = {
"use_edit_page_button": True,
"github_url": "https://github.com/anand-bala/argus",
"switcher": {
"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"],
"source_repository": "https://github.com/anand-bala/argus/",
"source_branch": "dev",
"source_directory": "docs/",
}
html_context = {
"github_user": "anand-bala",
"github_repo": "argus",
"github_version": "v0.1.1",
"doc_path": "docs",
html_sidebars = {
"**": [
"sidebar/brand.html",
"sidebar/search.html",
"sidebar/scroll-start.html",
"sidebar/navigation.html",
"sidebar/ethical-ads.html",
"sidebar/scroll-end.html",
"versions.html",
]
}

source_suffix = {
Expand All @@ -58,6 +58,10 @@
".md": "markdown",
}


# Whitelist pattern for branches (set to None to ignore all branches)
smv_branch_whitelist = r"^dev$"

autoapi_dirs = ["../pyargus/argus"]
autoapi_root = "api"

Expand Down
3 changes: 2 additions & 1 deletion environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ dependencies:
- lark # hypothesis[lark]
- pip
- sphinx
- pydata-sphinx-theme
- furo
- sphinx-copybutton
- myst-parser
- pip:
- sphinx-autoapi
- sphinx-multiversion

category: dev
6 changes: 3 additions & 3 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def dev(session: nox.Session):
def docs(session: nox.Session):
session.conda_install(
"sphinx",
"pydata-sphinx-theme",
"furo",
"sphinx-copybutton",
"myst-parser",
)
session.install("sphinx-autoapi")
session.install("sphinx-autoapi", "sphinx-multiversion")
with session.chdir(CURRENT_DIR / "pyargus"):
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)
Expand Down

0 comments on commit 2ed91f6

Please sign in to comment.