Skip to content

Commit 7184f08

Browse files
authored
Add sphinxcontrib-katex and docs guide (#10)
* Add sphinxcontrib-katex Signed-off-by: Charlie Truong <[email protected]> * Add docs for building docs Signed-off-by: Charlie Truong <[email protected]> * Update contribution guide to include uv guideline Signed-off-by: Charlie Truong <[email protected]> --------- Signed-off-by: Charlie Truong <[email protected]>
1 parent 72c2391 commit 7184f08

File tree

6 files changed

+99
-3
lines changed

6 files changed

+99
-3
lines changed

CONTRIBUTING.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,37 @@
44

55
Use [abseil-py](https://github.com/abseil/abseil-py/tree/main)'s **logging**, **testing** and **flags** instead of Python's own **logging**, **unittest** and **argparse**.
66

7+
We use [uv](https://docs.astral.sh/uv/) for managing dependencies. For reproducible builds, our project tracks the generated `uv.lock` file in the repository.
8+
On a weekly basis, the CI attemps an update of the lock file to test against upstream dependencies.
9+
10+
New required dependencies can be added by `uv add $DEPENDENCY`.
11+
12+
New optional dependencies can be added by `uv add --optional --extra $EXTRA $DEPENDENCY`.
13+
14+
`EXTRA` refers to the subgroup of extra-dependencies to which you're adding the new dependency.
15+
Example: For adding a TRT-LLM specific dependency, run `uv add --optional --extra trtllm $DEPENDENCY`.
16+
17+
New dependencies to a dependency group can be added with `uv add --group $GROUP $DEPENDENCY`. Dependency groups are specific to uv and are also optional dependencies but not intended to be used with the package such as docs dependencies.
18+
19+
Alternatively, the `pyproject.toml` file can also be modified directly.
20+
21+
Adding a new dependency will update UV's lock-file. Please check this into your branch:
22+
23+
```bash
24+
git add uv.lock pyproject.toml
25+
git commit -m "build: Adding dependencies"
26+
git push
27+
```
28+
29+
### 🧹 Linting and Formatting
30+
31+
We use [ruff](https://docs.astral.sh/ruff/) for linting and formatting. CI does not auto-fix linting and formatting issues, but most issues can be fixed by running the following command:
32+
33+
```bash
34+
uv run ruff check --fix .
35+
uv run ruff format .
36+
```
37+
738
## Coding Style
839

940
We generally follow [Google's style guides](https://google.github.io/styleguide/) , with some exceptions:
@@ -16,7 +47,7 @@ We generally follow [Google's style guides](https://google.github.io/styleguide/
1647

1748
Although common, **mixed case is not allowed** in any code.
1849

19-
Run pre-commit at local before submitting merge request. You can also read [.pre-commit-config.yaml]( .pre-commit-config.yaml) to understand what are being forced. The **flake8** and **mypy** settings are inherited from PyTorch.
50+
Run pre-commit at local before submitting merge request. You can also read [.pre-commit-config.yaml]( .pre-commit-config.yaml) to understand what are being forced. The **flake8** and **mypy** settings are inherited from PyTorch.
2051

2152
## Test
2253

@@ -44,9 +75,9 @@ We use [abseil-py](https://github.com/abseil/abseil-py/tree/main) **testing** be
4475
```
4576
Developer Certificate of Origin
4677
Version 1.1
47-
78+
4879
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
49-
80+
5081
Everyone is permitted to copy and distribute verbatim copies of this
5182
license document, but changing it is not allowed.
5283

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"sphinx.ext.doctest", # Allows testing in docstrings
4040
"sphinx.ext.napoleon", # For google style docstrings
4141
"sphinx_copybutton", # For copy button in code blocks
42+
"sphinxcontrib.katex", # For KaTeX math rendering
4243
]
4344

4445
templates_path = ["_templates"]

docs/documentation.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Documentation Development
2+
3+
- [Documentation Development](#documentation-development)
4+
- [Build the Documentation](#build-the-documentation)
5+
- [Live Building](#live-building)
6+
7+
8+
## Build the Documentation
9+
10+
The following sections describe how to set up and build the NeMo RL documentation.
11+
12+
Switch to the documentation source folder and generate HTML output.
13+
14+
```sh
15+
cd docs/
16+
uv run --only-group docs sphinx-build . _build/html
17+
```
18+
19+
* The resulting HTML files are generated in a `_build/html` folder that is created under the project `docs/` folder.
20+
* The generated python API docs are placed in `apidocs` under the `docs/` folder.
21+
22+
## Checking for Broken Links
23+
24+
To check for broken http links in the docs, run this command:
25+
26+
```sh
27+
cd docs/
28+
uv run --only-group docs sphinx-build --builder linkcheck . _build/linkcheck
29+
```
30+
31+
It will output a JSON file at `_build/linkcheck/output.json` with links it found while building the
32+
docs. Records will have a status of `broken` if the link is not reachable. The `docs/conf.py` file is
33+
configured to ignore github links because the CI test will often experience rate limit errors.
34+
Comment out the `linkcheck_ignore` variable there to check all the links.
35+
36+
## Live Building
37+
38+
When writing documentation, it can be helpful to serve the documentation and have it update live while you edit.
39+
40+
To do so, run:
41+
42+
```sh
43+
cd docs/
44+
uv run --only-group docs sphinx-autobuild . _build/html --port 12345 --host 0.0.0.0
45+
```
46+
47+
Open a web browser and go to `http://${HOST_WHERE_SPHINX_COMMAND_RUN}:12345` to view the output.

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
:caption: Development
77
:hidden:
88
9+
documentation.md
910
apidocs/index.rst
1011
```

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ docs = [
7272
"sphinx-autobuild>=2024.10.3",
7373
"sphinx-autodoc2>=0.5.0",
7474
"sphinx-copybutton>=0.5.2",
75+
"sphinxcontrib-katex>=0.9.11",
7576
]
7677
test = [
7778
"coverage>=7.8.1",

uv.lock

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)