-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Adds per-branch cloning command to docs #5952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # 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.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) | ||
|
|
||
|
|
||
| def setup(app): | ||
| """Register Isaac Lab documentation directives.""" | ||
| app.add_config_value("isaaclab_latest_branch", "main", "env") | ||
| app.add_directive("isaaclab-clone-commands", IsaacLabCloneCommands) | ||
| return { | ||
| "version": "0.1", | ||
| "parallel_read_safe": True, | ||
| "parallel_write_safe": True, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| import os | ||
| import sys | ||
|
|
||
| sys.path.insert(0, os.path.abspath("_extensions")) | ||
| sys.path.insert(0, os.path.abspath("../source/isaaclab")) | ||
| sys.path.insert(0, os.path.abspath("../source/isaaclab/isaaclab")) | ||
| sys.path.insert(0, os.path.abspath("../source/isaaclab_assets")) | ||
|
|
@@ -42,6 +43,13 @@ | |
| full_version = f.read().strip() | ||
| version = ".".join(full_version.split(".")[:3]) | ||
|
|
||
| # Latest branch referenced by installation documentation. | ||
| isaaclab_latest_branch = os.getenv("ISAACLAB_LATEST_BRANCH", "main") | ||
|
|
||
| rst_prolog = f""" | ||
| .. |isaaclab_latest_branch| replace:: {isaaclab_latest_branch} | ||
| """ | ||
|
Comment on lines
+49
to
+51
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
||
|
|
||
| # -- General configuration --------------------------------------------------- | ||
|
|
||
| # Add any Sphinx extension module names here, as strings. They can be | ||
|
|
@@ -65,6 +73,7 @@ | |
| "sphinx_design", | ||
| "sphinx_tabs.tabs", # backwards compatibility for building docs on v1.0.0 | ||
| "sphinx_multiversion", | ||
| "isaaclab_docs", | ||
| ] | ||
|
|
||
| # mathjax hacks | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cd IsaacLabis a new, undocumented behaviour changeThe previous inline
code::blocks showed only thegit clonecommand. This directive now appendscd IsaacLabto both SSH and HTTPS variants. In the deployment/container context (deployment/index.rst) the text that follows the clone block does not assume the working directory isIsaacLab, so readers may find the extra step confusing or superfluous there. If the intent is to always includecd IsaacLab, the PR description should mention it; if it is incidental, consider dropping thecdfrom the generated content.