Skip to content

Commit 463e8bb

Browse files
committed
add docs
1 parent c766528 commit 463e8bb

7 files changed

Lines changed: 483 additions & 7 deletions

File tree

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,4 +337,7 @@ result/*
337337

338338
dataset/*
339339
!dataset/.gitkeep
340-
.claude
340+
.claude
341+
342+
doc/docs/build/
343+
doc/docs/api/

doc/docs/conf.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# For the full list of built-in configuration values, see the documentation:
4+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
5+
6+
import sys
7+
from pathlib import Path
8+
9+
sys.path.insert(0, str(Path("../../src").resolve()))
10+
11+
# -- Project information -----------------------------------------------------
12+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
13+
14+
project = "PyTorch-Project-Template"
15+
copyright = "2025, Junya Morioka"
16+
author = "Junya Morioka"
17+
18+
# -- General configuration ---------------------------------------------------
19+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
20+
21+
extensions = [
22+
"myst_parser",
23+
"sphinx.ext.autodoc",
24+
"sphinx.ext.viewcode",
25+
"sphinx.ext.napoleon",
26+
"autoapi.extension",
27+
]
28+
29+
templates_path = ["_templates"]
30+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
31+
32+
language = "en"
33+
34+
# -- Options for HTML output -----------------------------------------------
35+
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
36+
37+
html_theme = "furo"
38+
39+
# -- Options for autodoc --------------------------------------------------
40+
autodoc_typehints = "signature"
41+
42+
# -- Options for viewcode --------------------------------------------------
43+
viewcode_follow_imported_members = True
44+
45+
# -- Options for autoapi ---------------------------------------------------
46+
autoapi_type = "python"
47+
autoapi_dirs = ["../../src"]
48+
autoapi_root = "api"
49+
autoapi_keep_files = True
50+
autoapi_python_class_content = "init"
51+
autoapi_options = [
52+
"members",
53+
"undoc-members",
54+
"private-members",
55+
"show-inheritance",
56+
"show-module-summary",
57+
"imported-members",
58+
]

doc/docs/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# PyTorch-Project-Template
2+
3+
```{toctree}
4+
:caption: 'API Reference'
5+
:maxdepth: 3
6+
7+
api/src/index
8+
```

pyproject.toml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ dependencies = [
2525
"timm>=1.0.15",
2626
]
2727

28+
[dependency-groups]
29+
doc = [
30+
"furo>=2024.8.6",
31+
"myst-parser>=4.0.1",
32+
"sphinx>=8.2.3",
33+
"sphinx-autoapi>=3.6.0",
34+
"sphinx-autobuild>=2024.10.3",
35+
]
36+
dev = ["mypy>=1.16.0", "pre-commit>=4.2.0", "pytest>=8.3.2", "ruff>=0.6.2"]
37+
2838
[build-system]
2939
requires = ["hatchling"]
3040
build-backend = "hatchling.build"
@@ -37,12 +47,7 @@ typeCheckingMode = "off"
3747
exclude = ["dataset", "result", ".tmp", ".git", ".venv", ".vscode"]
3848

3949
[tool.uv]
40-
dev-dependencies = [
41-
"mypy>=1.16.0",
42-
"pre-commit>=4.2.0",
43-
"pytest>=8.3.2",
44-
"ruff>=0.6.2",
45-
]
50+
default-groups = "all"
4651

4752
[tool.uv.sources]
4853
torch = [

script/run_docs.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
DOC_DIR=./doc/docs
4+
PACKAGE_DIR=./src
5+
6+
rm -rf $DOC_DIR/api $DOC_DIR/build
7+
8+
# Run live server with watch on source code directory
9+
sphinx-autobuild -b html $DOC_DIR $DOC_DIR/build --port 38000 --watch $PACKAGE_DIR

src/models/base.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ class BaseModel(nn.Module):
1212
def __init__(
1313
self, cfg: dict | None, cfg_loss: dict | None = None, phase: PhaseStr = "train"
1414
) -> None:
15+
"""
16+
Base model class.
17+
18+
Args:
19+
cfg: Configuration dictionary.
20+
cfg_loss: Configuration dictionary for loss.
21+
phase: Phase of the model. (train, val, test)
22+
"""
1523
super().__init__()
1624
self.cfg = cfg
1725
self.cfg_loss = cfg_loss

0 commit comments

Comments
 (0)