Skip to content

Commit d7cfc2a

Browse files
authored
Merge pull request #86 from CCPBioSim/85-docs-move-the-documentation-to-the-shared-ccpbiosim-sphinx-theme
Move the documentation to the shared CCPBioSim Sphinx theme
2 parents 5c6f696 + 0e088e7 commit d7cfc2a

9 files changed

Lines changed: 96 additions & 43 deletions

File tree

‎.gitignore‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ instance/
6969
.scrapy
7070

7171
# Sphinx documentation
72-
docs/_build/
72+
docs/build/
73+
docs/source/reference/
7374

7475
# PyBuilder
7576
.pybuilder/

‎.readthedocs.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ build:
99
python: "3.13"
1010

1111
sphinx:
12-
configuration: docs/conf.py
12+
configuration: docs/source/conf.py
1313

1414
python:
1515
install:

‎docs/Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# from the environment for the first two.
66
SPHINXOPTS ?=
77
SPHINXBUILD ?= sphinx-build
8-
SOURCEDIR = .
9-
BUILDDIR = _build
8+
SOURCEDIR = source
9+
BUILDDIR = build
1010

1111
# Put it first so that "make" without argument is like "make help".
1212
help:

‎docs/index.rst‎

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

docs/conf.py renamed to docs/source/conf.py

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,11 @@
33
# For the full list of built-in configuration values, see the documentation:
44
# https://www.sphinx-doc.org/en/master/usage/configuration.html
55

6-
# -- Path setup --------------------------------------------------------------
7-
import os
8-
import sys
6+
import importlib.metadata
97
import time
108

11-
# Put the repository root on sys.path so autodoc imports the local package.
12-
DOCS_DIR = os.path.abspath(os.path.dirname(__file__))
13-
REPO_ROOT = os.path.abspath(os.path.join(DOCS_DIR, ".."))
14-
sys.path.insert(0, REPO_ROOT)
15-
169
# -- Project information -----------------------------------------------------
10+
# Change these for your project.
1711
project = "CCPBioSim-Python-Template"
1812
copyright_first_year = "2025"
1913
copyright_owners = "CCPBioSim"
@@ -27,32 +21,45 @@
2721
)
2822
copyright = f"{copyright_year_string}, {copyright_owners}. All rights reserved"
2923

30-
version = ""
31-
release = ""
24+
# Read from the installed package, so it matches the release.
25+
release = importlib.metadata.version("example_package")
3226

3327
# -- General configuration ---------------------------------------------------
3428
extensions = [
35-
"sphinx.ext.autosummary",
36-
"sphinx.ext.autodoc",
3729
"sphinx.ext.mathjax",
3830
"sphinx.ext.viewcode",
3931
"sphinx.ext.napoleon",
4032
"sphinx.ext.intersphinx",
4133
"sphinx.ext.extlinks",
42-
"nbsphinx",
43-
"sphinx_copybutton",
34+
"autoapi.extension",
4435
]
4536

46-
# Autosummary (API stubs)
47-
autosummary_generate = True
48-
4937
# Napoleon: Google-style docstrings
5038
napoleon_google_docstring = True
5139
napoleon_numpy_docstring = False
5240
napoleon_use_param = True
5341
napoleon_use_rtype = True
5442
napoleon_use_ivar = True
5543

44+
# API reference generated from the source by sphinx-autoapi
45+
autoapi_dirs = ["../../example_package"]
46+
autoapi_root = "reference"
47+
autoapi_add_toctree_entry = False
48+
autoapi_member_order = "groupwise"
49+
# Include the __init__ docstring, where the constructor arguments are documented
50+
autoapi_python_class_content = "both"
51+
autoapi_options = [
52+
"members",
53+
"undoc-members",
54+
"show-inheritance",
55+
"show-module-summary",
56+
]
57+
58+
# Show type hints in the parameter list rather than the signature
59+
autodoc_typehints = "description"
60+
add_module_names = False
61+
python_maximum_signature_line_length = 88
62+
5663
templates_path = ["_templates"]
5764

5865
source_suffix = ".rst"
@@ -62,5 +69,7 @@
6269
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
6370

6471
# -- Options for HTML output -------------------------------------------------
65-
html_theme = "furo"
72+
# The shared CCPBioSim theme. Change github_repo to your repository's name.
73+
html_theme = "ccpbiosim_sphinx_theme"
74+
html_context = {"github_repo": "Python-Template"}
6675
html_static_path = ["_static"]

‎docs/source/index.rst‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
:html_theme.sidebar_secondary.remove:
2+
3+
CCPBioSim-Python-Template
4+
=========================
5+
6+
.. Banner for the home page. Add your logos to _static/logos/ and set
7+
:logo-light: (dark text, for light mode) and :logo-dark: (white text, for
8+
dark mode). See https://ccpbiosim-sphinx-theme.readthedocs.io/
9+
10+
.. ccpbiosim-hero::
11+
:tagline: CCPBioSim-Python-Template
12+
:button: reference/example_package/index | API reference
13+
:github: CCPBioSim/Python-Template
14+
15+
Short description of your package
16+
17+
Add an introduction to your package here. See the
18+
`reStructuredText <https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html>`_
19+
documentation for details on writing pages.
20+
21+
Quick start
22+
-----------
23+
24+
.. tab-set::
25+
26+
.. tab-item:: pip
27+
28+
.. code-block:: bash
29+
30+
pip install example_package
31+
32+
.. tab-item:: Conda
33+
34+
.. code-block:: bash
35+
36+
conda install -c conda-forge -c ccpbiosim example_package
37+
38+
Explore the documentation
39+
-------------------------
40+
41+
.. Add a card for each section of your documentation.
42+
43+
.. grid:: 1 2 2 2
44+
:gutter: 3
45+
46+
.. grid-item-card:: 📖 API Reference
47+
:link: reference/example_package/index
48+
:link-type: doc
49+
50+
Reference for the example_package package.
51+
52+
.. grid-item-card:: 💻 Source Code
53+
:link: https://github.com/CCPBioSim/Python-Template
54+
55+
The repository on GitHub.
56+
57+
.. toctree::
58+
:maxdepth: 2
59+
:hidden:
60+
61+
API Reference <reference/example_package/index>

‎pyproject.toml‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ Documentation = "https://Python-Template.github.io/"
4949
[project.optional-dependencies]
5050
testing = [
5151
"pytest>=9.0,<10.0",
52-
"pytest-cov>=7.0,<8.0",
53-
"pytest-sugar>=1.1,<2.0"
52+
"pytest-cov>=7.0,<8.0"
5453
]
5554

5655
pre-commit = [
@@ -62,9 +61,8 @@ pre-commit = [
6261

6362
docs = [
6463
"sphinx>=9,<10",
65-
"nbsphinx>=0.9,<1.0",
66-
"sphinx_copybutton>=0.5,<1.0",
67-
"furo>=2025.12.19,<2026.0",
64+
"sphinx-autoapi>=3.8,<4.0",
65+
"ccpbiosim-sphinx-theme>=1.3.4,<2.0",
6866
"markupsafe>=3.0,<4.0"
6967
]
7068

0 commit comments

Comments
 (0)