Skip to content

Commit 3aa8b58

Browse files
committed
docs
1 parent b027b5f commit 3aa8b58

4 files changed

Lines changed: 91 additions & 39 deletions

File tree

.github/workflows/build.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Tuxemon
22
on:
33
push:
44
branches:
5-
- development # only pushes on development. So the release variable will be set correctly
5+
- development # only pushes on development. So the release variable will be set correctly
66
pull_request:
77
page_build:
88
workflow_dispatch:
@@ -13,24 +13,25 @@ env:
1313

1414
jobs:
1515
appdata_validation:
16-
uses: ./.github/workflows/appdata_validation.yml
16+
uses: ./.github/workflows/appdata_validation.yml
1717

1818

1919
flatpak:
2020
uses: ./.github/workflows/flatpak.yml
2121
with:
2222
IS_RELEASE: ${{ github.event_name == 'push' && github.ref_type == 'tag' && startswith(github.ref_name, 'v') }}
2323

24-
2524
build_installer_windows:
26-
uses: ./.github/workflows/installer_windows.yml
27-
25+
uses: ./.github/workflows/installer_windows.yml
2826

2927
python-app:
30-
uses: ./.github/workflows/python-app.yml
28+
uses: ./.github/workflows/python-app.yml
29+
30+
docs:
31+
uses: ./.github/workflows/docs.yml
3132

3233
publish:
33-
needs: [flatpak, build_installer_windows]
34+
needs: [flatpak, build_installer_windows, docs]
3435
runs-on: ubuntu-latest # does not matter which
3536
# a prerelase is created when pushing to master
3637
# a release is created when a tag will be set

.github/workflows/docs.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Docs Build
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
docs:
12+
name: Docs Build Check
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Python 3.10
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: '3.10'
24+
25+
- name: Install documentation dependencies and project
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install sphinx sphinx-rtd-theme sphinx-autodoc-typehints
29+
pip install .
30+
31+
- name: Build Sphinx Documentation
32+
run: |
33+
sphinx-build -W -b html docs/ docs/_build

.readthedocs.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,21 @@
55
# Required
66
version: 2
77

8+
# Required
9+
version: 2
10+
811
# Build documentation in the docs/ directory with Sphinx
912
sphinx:
1013
configuration: docs/conf.py
1114

1215
python:
1316
version: 3.10
1417
install:
15-
- requirements: docs/requirements.txt
18+
- requirements:
19+
- sphinx
20+
- sphinx-rtd-theme
21+
- sphinx-autodoc-typehints
22+
- sphinx.ext.napoleon
23+
24+
- method: pip
25+
path: .

docs/conf.py

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,92 +4,100 @@
44
# list see the documentation:
55
# https://www.sphinx-doc.org/en/master/usage/configuration.html
66

7-
# -- Path setup --------------------------------------------------------------
8-
9-
# If extensions (or modules to document with autodoc) are in another directory,
10-
# add these directories to sys.path here. If the directory is relative to the
11-
# documentation root, use os.path.abspath to make it absolute, like shown here.
7+
# -- Path setup for importing project paths ------------------------------------
8+
#
9+
# The documentation must be able to import the main project package (tuxemon)
10+
# for extensions like autodoc and apidoc to work correctly.
1211
#
13-
import os
1412
import sys
15-
sys.path.append(os.path.abspath("./ext"))
16-
sys.path.insert(0, os.path.abspath('../'))
13+
from pathlib import Path
14+
from typing import Any
15+
from tuxemon.constants.paths import LIBDIR
1716

17+
CONF_DIR = Path(__file__).parent.resolve()
18+
PROJECT_ROOT = CONF_DIR.parent
19+
20+
sys.path.insert(0, str(PROJECT_ROOT))
21+
sys.path.append(str(CONF_DIR / "ext"))
22+
sys.path.append(str(Path(__file__).parent.resolve() / "ext"))
1823

1924
# -- Project information -----------------------------------------------------
20-
from typing import Any
2125

2226
project = 'Tuxemon'
2327
copyright = '2015-2025, William Edwards'
2428
author = 'William Edwards'
2529

2630
# The full version, including alpha/beta/rc tags
31+
# You could potentially get a dynamic version from your project here
2732
release = 'alpha'
2833

2934

3035
# -- General configuration ---------------------------------------------------
3136

32-
# Add any Sphinx extension module names here, as strings. They can be
33-
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
34-
# ones.
37+
# Add any Sphinx extension module names here, as strings.
3538
extensions = [
3639
'sphinx.ext.autodoc',
3740
'sphinx.ext.todo',
3841
'sphinx.ext.viewcode',
3942
'sphinx.ext.githubpages',
4043
'sphinx.ext.napoleon',
41-
'script_documenter',
44+
'script_documenter',
4245
]
4346

4447
# Add any paths that contain templates here, relative to this directory.
4548
templates_path = ['_templates']
4649

4750
# List of patterns, relative to source directory, that match files and
4851
# directories to ignore when looking for source files.
49-
# This pattern also affects html_static_path and html_extra_path.
50-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
52+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', 'autogen']
5153

5254

53-
# -- Options for HTML output ----------------------------------------------
55+
# -- Options for HTML output -------------------------------------------------
5456

55-
# The theme to use for HTML and HTML Help pages. See the documentation for
56-
# a list of builtin themes.
57-
#
57+
# The theme to use for HTML and HTML Help pages.
5858
html_theme = 'sphinx_rtd_theme'
5959

60-
# Add any paths that contain custom static files (such as style sheets) here,
61-
# relative to this directory. They are copied after the builtin static files,
62-
# so a file named "default.css" will overwrite the builtin "default.css".
60+
# Add any paths that contain custom static files (such as style sheets) here.
6361
html_static_path = ['_static']
6462

63+
64+
# -- Options for Autodoc and Napoleon ----------------------------------------
65+
66+
# Tell Autodoc how to display type hints
6567
autodoc_typehints = "description"
6668

69+
# Disable NumPy docstring parsing if you primarily use Google-style docstrings
6770
napoleon_numpy_docstring = False
6871

72+
# Define your custom Napoleon sections
6973
napoleon_custom_sections = [
7074
"Script usage",
7175
("Script parameters", "params_style")
7276
]
7377

7478

75-
# Apidoc call to generate automatic reference docs. Taken from
76-
# https://github.com/readthedocs/readthedocs.org/issues/1139#issuecomment-398083449
79+
# -- Apidoc Automation -------------------------------------------------------
80+
7781
def run_apidoc(_: Any) -> None:
82+
"""
83+
Automatically runs sphinx-apidoc before the Sphinx build process begins.
84+
This generates API reference files for all your project's modules.
85+
"""
7886
ignore_paths: list[str] = []
7987

8088
argv = [
81-
"-f",
82-
"-e",
83-
"-M",
84-
"-o",
85-
"autogen",
86-
".."
89+
"-f", # Force overwrite output files
90+
"-e", # Put documentation for each module on its own page
91+
"-M", # Look for module files instead of package files
92+
"-o", # Output directory
93+
"autogen", # Name of the directory to store the generated files
94+
str(PROJECT_ROOT) # Use the repo root so apidoc scans everything
8795
] + ignore_paths
8896

89-
# Sphinx 1.7+
9097
from sphinx.ext import apidoc
9198
apidoc.main(argv)
9299

93100

94101
def setup(app: Any) -> None:
102+
"""Connect the run_apidoc function to the 'builder-inited' Sphinx event."""
95103
app.connect('builder-inited', run_apidoc)

0 commit comments

Comments
 (0)