Skip to content

Commit 59eec3e

Browse files
skywchtruong814
andauthored
Setup sphinx docs (#12)
* add sphinx docs Signed-off-by: Hao Wu <[email protected]> * fix some minor doc error Signed-off-by: Hao Wu <[email protected]> * remove autodoc2 Signed-off-by: Hao Wu <[email protected]> * Add sphinx-panels Signed-off-by: Charlie Truong <[email protected]> * Remove index.md Signed-off-by: Charlie Truong <[email protected]> * Add project root to python path Signed-off-by: Charlie Truong <[email protected]> * Fix lint error Signed-off-by: Charlie Truong <[email protected]> * Set katex_prerender to False Signed-off-by: Charlie Truong <[email protected]> --------- Signed-off-by: Hao Wu <[email protected]> Signed-off-by: Charlie Truong <[email protected]> Co-authored-by: Charlie Truong <[email protected]>
1 parent 7184f08 commit 59eec3e

File tree

7 files changed

+119
-28
lines changed

7 files changed

+119
-28
lines changed

docs/conf.py

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
import sys
2222

2323

24+
# Add the project root directory to the Python path
25+
sys.path.insert(0, os.path.abspath(".."))
26+
2427
# -- Project information -----------------------------------------------------
2528
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
2629

@@ -33,18 +36,46 @@
3336
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
3437

3538
extensions = [
36-
"myst_parser", # For our markdown docs
37-
"autodoc2", # Generates API docs
3839
"sphinx.ext.viewcode", # For adding a link to view source code in docs
3940
"sphinx.ext.doctest", # Allows testing in docstrings
4041
"sphinx.ext.napoleon", # For google style docstrings
4142
"sphinx_copybutton", # For copy button in code blocks
4243
"sphinxcontrib.katex", # For KaTeX math rendering
44+
"sphinx.ext.autodoc",
45+
"sphinx.ext.autosummary",
46+
"sphinx.ext.intersphinx",
47+
"sphinx.ext.todo",
48+
"sphinx.ext.coverage",
49+
"sphinx.ext.autosectionlabel",
50+
"sphinx_panels",
51+
"sphinx.ext.linkcode",
4352
]
4453

4554
templates_path = ["_templates"]
4655
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
4756

57+
autosummary_generate = True
58+
numpydoc_show_class_members = False
59+
panels_add_bootstrap_css = False
60+
autosectionlabel_prefix_document = True
61+
katex_prerender = False
62+
napoleon_use_ivar = True
63+
html_domain_indices = False
64+
source_suffix = ".rst"
65+
master_doc = "index"
66+
autodoc_docstring_signature = True
67+
intersphinx_mapping = {
68+
"python": ("https://docs.python.org/3", None),
69+
"numpy": ("https://numpy.org/doc/stable", None),
70+
"torch": ("https://pytorch.org/docs/2.5", None),
71+
}
72+
73+
74+
def linkcode_resolve(domain, info):
75+
"""Resolve the linkcode for the given domain and info."""
76+
return None
77+
78+
4879
# -- Options for MyST Parser (Markdown) --------------------------------------
4980
# MyST Parser settings
5081
myst_enable_extensions = [
@@ -57,21 +88,6 @@
5788
]
5889
myst_heading_anchors = 5 # Generates anchor links for headings up to level 5
5990

60-
# -- Options for Autodoc2 ---------------------------------------------------
61-
sys.path.insert(0, os.path.abspath(".."))
62-
63-
autodoc2_packages = [
64-
"../emerging_optimizers", # Path to your package relative to conf.py
65-
]
66-
autodoc2_render_plugin = "myst" # Use MyST for rendering docstrings
67-
autodoc2_output_dir = "apidocs" # Output directory for autodoc2 (relative to docs/)
68-
# This is a workaround that uses the parser located in autodoc2_docstrings_parser.py to allow autodoc2 to
69-
# render google style docstrings.
70-
# Related Issue: https://github.com/sphinx-extensions2/sphinx-autodoc2/issues/33
71-
autodoc2_docstring_parser_regexes = [
72-
(r".*", "docs.autodoc2_docstrings_parser"),
73-
]
74-
7591
# -- Options for HTML output -------------------------------------------------
7692
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
7793

docs/index.md

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

docs/index.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Welcome to Emerging Optimizers's documentation!
2+
===============================================
3+
4+
.. toctree::
5+
:maxdepth: 1
6+
:caption: API documentation
7+
8+
utils
9+
orthogonalized_optimizers
10+
11+
12+
Indices and tables
13+
==================
14+
15+
* :ref:`genindex`
16+
* :ref:`search`

docs/orthogonalized_optimizers.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.. role:: hidden
2+
:class: hidden-section
3+
4+
emerging_optimizers.orthogonalized_optimizers
5+
=============================================
6+
7+
.. automodule:: emerging_optimizers.orthogonalized_optimizers
8+
.. currentmodule:: emerging_optimizers.orthogonalized_optimizers
9+
10+
:hidden:`OrthogonalizedOptimizer`
11+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12+
13+
.. autoclass:: OrthogonalizedOptimizer
14+
:members:
15+
16+
:hidden:`Muon`
17+
~~~~~~~~~~~~~~~
18+
19+
.. autoclass:: Muon
20+
:members:
21+
22+
23+
:hidden:`Newton-Schulz`
24+
~~~~~~~~~~~~~~~~~~~~~~~~
25+
.. automodule:: emerging_optimizers.orthogonalized_optimizers.muon_utils
26+
.. currentmodule:: emerging_optimizers.orthogonalized_optimizers.muon_utils
27+
28+
.. autofunction:: newton_schulz
29+
.. autofunction:: newton_schulz_step
30+
.. autofunction:: newton_schulz_tp

docs/utils.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.. role:: hidden
2+
:class: hidden-section
3+
4+
emerging_optimizers.utils
5+
==========================
6+
7+
.. automodule:: emerging_optimizers.utils
8+
.. currentmodule:: emerging_optimizers.utils
9+
10+
:hidden:`fp32_matmul_precision`
11+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12+
13+
.. autofunction:: fp32_matmul_precision
14+
15+
:hidden:`get_pg_size`
16+
~~~~~~~~~~~~~~~~~~~~~
17+
18+
.. autofunction:: get_pg_size
19+
20+
:hidden:`get_pg_rank`
21+
~~~~~~~~~~~~~~~~~~~~~
22+
23+
.. autofunction:: get_pg_rank

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+
"sphinx-panels>=0.4.1",
7576
"sphinxcontrib-katex>=0.9.11",
7677
]
7778
test = [

uv.lock

Lines changed: 16 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)