File size: 6,367 Bytes
3044426 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | # Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md).
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Sphinx helpers for Isaac Lab documentation."""
from __future__ import annotations
from docutils import nodes
from docutils.parsers.rst import directives
from docutils.statemachine import StringList
from sphinx.util.docutils import SphinxDirective
def _branch(config) -> str:
"""Return the branch or tag pinned in installation docs."""
current_version = getattr(config, "smv_current_version", "")
if current_version:
return current_version
return getattr(config, "isaaclab_latest_branch", "main")
def _parse_rst(directive: SphinxDirective, content: str) -> list[nodes.Node]:
"""Parse nested reST and return the generated document nodes."""
source = directive.env.doc2path(directive.env.docname, base=False)
lines = StringList(content.splitlines(), source=source)
container = nodes.container()
directive.state.nested_parse(lines, 0, container)
return container.children
class IsaacLabCloneCommands(SphinxDirective):
"""Render SSH/HTTPS clone tabs using copy-friendly ``code-block`` directives."""
has_content = False
def run(self) -> list[nodes.Node]:
branch = _branch(self.config)
content = f"""\
.. tab-set::
.. tab-item:: SSH
.. code-block:: bash
git clone git@github.com:isaac-sim/IsaacLab.git --branch {branch}
cd IsaacLab
.. tab-item:: HTTPS
.. code-block:: bash
git clone https://github.com/isaac-sim/IsaacLab.git --branch {branch}
cd IsaacLab
"""
return _parse_rst(self, content)
class IsaacLabCloneHttps(SphinxDirective):
"""Render an HTTPS clone command as a copy-friendly ``code-block``."""
has_content = False
def run(self) -> list[nodes.Node]:
branch = _branch(self.config)
content = f"""\
.. code-block:: bash
git clone https://github.com/isaac-sim/IsaacLab.git --branch {branch}
cd IsaacLab
"""
return _parse_rst(self, content)
class IsaacLabKitlessInstallSnippet(SphinxDirective):
"""Render the kit-less clone + install commands from the installation index."""
has_content = False
def run(self) -> list[nodes.Node]:
branch = _branch(self.config)
content = f"""\
.. code-block:: bash
git clone https://github.com/isaac-sim/IsaacLab.git --branch {branch}
cd IsaacLab
./isaaclab.sh --install # or ./isaaclab.sh -i
"""
return _parse_rst(self, content)
class IsaacLabQuickstartInstall(SphinxDirective):
"""Render quickstart install snippets with the pinned release branch."""
option_spec = {
"kitless": directives.flag,
"isaacsim": directives.flag,
"platform": directives.unchanged_required,
}
def run(self) -> list[nodes.Node]:
branch = _branch(self.config)
platform = self.options["platform"].strip().lower()
if platform not in {"linux", "windows"}:
raise self.error(f"Unsupported platform '{platform}'. Use 'linux' or 'windows'.")
if "kitless" in self.options and "isaacsim" in self.options:
raise self.error("Specify only one of :kitless: or :isaacsim:.")
if "kitless" in self.options:
content = _quickstart_kitless(branch, platform)
elif "isaacsim" in self.options:
content = _quickstart_isaacsim(branch, platform)
else:
raise self.error("Specify either :kitless: or :isaacsim:.")
return _parse_rst(self, content)
def _quickstart_kitless(branch: str, platform: str) -> str:
"""Return quickstart reST for kit-less installation."""
if platform == "linux":
return f"""\
.. code-block:: bash
# Install uv (https://docs.astral.sh/uv/getting-started/installation/)
curl -LsSf https://astral.sh/uv/install.sh | sh
git clone https://github.com/isaac-sim/IsaacLab.git --branch {branch}
cd IsaacLab
uv venv --python 3.12 --seed env_isaaclab
source env_isaaclab/bin/activate
./isaaclab.sh -i
"""
return f"""\
.. code-block:: batch
:: Install uv: https://docs.astral.sh/uv/getting-started/installation/
git clone https://github.com/isaac-sim/IsaacLab.git --branch {branch}
cd IsaacLab
uv venv --python 3.12 --seed env_isaaclab
env_isaaclab\\Scripts\\activate
isaaclab.bat -i
"""
def _quickstart_isaacsim(branch: str, platform: str) -> str:
"""Return quickstart reST for full Isaac Sim installation."""
if platform == "linux":
return f"""\
.. code-block:: bash
git clone https://github.com/isaac-sim/IsaacLab.git --branch {branch}
cd IsaacLab
uv venv --python 3.12 --seed env_isaaclab
source env_isaaclab/bin/activate
uv pip install --upgrade pip
uv pip install "isaacsim[all,extscache]==6.0.1.0" \\
--extra-index-url https://pypi.nvidia.com \\
--index-strategy unsafe-best-match --prerelease=allow
uv pip install -U torch==2.10.0 torchvision==0.25.0 \\
--index-url https://download.pytorch.org/whl/cu128
./isaaclab.sh -i
"""
return f"""\
.. code-block:: batch
:: Install uv: https://docs.astral.sh/uv/getting-started/installation/
git clone https://github.com/isaac-sim/IsaacLab.git --branch {branch}
cd IsaacLab
uv venv --python 3.12 --seed env_isaaclab
env_isaaclab\\Scripts\\activate
uv pip install --upgrade pip
uv pip install "isaacsim[all,extscache]==6.0.1.0" ^
--extra-index-url https://pypi.nvidia.com ^
--index-strategy unsafe-best-match --prerelease=allow
uv pip install -U torch==2.10.0 torchvision==0.25.0 ^
--index-url https://download.pytorch.org/whl/cu128
isaaclab.bat -i
"""
def setup(app):
"""Register Isaac Lab documentation directives."""
app.add_config_value("isaaclab_latest_branch", "release/3.0.0-beta2", "env")
app.add_directive("isaaclab-clone-commands", IsaacLabCloneCommands)
app.add_directive("isaaclab-clone-https", IsaacLabCloneHttps)
app.add_directive("isaaclab-kitless-install-snippet", IsaacLabKitlessInstallSnippet)
app.add_directive("isaaclab-quickstart-install", IsaacLabQuickstartInstall)
return {
"version": "0.1",
"parallel_read_safe": True,
"parallel_write_safe": True,
}
|