Skip to content

Commit 7474649

Browse files
mckimnhemildesai
andauthored
Add autogenerated API reference content to the documentation (#190)
* Resolve doc build errors Signed-off-by: Nathan McKimpson <[email protected]> * Remove previous API doc files Signed-off-by: Nathan McKimpson <[email protected]> * Add initial auto-generated API and NVIDIA theme Signed-off-by: Nathan McKimpson <[email protected]> * Update __init__.py Signed-off-by: Hemil Desai <[email protected]> --------- Signed-off-by: Nathan McKimpson <[email protected]> Signed-off-by: Hemil Desai <[email protected]> Co-authored-by: Hemil Desai <[email protected]>
1 parent 5c23986 commit 7474649

File tree

17 files changed

+490
-376
lines changed

17 files changed

+490
-376
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ instance/
7171

7272
# Sphinx documentation
7373
docs/_build/
74+
docs/source/api/
7475

7576
# PyBuilder
7677
.pybuilder/

CONTRIBUTING.md

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Not all steps are necessary for some contributions, so read the linked sections
1717
- [Whom should you ask for review:](#whom-should-you-ask-for-review)
1818

1919
## General principles
20+
2021
1. **User-oriented**: make it easy for end users, even at the cost of writing more code in the background
2122
1. **Robust**: make it hard for users to make mistakes.
2223
1. **Reusable**: for every piece of code, think about how it can be reused in the future and make it easy to be reused.
@@ -25,6 +26,7 @@ Not all steps are necessary for some contributions, so read the linked sections
2526
1. **Sensible**: code should make sense. If you think a piece of code might be confusing, write comments.
2627

2728
## Environment Setup
29+
2830
We use [uv](https://docs.astral.sh/uv/) to develop NeMo Run. The following steps should get you started with the dev environment:
2931

3032
1. Install [uv](https://docs.astral.sh/uv/getting-started/installation/)
@@ -34,16 +36,19 @@ We use [uv](https://docs.astral.sh/uv/) to develop NeMo Run. The following steps
3436
If all tests passed, then you should be good to get started with the development of NeMo-Run.
3537

3638
## Code Structure
39+
3740
The repository is home to flexible Python modules, sample scripts, tests, and more.
3841
Here is a brief overview of where everything lives:
42+
3943
- [docker](docker/) - Dockerfiles to build NeMo with NeMo Run.
4044
- [docs](docs/) - Walkthroughs and guides the library.
4145
- [examples](examples/) - Examples for how users may want to use NeMo Run.
4246
- [src](src/) -
43-
- [nemo_run](src/nemo_run/) - The source code for NeMo Run.
47+
- [nemo_run](src/nemo_run/) - The source code for NeMo Run.
4448
- [test](test/) - Unit tests.
4549

4650
## Examples and Documentation
51+
4752
Examples provide an easy way for users to see how the NeMo Run works in action.
4853
They should be incredibly lightweight and rely mostly on `nemo_run` for their functionality
4954
Most should be designed for a user to get up and running on their local machines, but examples on remote clusters are welcomed if it makes sense.
@@ -54,35 +59,49 @@ It should include both an explanation of the API, and how it's used in its corre
5459
The documentation should also cover potential pitfalls and caveats.
5560
This existing examples and documentation should serve as a good reference to what is expected.
5661

62+
### Building Documentation
63+
64+
Run the following commands to switch to the project documentation folder and generate HTML output.
65+
66+
```sh
67+
cd docs/
68+
uv run --group docs sphinx-build source/ _build/html
69+
```
70+
71+
The resulting HTML files are generated in a `_build/html` folder created under the project `docs/` folder.
72+
5773
## Python style
58-
We use [``ruff``](https://docs.astral.sh/ruff/) for linting and formatting. To lint and format your code, you can run `uv run --group lint -- ruff check` and `uv run --group lint -- ruff format` respectively.
74+
75+
We use [`ruff`](https://docs.astral.sh/ruff/) for linting and formatting. To lint and format your code, you can run `uv run --group lint -- ruff check` and `uv run --group lint -- ruff format` respectively.
5976

6077
## Unit tests
78+
6179
Unit tests should be simple and fast.
6280
Developers should be able to run them frequently while developing without any slowdown.
6381

6482
## Pull Requests (PR) Guidelines
6583

6684
**Send your PRs to the `main` or `dev` branch**
6785

68-
1) Make sure your PR does one thing. Have a clear answer to "What does this PR do?".
69-
2) Read General Principles and style guide above
70-
3) Make sure you sign off your commits. E.g. use ``git commit --signoff`` when committing.
71-
4) Make sure all unit tests finish successfully before sending PR
72-
5) Send your PR and request a review
86+
1. Make sure your PR does one thing. Have a clear answer to "What does this PR do?".
87+
2. Read General Principles and style guide above
88+
3. Make sure you sign off your commits. E.g. use `git commit --signoff` when committing.
89+
4. Make sure all unit tests finish successfully before sending PR
90+
5. Send your PR and request a review
7391

7492
The `dev` branch is for active development and may be unstable. Unit tests are expected to pass before merging into `dev` or `main`.
7593
Every release `dev` and `main` will sync to be the same.
7694

7795
## Sign Your Work
7896

79-
* We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license.
97+
- We require that all contributors "sign-off" on their commits. This certifies that the contribution is your original work, or you have rights to submit it under the same license, or a compatible license.
98+
99+
- Any contribution which contains commits that are not Signed-Off will not be accepted.
80100

81-
* Any contribution which contains commits that are not Signed-Off will not be accepted.
101+
- To sign off on a commit you simply use the `--signoff` option when committing your changes:
82102

83-
* To sign off on a commit you simply use the `--signoff` option when committing your changes:
84103
```bash
85-
$ git commit --signoff -m "Add cool feature."
104+
git commit --signoff -m "Add cool feature."
86105
```
87106

88107
## Full text of the DCO:

docs/Makefile

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

docs/make.bat

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

docs/source/api/configuration.rst

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

docs/source/api/execution.rst

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

docs/source/api/index.rst

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

docs/source/api/management.rst

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

docs/source/conf.py

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@
66
# -- Project information -----------------------------------------------------
77
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
88

9+
import sys
10+
from pathlib import Path
11+
12+
sys.path.append(str(Path("../../examples").resolve()))
13+
914
project = "NeMo-Run"
10-
copyright = "2024, NVIDIA"
15+
copyright = "2025, NVIDIA"
1116
author = "NVIDIA"
1217
release = "0.1.0"
1318

@@ -16,6 +21,7 @@
1621

1722
extensions = [
1823
"myst_parser",
24+
"autoapi.extension",
1925
"sphinx.ext.autodoc",
2026
"sphinx.ext.doctest",
2127
"sphinx.ext.intersphinx",
@@ -29,16 +35,30 @@
2935
]
3036

3137
templates_path = ["_templates"]
32-
exclude_patterns = []
38+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
3339
python_maximum_signature_line_length = 88
34-
autodoc_default_options = {
35-
"member-order": "bysource",
36-
"special-members": "__init__",
37-
"undoc-members": True,
38-
"exclude-members": "__weakref__",
39-
}
40-
autodoc_class_signature = "separated"
41-
autodoc_inherit_docstrings = True
40+
41+
# Autoapi settings
42+
autoapi_generate_api_docs = True
43+
autoapi_keep_files = False
44+
autoapi_add_toctree_entry = False
45+
autoapi_type = "python"
46+
autoapi_dirs = ["../../nemo_run"]
47+
autoapi_file_pattern = "*.py"
48+
autoapi_root = "api"
49+
autoapi_options = [
50+
"members",
51+
"show-inheritance",
52+
"show-module-summary",
53+
"special-members",
54+
"imported-members",
55+
]
56+
57+
# Autodoc settings
58+
autodoc_typehints = "signature"
59+
60+
# MyST settings
61+
myst_heading_anchors = 3
4262

4363
# Napoleon settings
4464
napoleon_google_docstring = True
@@ -56,5 +76,4 @@
5676
# -- Options for HTML output -------------------------------------------------
5777
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
5878

59-
html_theme = "alabaster"
60-
html_static_path = ["_static"]
79+
html_theme = "nvidia_sphinx_theme"

0 commit comments

Comments
 (0)