afterpython 0.3.1__py3-none-any.whl → 0.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- afterpython/builders/__init__.py +2 -0
- afterpython/builders/build_pdoc.py +57 -0
- afterpython/cli/commands/build.py +38 -3
- afterpython/cli/commands/bump.py +1 -1
- afterpython/templates/pdoc/frame.html.jinja2 +7 -0
- afterpython/templates/pre-commit-config-template.yaml +2 -2
- afterpython/tools/_afterpython.py +1 -0
- {afterpython-0.3.1.dist-info → afterpython-0.3.2.dist-info}/METADATA +5 -5
- {afterpython-0.3.1.dist-info → afterpython-0.3.2.dist-info}/RECORD +11 -9
- {afterpython-0.3.1.dist-info → afterpython-0.3.2.dist-info}/WHEEL +1 -1
- {afterpython-0.3.1.dist-info → afterpython-0.3.2.dist-info}/entry_points.txt +0 -0
afterpython/builders/__init__.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from afterpython.builders.build_pdoc import build_pdoc
|
|
1
2
|
from afterpython.builders.content_json import build_content_json
|
|
2
3
|
from afterpython.builders.faq_json import build_faq_json
|
|
3
4
|
from afterpython.builders.index_md import (
|
|
@@ -19,6 +20,7 @@ __all__ = (
|
|
|
19
20
|
"build_marimo_readme",
|
|
20
21
|
"build_markdown",
|
|
21
22
|
"build_metadata",
|
|
23
|
+
"build_pdoc",
|
|
22
24
|
"build_url_md",
|
|
23
25
|
"create_placeholder_index_md_files",
|
|
24
26
|
"delete_placeholder_index_md_files",
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import subprocess
|
|
3
|
+
|
|
4
|
+
import click
|
|
5
|
+
|
|
6
|
+
import afterpython as ap
|
|
7
|
+
from afterpython.tools.pyproject import find_package_directory
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def build_pdoc(base_path: str) -> None:
|
|
11
|
+
"""Generate API reference HTML from the user's package via pdoc.
|
|
12
|
+
|
|
13
|
+
Output goes to `_build/api_reference/` (the standard staging dir);
|
|
14
|
+
the build command is responsible for copying it into the website's
|
|
15
|
+
static dir.
|
|
16
|
+
|
|
17
|
+
`base_path` is "" for custom domains and "/{repo-name}" for GitHub
|
|
18
|
+
Pages — used to wire pdoc's logo + logo-link flags so that the
|
|
19
|
+
project logo appears in the top-left of every API page and links
|
|
20
|
+
back to the project website root (matches MyST's UX).
|
|
21
|
+
"""
|
|
22
|
+
package_dir = find_package_directory()
|
|
23
|
+
output_dir = ap.paths.build_path / "api_reference"
|
|
24
|
+
template_dir = ap.paths.templates_path / "pdoc"
|
|
25
|
+
|
|
26
|
+
click.echo("Building api_reference/...")
|
|
27
|
+
|
|
28
|
+
# PDOC_ALLOW_EXEC=1 lets module-level subprocess calls run during pdoc's
|
|
29
|
+
# introspection import. Required because some deps (e.g. jupytext) shell
|
|
30
|
+
# out to `pandoc --version` at import time. Safe here: pdoc imports the
|
|
31
|
+
# user's own package, whose import-time behavior the user already trusts.
|
|
32
|
+
env = {**os.environ, "PDOC_ALLOW_EXEC": "1"}
|
|
33
|
+
|
|
34
|
+
# logo.svg is a project-website-template convention (always present in
|
|
35
|
+
# `_website/static/`); served at `{base_path}/logo.svg` once the site
|
|
36
|
+
# is built. logo-link points back to the project website root.
|
|
37
|
+
result = subprocess.run(
|
|
38
|
+
[
|
|
39
|
+
"pdoc",
|
|
40
|
+
"-o",
|
|
41
|
+
str(output_dir),
|
|
42
|
+
"--logo",
|
|
43
|
+
f"{base_path}/logo.svg",
|
|
44
|
+
"--logo-link",
|
|
45
|
+
f"{base_path}/",
|
|
46
|
+
"--template-directory",
|
|
47
|
+
str(template_dir),
|
|
48
|
+
str(package_dir),
|
|
49
|
+
],
|
|
50
|
+
env=env,
|
|
51
|
+
check=False,
|
|
52
|
+
)
|
|
53
|
+
if result.returncode != 0:
|
|
54
|
+
raise click.ClickException(
|
|
55
|
+
f"pdoc failed with exit code {result.returncode}. "
|
|
56
|
+
f"Re-run `ap build --skip-api` to skip API reference generation."
|
|
57
|
+
)
|
|
@@ -24,6 +24,7 @@ from afterpython.builders import (
|
|
|
24
24
|
build_marimo_readme,
|
|
25
25
|
build_markdown,
|
|
26
26
|
build_metadata,
|
|
27
|
+
build_pdoc,
|
|
27
28
|
build_url_md,
|
|
28
29
|
create_placeholder_index_md_files,
|
|
29
30
|
delete_placeholder_index_md_files,
|
|
@@ -66,6 +67,22 @@ def determine_base_path() -> str:
|
|
|
66
67
|
return f"/{repo_name}"
|
|
67
68
|
|
|
68
69
|
|
|
70
|
+
def _read_api_reference() -> bool:
|
|
71
|
+
"""Read `[website].api_reference` from afterpython.toml. Defaults to False.
|
|
72
|
+
|
|
73
|
+
Off-by-default means freshly `ap init`'d projects don't blow up on
|
|
74
|
+
`ap build` before their package is import-ready or has docstrings —
|
|
75
|
+
pdoc errors are opt-in surface. Users enable the API reference by
|
|
76
|
+
setting the field to true.
|
|
77
|
+
"""
|
|
78
|
+
from afterpython._io.toml import _from_tomlkit
|
|
79
|
+
from afterpython.tools._afterpython import read_afterpython
|
|
80
|
+
|
|
81
|
+
afterpython = read_afterpython()
|
|
82
|
+
website = _from_tomlkit(afterpython.get("website", {}))
|
|
83
|
+
return bool(website.get("api_reference", False))
|
|
84
|
+
|
|
85
|
+
|
|
69
86
|
def prebuild():
|
|
70
87
|
def _check_initialized():
|
|
71
88
|
# Check if 'ap init' has been run
|
|
@@ -85,7 +102,15 @@ def prebuild():
|
|
|
85
102
|
content_build_paths = [
|
|
86
103
|
website_static_path / content_type for content_type in CONTENT_TYPES
|
|
87
104
|
]
|
|
88
|
-
|
|
105
|
+
# Also wipe the API reference static dir so a `--skip-api` build doesn't
|
|
106
|
+
# leave stale pages from a prior run live on the deployed site.
|
|
107
|
+
api_static_path = website_static_path / "api_reference"
|
|
108
|
+
for path in [
|
|
109
|
+
build_path,
|
|
110
|
+
website_build_path,
|
|
111
|
+
api_static_path,
|
|
112
|
+
*content_build_paths,
|
|
113
|
+
]:
|
|
89
114
|
if path.exists():
|
|
90
115
|
shutil.rmtree(path)
|
|
91
116
|
build_path.mkdir(parents=True, exist_ok=True)
|
|
@@ -209,7 +234,11 @@ def postbuild(dev_build: bool = False):
|
|
|
209
234
|
def build(ctx: click.Context, execute: bool):
|
|
210
235
|
"""Build the project website and all contents for production.
|
|
211
236
|
|
|
212
|
-
This command builds MyST content (doc/blog/tutorial/example/guide)
|
|
237
|
+
This command builds MyST content (doc/blog/tutorial/example/guide), the API
|
|
238
|
+
reference (via pdoc), and the SvelteKit website.
|
|
239
|
+
|
|
240
|
+
The API reference is opt-in via `[website].api_reference = true` in
|
|
241
|
+
afterpython.toml — by default it is skipped.
|
|
213
242
|
|
|
214
243
|
Any extra arguments are passed to the 'myst build --html' command for each content type.
|
|
215
244
|
See "myst build --help" for more details.
|
|
@@ -240,12 +269,18 @@ def build(ctx: click.Context, execute: bool):
|
|
|
240
269
|
paths = ctx.obj["paths"]
|
|
241
270
|
prebuild()
|
|
242
271
|
|
|
243
|
-
# Determine BASE_PATH based on website URL configuration
|
|
272
|
+
# Determine BASE_PATH based on website URL configuration. Computed
|
|
273
|
+
# before build_pdoc() so it can wire pdoc's logo-link back to the
|
|
274
|
+
# project website root.
|
|
244
275
|
base_path = determine_base_path()
|
|
245
276
|
if base_path:
|
|
246
277
|
click.echo(f"Using BASE_PATH: {base_path}")
|
|
247
278
|
else:
|
|
248
279
|
click.echo("Using BASE_PATH: (empty - custom domain)")
|
|
280
|
+
|
|
281
|
+
if _read_api_reference():
|
|
282
|
+
build_pdoc(base_path=base_path)
|
|
283
|
+
|
|
249
284
|
node_env: NodeEnv = find_node_env()
|
|
250
285
|
|
|
251
286
|
# myst's production build
|
afterpython/cli/commands/bump.py
CHANGED
|
@@ -75,7 +75,7 @@ def bump(ctx, release: bool, pre: bool):
|
|
|
75
75
|
|
|
76
76
|
# by default, bump dev-release version
|
|
77
77
|
if version.is_devrelease and not pre:
|
|
78
|
-
devrelease_number = int(version.dev)
|
|
78
|
+
devrelease_number = int(version.dev) if version.dev is not None else 0
|
|
79
79
|
if "--devrelease" not in ctx.args:
|
|
80
80
|
args = ["--devrelease", str(devrelease_number + 1), *ctx.args]
|
|
81
81
|
# exclude e.g. 0.1.0.dev1 which is both dev-release and pre-release (with version.pre = None)
|
|
@@ -23,7 +23,7 @@ repos:
|
|
|
23
23
|
stages:
|
|
24
24
|
- pre-commit
|
|
25
25
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
26
|
-
rev: v0.
|
|
26
|
+
rev: v0.15.12
|
|
27
27
|
hooks:
|
|
28
28
|
- id: ruff-check
|
|
29
29
|
stages:
|
|
@@ -38,7 +38,7 @@ repos:
|
|
|
38
38
|
- --config
|
|
39
39
|
- ./afterpython/ruff.toml
|
|
40
40
|
- repo: https://github.com/commitizen-tools/commitizen
|
|
41
|
-
rev: v4.10
|
|
41
|
+
rev: v4.13.10
|
|
42
42
|
hooks:
|
|
43
43
|
- id: commitizen
|
|
44
44
|
stages:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: afterpython
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: CLI tool to streamline Python package maintenance and generate a dedicated project website
|
|
5
5
|
Keywords: package-maintenance,project-website,static-site-generator,developer-tools,documentation,cli-tool,ci/cd,mystmd,semantic-release,python-packaging
|
|
6
6
|
Author: Stephen Yau
|
|
@@ -19,12 +19,12 @@ Requires-Dist: trogon>=0.6.0
|
|
|
19
19
|
Requires-Dist: httpx>=0.28.1
|
|
20
20
|
Requires-Dist: tomlkit>=0.14.0
|
|
21
21
|
Requires-Dist: ruamel-yaml>=0.19.1
|
|
22
|
-
Requires-Dist: gitpython>=3.1.
|
|
22
|
+
Requires-Dist: gitpython>=3.1.50
|
|
23
23
|
Requires-Dist: python-dotenv>=1.2.2
|
|
24
24
|
Requires-Dist: pyproject-metadata>=0.11.0
|
|
25
25
|
Requires-Dist: jupytext>=1.19.1
|
|
26
26
|
Requires-Dist: mystmd>=1.9.0
|
|
27
|
-
Requires-Dist:
|
|
27
|
+
Requires-Dist: pdoc>=16.0.0
|
|
28
28
|
Requires-Dist: ruff>=0.15.12
|
|
29
29
|
Requires-Dist: pre-commit>=4.6.0
|
|
30
30
|
Requires-Dist: commitizen>=4.13.10
|
|
@@ -53,7 +53,7 @@ Description-Content-Type: text/markdown
|
|
|
53
53
|
[pre-commit]: https://pre-commit.com
|
|
54
54
|
[pagefind]: https://pagefind.app
|
|
55
55
|
[SemVer]: https://semver.org
|
|
56
|
-
[
|
|
56
|
+
[pdoc]: https://pdoc.dev/
|
|
57
57
|
[GitHub Actions]: https://github.com/features/actions
|
|
58
58
|
[PyTorch]: https://pytorch.org
|
|
59
59
|
[Scikit-Learn]: https://scikit-learn.org
|
|
@@ -124,7 +124,7 @@ ap tui
|
|
|
124
124
|
- [project-website-template]
|
|
125
125
|
- [pre-commit]
|
|
126
126
|
- [GitHub Actions]
|
|
127
|
-
- [
|
|
127
|
+
- [pdoc]
|
|
128
128
|
- [commitizen]
|
|
129
129
|
- [uv]
|
|
130
130
|
- [ruff]
|
|
@@ -3,7 +3,8 @@ afterpython/_io/toml.py,sha256=dvmq6n4MhlJ02u_YjfC3mOnCWatfCn_J1lugavigoJw,3410
|
|
|
3
3
|
afterpython/_io/yaml.py,sha256=raksve_gaIFJim8lQrq-kQHkRjTloed7CT2FY0oUJSg,654
|
|
4
4
|
afterpython/_paths.py,sha256=FTwQ7necKYuRosCyMZPfv1eqaEmGIsyqd3yXpm-WQTA,1584
|
|
5
5
|
afterpython/_typing.py,sha256=FbphSGoujPuTfCZqt0HaKQrBgzhRpCOEAEQU6Cbl7oA,145
|
|
6
|
-
afterpython/builders/__init__.py,sha256=
|
|
6
|
+
afterpython/builders/__init__.py,sha256=H7f9mFKXofWOAC3hkrxiFzvW5NziF8wYyduUBykHa5w,975
|
|
7
|
+
afterpython/builders/build_pdoc.py,sha256=rasjCtTah5GsZYokqU--Fp3bvTEf464ievENfOoANOk,2040
|
|
7
8
|
afterpython/builders/content_json.py,sha256=-LTkeA8oA6XEudc2b1H7U0-UwcJlHn7xgICeweMYrG0,4805
|
|
8
9
|
afterpython/builders/faq_json.py,sha256=mMfFepRBL_1QYO0tQ6orf5ESo2LVntk55nfFzencViM,1193
|
|
9
10
|
afterpython/builders/index_md.py,sha256=SDVHnVftL4D1AA8jw2YvRdTem_Ho8v8DcrORVjVtW8A,3762
|
|
@@ -15,8 +16,8 @@ afterpython/builders/metadata.py,sha256=mXTeEpxdwNFlaUwFYLLU1UXvSX2T-pzIxzssFdmn
|
|
|
15
16
|
afterpython/builders/url_md.py,sha256=uuW3YCyphd-Qvl9Yopv48utu6y1tyfJHNc25sS-O6Yw,3526
|
|
16
17
|
afterpython/cli/__init__.py,sha256=G4AB-rllhmr7tURFc5cXJfkjZZ2bXtMBg3oy4zUGEFw,84
|
|
17
18
|
afterpython/cli/commands/add.py,sha256=Ppp4msdvOwN9_-fdG5-b0-IV9p0Eef9CiIEU3srUjYk,1792
|
|
18
|
-
afterpython/cli/commands/build.py,sha256=
|
|
19
|
-
afterpython/cli/commands/bump.py,sha256=
|
|
19
|
+
afterpython/cli/commands/build.py,sha256=h0AaZuhjuxD_2Iu_CHD-3-OMBbi-ncAYuMUIR2pha1k,11798
|
|
20
|
+
afterpython/cli/commands/bump.py,sha256=9fR-wShNKhXbW2JgMExPlyI2n14TfQOtowAuALp-N-8,4122
|
|
20
21
|
afterpython/cli/commands/check.py,sha256=lrPaVThAwxxnczu-VOZT7dd7aKjstnMQfX9UpZY3Lxs,1058
|
|
21
22
|
afterpython/cli/commands/clean.py,sha256=havP43ZC1AKFzvscsRMF_to6TvOwruxGA5qzr6dMHvg,2529
|
|
22
23
|
afterpython/cli/commands/commit.py,sha256=9QOKyt4tfTJzZEdHEPAdpUc4stYMSvG3-31uADuBxn4,1420
|
|
@@ -44,10 +45,11 @@ afterpython/templates/ci-workflow-template.yml,sha256=NSuPjSgo9l70a1IwUuasvgKk-K
|
|
|
44
45
|
afterpython/templates/cz-template.toml,sha256=2qwbQLb0nbZaA63oWXFFzvzPNBsFZHATL1C2rdNdjjs,185
|
|
45
46
|
afterpython/templates/dependabot-template.yml,sha256=CBQEgh8EsXw2X7IqzGtFI7lVT9liF6PW4DvGLB0X2LY,1136
|
|
46
47
|
afterpython/templates/deploy-workflow-template.yml,sha256=L3dSB0WdUvuW2C65MqxkMNbUFCU8-eGvfS_wUj2etNU,2397
|
|
47
|
-
afterpython/templates/
|
|
48
|
+
afterpython/templates/pdoc/frame.html.jinja2,sha256=GX4pNSuYC4Fq9hvZ01WyaBQes4FyNDOx5Ra4MNLr0eg,250
|
|
49
|
+
afterpython/templates/pre-commit-config-template.yaml,sha256=FfQb0mVWouGmV62uCF5WO18hodZhGt-PfybB6m9nsAM,917
|
|
48
50
|
afterpython/templates/release-workflow-template.yml,sha256=3YBkgrqmi--uznslpMxPz7Vj7L4_NPlhDxgwYBt-Ui8,1606
|
|
49
51
|
afterpython/templates/ruff-template.toml,sha256=lNCd4EthoLScr4cyVEgGUH4xK5CfIX3f9I3zkJHAYgg,1008
|
|
50
|
-
afterpython/tools/_afterpython.py,sha256=
|
|
52
|
+
afterpython/tools/_afterpython.py,sha256=IgzUG8ihdaqrqLIma8yy6pVtC2ldt4jyWOf6FQWnKCU,4345
|
|
51
53
|
afterpython/tools/_git.py,sha256=aO-qDEQ4OevD_B74DYKK4nQKYeiaS1BXmYc8paJRfbQ,3772
|
|
52
54
|
afterpython/tools/branch_rules.py,sha256=ciQ2H2YBnoCZu_plyVeIHzf2FcAILRFhpjzOR2_IfJg,3159
|
|
53
55
|
afterpython/tools/commitizen.py,sha256=ZO1qHmzUU0myd85tncv76WtIR7DB_AoQGSUvaf78Ohg,438
|
|
@@ -57,7 +59,7 @@ afterpython/tools/pre_commit.py,sha256=oNsrUkPI13rSSBSyhyTTKPnQGhDxLIPYhxu6kL0fD
|
|
|
57
59
|
afterpython/tools/pyproject.py,sha256=hz-DOf-pkGBF2m_RqEZipAaO-NDbsLxrrc65LWAIwLA,3698
|
|
58
60
|
afterpython/utils.py,sha256=fVa3jIzCvhn7QA7N0M6d_pvojpPFrN-hae8trUYhPKU,11701
|
|
59
61
|
afterpython/version.py,sha256=hihRV1S-gc1m46OaXD32ikkEkqzs-Gtq7AcAqOQV-wY,1603
|
|
60
|
-
afterpython-0.3.
|
|
61
|
-
afterpython-0.3.
|
|
62
|
-
afterpython-0.3.
|
|
63
|
-
afterpython-0.3.
|
|
62
|
+
afterpython-0.3.2.dist-info/WHEEL,sha256=-unyBNsdNo6Y_XVO25zjvxasG_uUFN_fBd_kLyKE-Fk,81
|
|
63
|
+
afterpython-0.3.2.dist-info/entry_points.txt,sha256=roa0PDgBueM1JPbRG0G2OSxzaN394OUL_oS9iEwVLBc,80
|
|
64
|
+
afterpython-0.3.2.dist-info/METADATA,sha256=Rhe3BEDPDmJrHdwZtiNQwa6EJ71P975ErqSNeLLrerE,6181
|
|
65
|
+
afterpython-0.3.2.dist-info/RECORD,,
|
|
File without changes
|