Skip to content

Commit 31815f4

Browse files
authored
fix: trigger publish only on release (pyOpenSci#140)
* fix: releaase trigger for publish only * changlog * bug: fix documentation setup * fix: * fix: sphinx design
1 parent 2199b9f commit 31815f4

File tree

7 files changed

+74
-31
lines changed

7 files changed

+74
-31
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## [Unreleased]
44

5+
* Bug: small bug in the release ci and update conf.py (@lwasser, #140)
6+
7+
## [v0.6.8]
58
* Fix docs CI builds to to simplify maintenance and feedback on jobs (@lwasser, #127, #138)
69

710
## [v0.6.7]

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ dependencies = [
8080
"mkdocs-awesome-pages-plugin ~=2.9",
8181
"pydata_sphinx_theme ~=0.16",
8282
"myst-parser ~=4.0",
83-
"Sphinx ~=8.0",
83+
"sphinx ~=8.0",
84+
"sphinx-autobuild>=2024.10.3",
85+
"sphinx-autoapi>=3.6.0",
86+
"sphinx_design>=0.6.1",
87+
"sphinx-copybutton",
8488
]
8589

8690
[[tool.hatch.envs.test.matrix]]

template/pyproject.toml.jinja

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ docs = [
9393
"pydata-sphinx-theme~=0.16",
9494
"sphinx-autobuild>=2024.10.3",
9595
"sphinx-autoapi>=3.6.0",
96-
"sphinx-design>=0.6.1",
96+
"sphinx_design>=0.6.1",
9797
"sphinx-copybutton>=0.5.2",
9898
{%- elif documentation == "mkdocs" %}
9999
"mkdocs-material ~=9.5",
@@ -323,8 +323,8 @@ build = "mkdocs build {args:--clean --strict}"
323323
serve = "mkdocs serve {args}"
324324
{%- endif %}
325325
{%- if documentation == "sphinx" %}
326-
build = ["sphinx-apidoc -o docs/api src/{{ package_name}}", "sphinx-build {args:-W -b html docs docs/_build}"]
327-
serve = ["sphinx-apidoc -o docs/api src/{{ package_name}}", "sphinx-autobuild docs --watch src/{{ package_name }} {args:-b html docs/_build/serve}"]
326+
build = ["sphinx-build {args:-W -b html docs docs/_build}"]
327+
serve = ["sphinx-autobuild docs --watch src/{{ package_name }} {args:-b html docs/_build/serve}"]
328328
{%- endif %}
329329
{%- endif %}
330330

template/{% if documentation == 'sphinx' %}docs{% endif %}/conf.py.jinja

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,56 @@
11
#
22
# {{ project_name }} documentation build configuration file
33
#
4+
import os
5+
import sys
46
import importlib.metadata
7+
from datetime import datetime
58

6-
# -- General configuration -----------------------------------------------------
7-
8-
# Add any Sphinx extension module names here, as strings. They can be extensions
9-
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
10-
extensions = [
11-
"myst_parser",
12-
"sphinx.ext.intersphinx",
13-
"sphinx.ext.autodoc",
14-
]
9+
# Ensure src/ is on the path so autodoc can find the package
10+
sys.path.insert(0, os.path.abspath("../src"))
1511

16-
# The suffix of source filenames.
17-
source_suffix = ".rst"
18-
19-
# The master toctree document.
20-
master_doc = "index"
12+
# Get the year so it automatically updates
13+
current_year = datetime.now().year
2114

15+
# -- General project information -----------------------------
2216
# General information about the project.
2317
project = "{{ project_name }}"
2418
copyright = "Copyright © {{ year }} {{ copyright_holder }}"
2519
html_show_sphinx = False
2620

27-
# The version info for the project you're documenting, acts as replacement for
21+
# Try to get the version info for the project you're documenting, acts as replacement for
2822
# |version| and |release|, also used in various other places throughout the
2923
# built documents.
3024
try:
3125
version = importlib.metadata.version("{{ package_name }}")
3226
except importlib.metadata.PackageNotFoundError:
3327
version = "0.0.0"
3428

29+
# -- General configuration -----------------------------------------------------
30+
31+
# -- General configuration -----------------------------------------------------
32+
33+
# Add any Sphinx extension module names here, as strings. They can be extensions
34+
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
35+
extensions = [
36+
"myst_parser",
37+
"sphinx_design",
38+
"sphinx_copybutton",
39+
"sphinx.ext.intersphinx",
40+
"sphinx.ext.napoleon", # Support numpy style docstrings
41+
# This allows you to create :::{todo} sections that will not be rendered
42+
# in the live docs if you want to leave notes for future work in the docs
43+
"sphinx.ext.todo",
44+
# Auto generate docs
45+
"autoapi.extension",
46+
]
47+
48+
# Support Markdown source files & rst for api docs
49+
source_suffix = [".rst", ".md"]
50+
51+
# The master toctree document.
52+
master_doc = "index"
53+
3554
# The name of the Pygments (syntax highlighting) style to use.
3655
pygments_style = "default"
3756

@@ -44,8 +63,31 @@ language = "en"
4463

4564
# -- Options for extensions ----------------------------------------------------
4665
# https://myst-parser.readthedocs.io/en/latest/syntax/optional.html
47-
myst_enable_extensions = ["html_image"]
66+
# -- Options for myst markdown formatting
67+
myst_enable_extensions = [
68+
"html_image",
69+
"colon_fence",
70+
"deflist",
71+
"attrs_inline",
72+
]
73+
74+
myst_heading_anchors = 3
75+
myst_footnote_transition = False
76+
77+
78+
templates_path = ["_templates"]
79+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
80+
81+
#--------- setup autoapi defaults for your api docs ---------------
4882

83+
# AutoAPI configuration
84+
autoapi_type = "python"
85+
# point AutoAPI at your package sources; adjust if using src layout
86+
autoapi_dirs = ["../src"]
87+
# Don't let AutoAPI automatically insert a toctree (avoid duplicates)
88+
autoapi_add_toctree = False
89+
autoapi_keep_files = False
90+
autoapi_options = ["members", "undoc-members", "show-inheritance"]
4991

5092
# -- Options for HTML output ---------------------------------------------------
5193

template/{% if documentation == 'sphinx' %}docs{% endif %}/index.md.jinja

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
:caption: Contents:
99

1010
Home <self>
11-
Documentation <documentation/index>
1211
:::
1312

1413
This is the landing page of your docs. you can update it as you'd like to.
@@ -42,15 +41,9 @@ If you see syntax like the syntax below, you are looking at rst.
4241
:caption: Contents:
4342
```
4443

45-
[API Documentation](./api/modules.rst)
46-
4744
## Copyright
4845

4946
{% with license_path = False -%}
5047
{% include pathjoin("includes", "licenses", "stub.md.jinja") %}
5148
{%- endwith %}
5249

53-
```{toctree}
54-
:hidden:
55-
./api/modules.rst
56-
```

template/{% if use_git and dev_platform == 'GitHub' %}.github{% endif %}/workflows/release.yml.jinja

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ jobs:
5454
publish:
5555
name: >-
5656
Publish Python 🐍 distribution 📦 to PyPI
57-
# Modify the repo name below to be your project's repo name.
58-
if: github.repository_owner == '{{ username }}'
57+
# Only publish to PyPI with a release trigger in your repository.
58+
if: github.repository_owner == '{{ username }}' && github.event_name == 'release'
5959
needs:
6060
- build
6161
runs-on: ubuntu-latest

tests/test_template_init.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def test_template_suite(
178178
@pytest.mark.installs
179179
@pytest.mark.parametrize("use_hatch_envs", [True, False])
180180
def test_docs_build(documentation: str, generated: Callable[..., Path], use_hatch_envs: bool):
181-
"""The docs should build."""
181+
"""The docs should build both with and without hatch environments."""
182182
if documentation == "no":
183183
return
184184

@@ -193,7 +193,8 @@ def test_docs_build(documentation: str, generated: Callable[..., Path], use_hatc
193193
pytest.skip(
194194
"Dont know enough about invoking shell commands on windows for this :(",
195195
)
196-
run_command("sphinx-apidoc -o docs/api src/alien_clones", project)
196+
# With autoapi we shouldn't have to manually run sphinx-apidoc anymore
197+
#run_command("sphinx-apidoc -o docs/api src/alien_clones", project)
197198
# prepend pythonpath so we don't have to actually install here...
198199
run_command(f"PYTHONPATH={str(project/'src')} sphinx-build -W -b html docs docs/_build", project)
199200

0 commit comments

Comments
 (0)