Skip to content

Commit 507c141

Browse files
authored
Merge pull request #769 from NVIDIA/am/doc-rst
Provide CMS-friendly documentation build
2 parents 7b63c79 + 18f3d8c commit 507c141

25 files changed

+2003
-1286
lines changed

.github/workflows/docs.yml

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Build and Deploy Documentation
33
on:
44
push:
55
branches: [ main ]
6+
tags: [ 'v*' ]
67
workflow_dispatch: # Allow manual triggering
78

89
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
@@ -23,30 +24,44 @@ jobs:
2324
with:
2425
enable-cache: true
2526

26-
- name: Set up environment
27-
run: |
28-
set -eE
29-
set -o pipefail
30-
31-
uv sync --extra docs
32-
3327
- name: Build documentation
34-
run: |
35-
set -eE
36-
set -o pipefail
37-
38-
source .venv/bin/activate
39-
cd doc
40-
make html
41-
42-
- name: Add .nojekyll file
43-
run: touch doc/_build/html/.nojekyll
28+
run: make -C doc/ html
4429

4530
- name: Upload artifact
4631
uses: actions/upload-pages-artifact@v3
4732
with:
4833
path: ./doc/_build/html
4934

35+
build-cms:
36+
name: Build CMS Documentation
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v4
41+
42+
- name: Install uv
43+
uses: astral-sh/setup-uv@v5
44+
with:
45+
enable-cache: true
46+
47+
- name: Set up Node.js
48+
uses: actions/setup-node@v6
49+
with:
50+
node-version: '24'
51+
52+
- name: Build CMS documentation
53+
run: make -C doc/ cms-html
54+
55+
- name: Sanitize artifact name
56+
id: artifact-name
57+
run: echo "name=cloudai-docs-cms-$(echo '${{ github.ref_name }}' | tr '/' '-')" >> $GITHUB_OUTPUT
58+
59+
- name: Upload CMS docs artifact
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: ${{ steps.artifact-name.outputs.name }}
63+
path: doc/_build-cms/html
64+
5065
deploy:
5166
name: Deploy to GitHub Pages
5267
needs: build

doc/DEV.md

Lines changed: 0 additions & 86 deletions
This file was deleted.

doc/DEV.rst

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
Development
2+
===========
3+
4+
This document targets developers who want to contribute to the project's core.
5+
6+
.. mermaid::
7+
8+
graph TD
9+
subgraph _core
10+
base_modules
11+
core_implementations
12+
registry
13+
end
14+
15+
subgraph runners
16+
SlurmRunner
17+
StandaloneRunner
18+
end
19+
20+
subgraph installers
21+
SlurmInstaller
22+
StandaloneInstaller
23+
end
24+
25+
subgraph systems
26+
SlurmSystem
27+
StandaloneSystem
28+
end
29+
30+
installers --> _core
31+
runners --> _core
32+
systems --> _core
33+
34+
Core Modules
35+
------------
36+
37+
We use `import-linter <https://github.com/seddonym/import-linter>`_ to ensure no core modules import higher level modules.
38+
39+
``Registry`` object is a singleton that holds implementation mappings. Users can register their own implementations to the registry or replace the default implementations.
40+
41+
Cache
42+
-----
43+
44+
Some prerequisites can be installed. For example: Docker images, git repos with executable scripts, etc. All such "installables" are kept under system ``install_path``.
45+
46+
Installables are shared among all tests. So if any number of tests use the same installable, it is installed only once for a particular system TOML.
47+
48+
.. mermaid::
49+
50+
classDiagram
51+
class Installable {
52+
<<abstract>>
53+
+ __eq__(other: object)
54+
+ __hash__()
55+
}
56+
57+
class DockerImage {
58+
+ url: str
59+
+ install_path: str | Path
60+
}
61+
62+
class GitRepo {
63+
+ git_url: str
64+
+ commit_hash: str
65+
+ install_path: Path
66+
}
67+
68+
class PythonExecutable {
69+
+ git_repo: GitRepo
70+
+ venv_path: Path
71+
}
72+
73+
Installable <|-- DockerImage
74+
Installable <|-- GitRepo
75+
Installable <|-- PythonExecutable
76+
PythonExecutable --> GitRepo
77+
78+
class BaseInstaller {
79+
<<abstract>>
80+
+ install(items: Iterable[Installable])
81+
+ uninstall(items: Iterable[Installable])
82+
+ is_installed(items: Iterable[Installable]) -> bool
83+
84+
* install_one(item: Installable)
85+
* uninstall_one(item: Installable)
86+
* is_installed_one(item: Installable) -> bool
87+
}
88+
89+
BaseInstaller <|-- SlurmInstaller
90+
BaseInstaller <|-- StandaloneInstaller
91+

doc/Makefile

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,45 @@
1515
# limitations under the License.
1616

1717
SPHINXOPTS ?=
18-
SPHINXBUILD ?= sphinx-build
19-
SOURCEDIR = .
20-
BUILDDIR = _build
18+
SOURCEDIR = .
19+
BUILDDIR = _build
20+
BUILDDIR_CMS = _build-cms
21+
22+
NODE_MODULES = $(BUILDDIR_CMS)/node_modules
23+
MMDC = $(NODE_MODULES)/.bin/mmdc
24+
PUPPETEER_CFG = $(BUILDDIR_CMS)/puppeteer-config.json
25+
26+
.PHONY: help html cms-html install-mermaid clean
2127

2228
help:
23-
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
29+
@echo "Available targets:"
30+
@echo " html - Build documentation for GitHub Pages (nvidia_sphinx_theme) -> $(BUILDDIR)/"
31+
@echo " cms-html - Build documentation for BrightSpot CMS (sphinx_rtd_theme, PNG mermaid) -> $(BUILDDIR_CMS)/"
32+
@echo " clean - Remove all build directories"
33+
34+
# Default html target (GitHub Pages)
35+
html:
36+
@echo "Setting up environment for GitHub Pages build..."
37+
@cd .. && uv sync --extra docs
38+
@echo "Building documentation..."
39+
@cd .. && uv run sphinx-build -M html "doc" "doc/$(BUILDDIR)" $(SPHINXOPTS)
40+
@touch $(BUILDDIR)/html/.nojekyll
41+
42+
cms-html: install-mermaid
43+
@echo "Setting up environment for CMS build..."
44+
@cd .. && uv sync --extra docs-cms
45+
@echo "Building documentation..."
46+
@cd .. && CLOUDAI_DOC_TARGET=cms uv run sphinx-build -M html "doc" "doc/$(BUILDDIR_CMS)" $(SPHINXOPTS)
47+
48+
install-mermaid: $(MMDC)
2449

25-
.PHONY: help Makefile
50+
$(MMDC):
51+
@command -v npm >/dev/null 2>&1 || { echo "Error: npm is required for CMS build but not found. Please install Node.js/npm first."; exit 1; }
52+
@echo "Installing @mermaid-js/mermaid-cli via npm..."
53+
@mkdir -p $(BUILDDIR_CMS)
54+
@cd $(BUILDDIR_CMS) && npm install @mermaid-js/mermaid-cli@^11
55+
@echo '{"args": ["--no-sandbox"]}' > $(PUPPETEER_CFG)
56+
@echo "mermaid-cli installed successfully."
2657

27-
%: Makefile
28-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
58+
clean:
59+
@rm -rf $(BUILDDIR) $(BUILDDIR_CMS)

0 commit comments

Comments
 (0)