Skip to content

Commit 0f87d77

Browse files
committed
docs
1 parent b027b5f commit 0f87d77

11 files changed

Lines changed: 215 additions & 111 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: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,11 @@ sphinx:
1212
python:
1313
version: 3.10
1414
install:
15-
- requirements: docs/requirements.txt
15+
- requirements:
16+
- sphinx
17+
- sphinx-rtd-theme
18+
- sphinx-autodoc-typehints
19+
- sphinx.ext.napoleon
20+
21+
- method: pip
22+
path: .

docs/conf.py

Lines changed: 54 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,92 +4,101 @@
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
1715

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

1923
# -- Project information -----------------------------------------------------
20-
from typing import Any
2124

22-
project = 'Tuxemon'
23-
copyright = '2015-2025, William Edwards'
24-
author = 'William Edwards'
25+
project = "Tuxemon"
26+
copyright = "2015-2025, William Edwards"
27+
author = "William Edwards"
2528

2629
# The full version, including alpha/beta/rc tags
27-
release = 'alpha'
30+
# You could potentially get a dynamic version from your project here
31+
release = "alpha"
2832

2933

3034
# -- General configuration ---------------------------------------------------
3135

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.
36+
# Add any Sphinx extension module names here, as strings.
3537
extensions = [
36-
'sphinx.ext.autodoc',
37-
'sphinx.ext.todo',
38-
'sphinx.ext.viewcode',
39-
'sphinx.ext.githubpages',
40-
'sphinx.ext.napoleon',
41-
'script_documenter',
38+
"sphinx.ext.autodoc",
39+
"sphinx.ext.todo",
40+
"sphinx.ext.viewcode",
41+
"sphinx.ext.githubpages",
42+
"sphinx.ext.napoleon",
43+
"script_documenter",
4244
]
4345

4446
# Add any paths that contain templates here, relative to this directory.
45-
templates_path = ['_templates']
47+
templates_path = ["_templates"]
4648

4749
# List of patterns, relative to source directory, that match files and
4850
# 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']
51+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", "autogen"]
5152

5253

53-
# -- Options for HTML output ----------------------------------------------
54+
# -- Options for HTML output -------------------------------------------------
5455

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

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".
63-
html_static_path = ['_static']
59+
# Add any paths that contain custom static files (such as style sheets) here.
60+
html_static_path = ["_static"]
6461

62+
63+
# -- Options for Autodoc and Napoleon ----------------------------------------
64+
65+
# Tell Autodoc how to display type hints
6566
autodoc_typehints = "description"
6667

68+
# Disable NumPy docstring parsing if you primarily use Google-style docstrings
6769
napoleon_numpy_docstring = False
6870

71+
# Define your custom Napoleon sections
6972
napoleon_custom_sections = [
7073
"Script usage",
71-
("Script parameters", "params_style")
74+
("Script parameters", "params_style"),
7275
]
7376

7477

75-
# Apidoc call to generate automatic reference docs. Taken from
76-
# https://github.com/readthedocs/readthedocs.org/issues/1139#issuecomment-398083449
78+
# -- Apidoc Automation -------------------------------------------------------
79+
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
98+
9199
apidoc.main(argv)
92100

93101

94102
def setup(app: Any) -> None:
95-
app.connect('builder-inited', run_apidoc)
103+
"""Connect the run_apidoc function to the 'builder-inited' Sphinx event."""
104+
app.connect("builder-inited", run_apidoc)

tuxemon/event/actions/dojo_method.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,21 @@ class DojoMethodAction(EventAction):
3131
Represents an event action for the monks in the Dojo (Spyder).
3232
3333
Script Usage:
34-
.. code-block::
3534
36-
dojo_method <variable_name>,<option>
35+
.. code-block:: text
36+
37+
dojo_method <variable_name>,<option>
3738
3839
Script Parameters:
39-
variable_name: The name of the variable where the monster ID will be stored.
40-
option: The action to perform. Can be either:
40+
41+
variable_name:
42+
The name of the variable where the monster ID will be stored.
43+
44+
option:
45+
The action to perform. Can be either:
46+
4147
- "technique": Learn any move the monster hasn't acquired from its base
42-
moveset, without restrictions based on level or evolution stage.
48+
moveset, without restrictions based on level or evolution stage.
4349
- "monster": Devolve the monster.
4450
"""
4551

tuxemon/event/actions/info.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,31 @@
1919
class InfoAction(EventAction):
2020
"""
2121
Records monster's attribute values inside a game variable.
22-
It allows to record the monster's owner attribute values too.
22+
It allows recording the monster's owner attribute values too.
2323
2424
Script usage:
25-
.. code-block::
2625
27-
info <variable>,<attribute>
26+
.. code-block:: text
27+
28+
info <variable>,<attribute>
2829
2930
Script parameters:
30-
variable: Name of the variable where to store the monster id.
31-
attribute: The attribute to check (level, speed, etc.)
32-
33-
eg. "info name_variable,level"
34-
-> if the monster is lv 4, then it'll create a variable called:
35-
"info_level:4"
36-
eg. "info name_variable,owner_steps"
37-
-> if the owner walked 69 steps, then it'll create a variable called:
38-
"info_owner_steps:69"
31+
32+
variable:
33+
Name of the variable where to store the monster id.
34+
35+
attribute:
36+
The attribute to check (level, speed, etc.)
37+
38+
Examples:
39+
40+
"info name_variable,level"
41+
-> if the monster is lv 4, then it'll create a variable called:
42+
"info_level:4"
43+
44+
"info name_variable,owner_steps"
45+
-> if the owner walked 69 steps, then it'll create a variable called:
46+
"info_owner_steps:69"
3947
"""
4048

4149
name = "info"

tuxemon/event/actions/input_variable.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,38 @@
1717
@dataclass
1818
class InputVariableAction(EventAction):
1919
"""
20-
Set a code and checks if it's correct or not.
20+
Set a code and check if it's correct or not.
2121
The player's output will be by default lowercase.
2222
2323
Script usage:
24-
.. code-block::
2524
26-
input_variable <variable>,<question>[,answer][,escape]
25+
.. code-block:: text
26+
27+
input_variable <variable>,<question>[,answer][,escape]
2728
2829
Script parameters:
29-
question: The question the player needs to reply (eg. "access_code")
30-
then you create the msgid "access_code" inside the PO file:
30+
31+
question:
32+
The question the player needs to reply (e.g. "access_code").
33+
Then you create the msgid "access_code" inside the PO file:
34+
3135
msgid "access_code"
3236
msgstr "Here the actual question?"
33-
variable: Name of the variable where to store the output.
34-
escape: Optional string flag ("true", "1", "yes" for True),
35-
defaults to False when omitted
3637
37-
eg. "input_variable access_code,response_question"
38-
eg. "input_variable access_code,response_question,escape"
38+
variable:
39+
Name of the variable where to store the output.
40+
41+
escape:
42+
Optional string flag ("true", "1", "yes" for True),
43+
defaults to False when omitted.
44+
45+
Examples:
46+
47+
"input_variable access_code,response_question"
48+
"input_variable access_code,response_question,escape"
3949
40-
-> "is variable_set response_question:whatswrittenbytheplayer"
41-
-> "not variable_set response_question:whatswrittenbytheplayer"
50+
-> "is variable_set response_question:whatswrittenbytheplayer"
51+
-> "not variable_set response_question:whatswrittenbytheplayer"
4252
"""
4353

4454
name = "input_variable"

tuxemon/event/actions/set_cipher.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,21 @@ class SetCipherAction(EventAction):
5252
Toggles ciphering for dialogue by enabling or disabling the CipherProcessor.
5353
5454
Script usage:
55-
.. code-block::
56-
set_cipher <option>,<cipher_map>
55+
56+
.. code-block:: text
57+
58+
set_cipher <option>,<cipher_map>
5759
5860
Parameters:
61+
5962
option:
60-
- "enable": Activates ciphering using the provided cipher map (if any).
61-
- "disable": Disables ciphering entirely.
63+
- "enable": Activates ciphering using the provided cipher map (if any).
64+
- "disable": Disables ciphering entirely.
6265
63-
cipher_map: the filename (without extension) of a YAML file located in
64-
the mods folder.
65-
- If omitted during "enable", the default cipher map is used.
66-
- Ignored when option is "disable".
66+
cipher_map:
67+
The filename (without extension) of a YAML file located in the mods folder.
68+
- If omitted during "enable", the default cipher map is used.
69+
- Ignored when option is "disable".
6770
"""
6871

6972
name = "set_cipher"

0 commit comments

Comments
 (0)