Skip to content

Commit

Permalink
Version-dependent docs deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi committed May 24, 2024
1 parent 2049374 commit fbef89c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
branches: [main]
pull_request:
branches: [main]
release:
types: [created]
workflow_dispatch:

jobs:
Expand All @@ -27,11 +29,22 @@ jobs:
uv pip install --system -r docs/requirements.txt
sphinx-build docs/source docs/build -b dirhtml
# Deploy
# Get version from pyproject.toml.
- name: Extract version
id: get_version
run: |
python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])" > version.txt
VERSION=$(cat version.txt)
echo "::set-output name=version::$VERSION"
# Deploy to version-dependent subdirectory.
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/build
# TODO: only set this to the version number for release actions.
destination_dir: ${{ steps.get_version.outputs.version }}
keep_files: false # This will only erase the destination subdirectory.
cname: viser.studio
if: github.event_name != 'pull_request'
4 changes: 3 additions & 1 deletion docs/source/_static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ img.sidebar-logo {
margin: 1em 0 0 0;
}
.sidebar-brand-text {
display: none;
font-size: 1rem;
font-weight: 600;
font-style: italic;
}
6 changes: 3 additions & 3 deletions docs/source/_templates/sidebar/brand.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<img class="sidebar-logo only-light" src="{{ pathto('_static/' + theme_light_logo, 1) }}" alt="logo" />
<img class="sidebar-logo only-dark" src="{{ pathto('_static/' + theme_dark_logo, 1) }}" alt="logo" />
</div>
{%- endif %} {#- {% if not theme_sidebar_hide_name %}
<span class="sidebar-brand-text">{{ docstitle if docstitle else project }}</span>
{%- endif %} -#} {% endblock brand_content %}
{%- endif %}
<span class="sidebar-brand-text">{{ version }}</span>
{% endblock brand_content %}
</a>

<div style="text-align: left; padding: 1em">
Expand Down
13 changes: 12 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
# full list see the documentation:
# http://www.sphinx-doc.org/en/stable/config

from pathlib import Path
from typing import Dict, List

import m2r2
import toml

# -- Path setup --------------------------------------------------------------

Expand All @@ -24,7 +26,16 @@
author = "brentyi"

# The short X.Y version
version = ""
version: str = toml.load(
Path(__file__).absolute().parent.parent.parent / "pyproject.toml"
)["project"]["version"]

# Formatting!
# 0.1.30 => v0.1.30
# dev => dev
if not version.isalpha():
version = "v" + version

# The full version, including alpha/beta/rc tags
release = ""

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dev = [
"mypy>=1.4.1",
"ruff==0.4.3",
"pre-commit==3.3.2",
"toml>=0.10.2",
]
examples = [
"torch>=1.13.1",
Expand Down

0 comments on commit fbef89c

Please sign in to comment.