Unverified Commit 0bccd886 authored by Sheikh Dawood's avatar Sheikh Dawood Committed by GitHub

Adds versioning to the docs (#1247)

# Description

Adds versioning to the docs. Users can now choose a specific tag from
version v1.0.0 onwards.

## Type of change

- New feature (non-breaking change which adds functionality)

## Checklist

- [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with
`./isaaclab.sh --format`
- [x] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have updated the changelog and the corresponding version in the
extension's `config/extension.toml` file
- [x] I have added my name to the `CONTRIBUTORS.md` or my name already
exists there
parent a4118d7f
name: Build & deploy docs name: Build & deploy docs
on: [push] on:
push:
pull_request:
jobs: jobs:
build-docs: build-docs:
...@@ -8,28 +10,35 @@ jobs: ...@@ -8,28 +10,35 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Setup python - name: Setup python
uses: actions/setup-python@v2 uses: actions/setup-python@v2
with: with:
python-version: "3.10" python-version: "3.10"
architecture: x64 architecture: x64
- name: Install dev requirements - name: Install dev requirements
working-directory: ./docs working-directory: ./docs
run: pip install -r requirements.txt run: pip install -r requirements.txt
- name: Generate docs - name: Check branch docs building
working-directory: ./docs if: ${{ github.event_name == 'pull_request' }}
run: make html working-directory: ./docs
run: make current-docs
- name: Upload docs artifact - name: Generate multi-version docs
uses: actions/upload-artifact@v4 working-directory: ./docs
with: run: |
name: docs-html git fetch --prune --unshallow --tags
path: ./docs/_build/html make multi-docs
- name: Upload docs artifact
uses: actions/upload-artifact@v4
with:
name: docs-html
path: ./docs/_build
check-secrets: check-secrets:
name: Check secrets name: Check secrets
...@@ -37,12 +46,12 @@ jobs: ...@@ -37,12 +46,12 @@ jobs:
outputs: outputs:
trigger-deploy: ${{ steps.trigger-deploy.outputs.defined }} trigger-deploy: ${{ steps.trigger-deploy.outputs.defined }}
steps: steps:
- id: trigger-deploy - id: trigger-deploy
env: env:
REPO_NAME: ${{ secrets.REPO_NAME }} REPO_NAME: ${{ secrets.REPO_NAME }}
BRANCH_REF: ${{ secrets.BRANCH_REF }} BRANCH_REF: ${{ secrets.BRANCH_REF }}
if: "${{ github.repository == env.REPO_NAME && github.ref == env.BRANCH_REF }}" if: "${{ github.repository == env.REPO_NAME && github.ref == env.BRANCH_REF }}"
run: echo "defined=true" >> "$GITHUB_OUTPUT" run: echo "defined=true" >> "$GITHUB_OUTPUT"
deploy-docs: deploy-docs:
name: Deploy Docs name: Deploy Docs
...@@ -51,14 +60,14 @@ jobs: ...@@ -51,14 +60,14 @@ jobs:
if: needs.check-secrets.outputs.trigger-deploy == 'true' if: needs.check-secrets.outputs.trigger-deploy == 'true'
steps: steps:
- name: Download docs artifact - name: Download docs artifact
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
with: with:
name: docs-html name: docs-html
path: ./docs/_build/html path: ./docs/_build
- name: Deploy to gh-pages - name: Deploy to gh-pages
uses: peaceiris/actions-gh-pages@v3 uses: peaceiris/actions-gh-pages@v3
with: with:
github_token: ${{ secrets.GITHUB_TOKEN }} github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build/html publish_dir: ./docs/_build
...@@ -28,6 +28,7 @@ Guidelines for modifications: ...@@ -28,6 +28,7 @@ Guidelines for modifications:
* Mayank Mittal * Mayank Mittal
* Nikita Rudin * Nikita Rudin
* Pascal Roth * Pascal Roth
* Sheikh Dawood
## Contributors ## Contributors
......
...@@ -8,13 +8,11 @@ SPHINXBUILD ?= sphinx-build ...@@ -8,13 +8,11 @@ SPHINXBUILD ?= sphinx-build
SOURCEDIR = . SOURCEDIR = .
BUILDDIR = _build BUILDDIR = _build
# Put it first so that "make" without argument is like "make help". .PHONY: multi-docs
help: multi-docs:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) @sphinx-multiversion "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS)
@cp _redirect/index.html $(BUILDDIR)/index.html
.PHONY: help Makefile .PHONY: current-docs
current-docs:
# Catch-all target: route all unknown targets to Sphinx using the new @$(SPHINXBUILD) "$(SOURCEDIR)" "$(BUILDDIR)/current" $(SPHINXOPTS)
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
# Building Documentation # Building Documentation
We use [Sphinx](https://www.sphinx-doc.org/en/master/) with the [Book Theme](https://sphinx-book-theme.readthedocs.io/en/stable/) for maintaining the documentation. We use [Sphinx](https://www.sphinx-doc.org/en/master/) with the [Book Theme](https://sphinx-book-theme.readthedocs.io/en/stable/) for maintaining and generating our documentation.
> **Note:** To build the documentation, we recommend creating a virtual environment to avoid any conflicts with system installed dependencies. > **Note:** To avoid dependency conflicts, we strongly recommend using a Python virtual environment to isolate the required dependencies from your system's global Python environment.
Execute the following instructions to build the documentation (assumed from the top of the repository): ## Current-Version Documentation
1. Install the dependencies for [Sphinx](https://www.sphinx-doc.org/en/master/): This section describes how to build the documentation for the current version of the project.
```bash <details open>
# enter the location where this readme exists <summary><strong>Linux</strong></summary>
cd docs
# install dependencies
pip install -r requirements.txt
```
2. Generate the documentation file via: ```bash
# 1. Navigate to the docs directory and install dependencies
cd docs
pip install -r requirements.txt
```bash # 2. Build the current documentation
# make the html version make current-docs
make html
```
3. The documentation is now available at `docs/_build/html/index.html`: # 3. Open the current docs
xdg-open _build/current/index.html
```
</details>
```bash <details> <summary><strong>Windows</strong></summary>
# open on default browser
xdg-open _build/html/index.html ```batch
``` :: 1. Navigate to the docs directory and install dependencies
cd docs
pip install -r requirements.txt
:: 2. Build the current documentation
make current-docs
:: 3. Open the current docs
start _build\current\index.html
```
</details>
## Multi-Version Documentation
This section describes how to build the multi-version documentation, which includes previous tags and the main branch.
<details open> <summary><strong>Linux</strong></summary>
```bash
# 1. Navigate to the docs directory and install dependencies
cd docs
pip install -r requirements.txt
# 2. Build the multi-version documentation
make multi-docs
# 3. Open the multi-version docs
xdg-open _build/index.html
```
</details>
<details> <summary><strong>Windows</strong></summary>
```batch
:: 1. Navigate to the docs directory and install dependencies
cd docs
pip install -r requirements.txt
:: 2. Build the multi-version documentation
make multi-docs
:: 3. Open the multi-version docs
start _build\index.html
```
</details>
<!DOCTYPE html>
<html>
<head>
<title>Redirecting to the latest Isaac Lab documentation</title>
<meta charset="utf-8">
<meta http-equiv="refresh" content="0; url=./main/index.html">
</head>
</html>
{% if versions %}
<nav class="bd-links bd-docs-nav">
<div class="bd-toc-item navbar-nav">
<ul class="nav bd-sidenav">
<li class="toctree-l1 has-children" style="display: flex; justify-content: center; align-items: center; flex-direction: column;">
<div style ="text-align:center;">
<label for="version-select" style="font-weight: bold; display: block;">Version</label>
</div>
<select id="version-select" class="version-dropdown" style="margin: 0 auto; display: block;" onchange="location = this.value;">
{%- for item in versions.branches %}
<option value="{{ item.url }}" {% if item == current_version %}selected{% endif %}>{{ item.name }}</option>
{%- endfor %}
{%- for item in versions.tags|reverse %}
<option value="{{ item.url }}" {% if item == current_version %}selected{% endif %}>{{ item.name }}</option>
{%- endfor %}
</select>
</li>
</ul>
</div>
</nav>
{% endif %}
...@@ -54,6 +54,8 @@ extensions = [ ...@@ -54,6 +54,8 @@ extensions = [
"sphinxcontrib.icon", "sphinxcontrib.icon",
"sphinx_copybutton", "sphinx_copybutton",
"sphinx_design", "sphinx_design",
"sphinx_tabs.tabs", # backwards compatibility for building docs on v1.0.0
"sphinx_multiversion",
] ]
# mathjax hacks # mathjax hacks
...@@ -115,7 +117,7 @@ templates_path = [] ...@@ -115,7 +117,7 @@ templates_path = []
# List of patterns, relative to source directory, that match files and # List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files. # directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path. # This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "README.md", "licenses/*"] exclude_patterns = ["_build", "_redirect", "_templates", "Thumbs.db", ".DS_Store", "README.md", "licenses/*"]
# Mock out modules that are not available on RTD # Mock out modules that are not available on RTD
autodoc_mock_imports = [ autodoc_mock_imports = [
...@@ -190,7 +192,7 @@ language = "en" ...@@ -190,7 +192,7 @@ language = "en"
import sphinx_book_theme import sphinx_book_theme
html_title = "Isaac Lab documentation" html_title = "Isaac Lab Documentation"
html_theme_path = [sphinx_book_theme.get_html_theme_path()] html_theme_path = [sphinx_book_theme.get_html_theme_path()]
html_theme = "sphinx_book_theme" html_theme = "sphinx_book_theme"
html_favicon = "source/_static/favicon.ico" html_favicon = "source/_static/favicon.ico"
...@@ -213,7 +215,7 @@ html_theme_options = { ...@@ -213,7 +215,7 @@ html_theme_options = {
"show_toc_level": 1, "show_toc_level": 1,
"use_sidenotes": True, "use_sidenotes": True,
"logo": { "logo": {
"text": "Isaac Lab documentation", "text": "Isaac Lab Documentation",
"image_light": "source/_static/NVIDIA-logo-white.png", "image_light": "source/_static/NVIDIA-logo-white.png",
"image_dark": "source/_static/NVIDIA-logo-black.png", "image_dark": "source/_static/NVIDIA-logo-black.png",
}, },
...@@ -240,7 +242,19 @@ html_theme_options = { ...@@ -240,7 +242,19 @@ html_theme_options = {
"icon_links_label": "Quick Links", "icon_links_label": "Quick Links",
} }
html_sidebars = {"**": ["navbar-logo.html", "icon-links.html", "search-field.html", "sbt-sidebar-nav.html"]} templates_path = [
"_templates",
]
# Whitelist pattern for remotes
smv_remote_whitelist = r"^.*$"
# Whitelist pattern for branches (set to None to ignore all branches)
smv_branch_whitelist = os.getenv("SMV_BRANCH_WHITELIST", r"^(main|devel)$")
# Whitelist pattern for tags (set to None to ignore all tags)
smv_tag_whitelist = os.getenv("SMV_TAG_WHITELIST", r"^v[1-9]\d*\.\d+\.\d+$")
html_sidebars = {
"**": ["navbar-logo.html", "versioning.html", "icon-links.html", "search-field.html", "sbt-sidebar-nav.html"]
}
# -- Advanced configuration ------------------------------------------------- # -- Advanced configuration -------------------------------------------------
......
BSD 2-Clause License
Copyright (c) 2020, Jan Holthuis <jan.holthuis@ruhr-uni-bochum.de>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
...@@ -2,34 +2,63 @@ ...@@ -2,34 +2,63 @@
pushd %~dp0 pushd %~dp0
REM Command file for Sphinx documentation REM Command file to build Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=. set SOURCEDIR=.
set BUILDDIR=_build set BUILDDIR=_build
if "%1" == "" goto help REM Check if a specific target was passed
if "%1" == "multi-docs" (
%SPHINXBUILD% >NUL 2>NUL REM Check if SPHINXBUILD is set, if not default to sphinx-multiversion
if errorlevel 9009 ( if "%SPHINXBUILD%" == "" (
echo. set SPHINXBUILD=sphinx-multiversion
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx )
echo.installed, then set the SPHINXBUILD environment variable to point %SPHINXBUILD% >NUL 2>NUL
echo.to the full path of the 'sphinx-build' executable. Alternatively you if errorlevel 9009 (
echo.may add the Sphinx directory to PATH. echo.
echo. echo.The 'sphinx-multiversion' command was not found. Make sure you have Sphinx
echo.If you don't have Sphinx installed, grab it from echo.installed, then set the SPHINXBUILD environment variable to point
echo.http://sphinx-doc.org/ echo.to the full path of the 'sphinx-multiversion' executable. Alternatively you
exit /b 1 echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
REM Copy the redirect index.html to the build directory
copy _redirect\index.html %BUILDDIR%\index.html
goto end
) )
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% if "%1" == "current-docs" (
goto end REM Check if SPHINXBUILD is set, if not default to sphinx-build
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% %SOURCEDIR% %BUILDDIR%\current %SPHINXOPTS% %O%
goto end
)
:help REM If no valid target is passed, show usage instructions
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% echo.
echo.Usage:
echo. make.bat multi-docs - To build the multi-version documentation.
echo. make.bat current-docs - To build the current documentation.
echo.
:end :end
popd popd
...@@ -7,6 +7,8 @@ sphinx-copybutton ...@@ -7,6 +7,8 @@ sphinx-copybutton
sphinx-icon sphinx-icon
sphinx_design sphinx_design
sphinxemoji sphinxemoji
sphinx-tabs # backwards compatibility for building docs on v1.0.0
sphinx-multiversion==0.2.4
# basic python # basic python
numpy numpy
......
...@@ -519,9 +519,9 @@ if "%arg%"=="-i" ( ...@@ -519,9 +519,9 @@ if "%arg%"=="-i" (
call :extract_python_exe call :extract_python_exe
pushd %ISAACLAB_PATH%\docs pushd %ISAACLAB_PATH%\docs
call !python_exe! -m pip install -r requirements.txt >nul call !python_exe! -m pip install -r requirements.txt >nul
call !python_exe! -m sphinx -b html -d _build\doctrees . _build\html call !python_exe! -m sphinx -b html -d _build\doctrees . _build\current
echo [INFO] To open documentation on default browser, run: echo [INFO] To open documentation on default browser, run:
echo xdg-open "%ISAACLAB_PATH%\docs\_build\html\index.html" echo xdg-open "%ISAACLAB_PATH%\docs\_build\current\index.html"
popd >nul popd >nul
shift shift
goto :end goto :end
......
...@@ -396,10 +396,10 @@ while [[ $# -gt 0 ]]; do ...@@ -396,10 +396,10 @@ while [[ $# -gt 0 ]]; do
cd ${ISAACLAB_PATH}/docs cd ${ISAACLAB_PATH}/docs
${python_exe} -m pip install -r requirements.txt > /dev/null ${python_exe} -m pip install -r requirements.txt > /dev/null
# build the documentation # build the documentation
${python_exe} -m sphinx -b html -d _build/doctrees . _build/html ${python_exe} -m sphinx -b html -d _build/doctrees . _build/current
# open the documentation # open the documentation
echo -e "[INFO] To open documentation on default browser, run:" echo -e "[INFO] To open documentation on default browser, run:"
echo -e "\n\t\txdg-open $(pwd)/_build/html/index.html\n" echo -e "\n\t\txdg-open $(pwd)/_build/current/index.html\n"
# exit neatly # exit neatly
cd - > /dev/null cd - > /dev/null
shift # past argument shift # past argument
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment