afterpython 0.4.7__tar.gz → 0.4.9__tar.gz
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-0.4.7 → afterpython-0.4.9}/PKG-INFO +1 -1
- {afterpython-0.4.7 → afterpython-0.4.9}/pyproject.toml +1 -1
- {afterpython-0.4.7 → afterpython-0.4.9}/pyproject.toml.orig +1 -1
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/builders/faq_json.py +1 -3
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/builders/marimo_notebook.py +7 -1
- afterpython-0.4.9/src/afterpython/builders/site_data.py +215 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/build.py +7 -18
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/dev.py +23 -6
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/tools/myst.py +3 -4
- {afterpython-0.4.7 → afterpython-0.4.9}/README.md +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/__init__.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/_io/toml.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/_io/yaml.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/_paths.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/_typing.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/builders/__init__.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/builders/build_pdoc.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/builders/comments_json.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/builders/content_json.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/builders/index_md.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/builders/jupyter_notebook.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/builders/llms_txt.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/builders/marimo_content.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/builders/markdown.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/builders/metadata.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/builders/url_md.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/__init__.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/add.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/bump.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/changelog.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/check.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/clean.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/commit_msg.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/format.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/init.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/init_branch_rules.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/install.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/lint.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/lock.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/prek.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/preview.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/release.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/remove.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/serve.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/start.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/sync.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/commands/update.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/cli/main.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/const.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/main.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/pcu.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/py.typed +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/templates/afterpython-template.toml +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/templates/ci-workflow-template.yml +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/templates/cliff-template.toml +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/templates/dependabot-template.yml +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/templates/deploy-workflow-template.yml +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/templates/pdoc/custom.css +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/templates/pdoc/frame.html.jinja2 +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/templates/pdoc/module.html.jinja2 +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/templates/pdoc/syntax-highlighting.css +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/templates/pdoc/theme.css +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/templates/pre-commit-config-template.yaml +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/templates/release-workflow-template.yml +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/templates/ruff-template.toml +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/templates/ty-template.toml +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/tools/_afterpython.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/tools/_git.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/tools/branch_rules.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/tools/github_actions.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/tools/prek.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/tools/pyproject.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/utils.py +0 -0
- {afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: afterpython
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.9
|
|
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
|
|
@@ -7,8 +7,6 @@ import click
|
|
|
7
7
|
import afterpython as ap
|
|
8
8
|
from afterpython._io.yaml import read_yaml
|
|
9
9
|
|
|
10
|
-
build_path = ap.paths.build_path
|
|
11
|
-
|
|
12
10
|
|
|
13
11
|
def build_faq_json():
|
|
14
12
|
"""Build faq.json from the user's afterpython/faq.yml.
|
|
@@ -40,5 +38,5 @@ def build_faq_json():
|
|
|
40
38
|
for item in raw
|
|
41
39
|
]
|
|
42
40
|
|
|
43
|
-
with open(build_path / "faq.json", "w") as f:
|
|
41
|
+
with open(ap.paths.build_path / "faq.json", "w") as f:
|
|
44
42
|
json.dump(items, f, indent=2)
|
|
@@ -157,11 +157,14 @@ def build_marimo_notebook(
|
|
|
157
157
|
_inject_molab_badge(output_html, molab_url)
|
|
158
158
|
|
|
159
159
|
|
|
160
|
-
def build_marimo_readme(mode: MarimoExportMode =
|
|
160
|
+
def build_marimo_readme(mode: MarimoExportMode | None = None):
|
|
161
161
|
"""Build afterpython/README.py to _build/readme_py/readme_py.html.
|
|
162
162
|
|
|
163
163
|
Skips silently if README.py is absent or isn't a marimo notebook so users
|
|
164
164
|
who keep only README.md aren't penalized.
|
|
165
|
+
|
|
166
|
+
`mode` defaults to `[website].readme_py` in afterpython.toml ("wasm" when
|
|
167
|
+
unset or unknown, the same fallback the metadata.json resolver uses).
|
|
165
168
|
"""
|
|
166
169
|
from afterpython._io.toml import _from_tomlkit
|
|
167
170
|
from afterpython.tools._afterpython import read_afterpython
|
|
@@ -172,5 +175,8 @@ def build_marimo_readme(mode: MarimoExportMode = "wasm"):
|
|
|
172
175
|
output_html = ap.paths.build_path / "readme_py" / "readme_py.html"
|
|
173
176
|
content_path = Path("README.py")
|
|
174
177
|
website = _from_tomlkit(read_afterpython().get("website", {}))
|
|
178
|
+
if mode is None:
|
|
179
|
+
configured = str(website.get("readme_py", "wasm"))
|
|
180
|
+
mode = "static" if configured == "static" else "wasm"
|
|
175
181
|
execute = bool(website.get("execute_readme_py", False))
|
|
176
182
|
build_marimo_notebook(readme_path, output_html, content_path, mode, execute=execute)
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"""`ap dev`: rebuild the website's data files when their sources change.
|
|
2
|
+
|
|
3
|
+
`prebuild()` and `postbuild()` turn project files into data files under
|
|
4
|
+
afterpython/_build/ (faq.json, metadata.json, blog.json, ...) and copy them to
|
|
5
|
+
afterpython/_website/static/, where SvelteKit reads them. Without this
|
|
6
|
+
watcher that only happens once, when `ap dev` starts, so editing e.g. faq.yml
|
|
7
|
+
needed a restart to show up.
|
|
8
|
+
|
|
9
|
+
Each `_Source` below pairs the files to watch with the builder that reads
|
|
10
|
+
them and the outputs that builder writes. The MyST pages themselves are
|
|
11
|
+
already live (`myst start` watches them); what goes stale is the data built
|
|
12
|
+
around them, such as the blog/tutorial listings.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import shutil
|
|
18
|
+
import threading
|
|
19
|
+
from collections.abc import Callable, Iterable
|
|
20
|
+
from dataclasses import dataclass
|
|
21
|
+
from pathlib import Path
|
|
22
|
+
|
|
23
|
+
import click
|
|
24
|
+
|
|
25
|
+
import afterpython as ap
|
|
26
|
+
from afterpython.const import CONTENT_TYPES
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@dataclass(frozen=True)
|
|
30
|
+
class _Source:
|
|
31
|
+
name: str
|
|
32
|
+
# returns the files to watch; re-evaluated on every poll so newly
|
|
33
|
+
# created files (e.g. a first faq.yml, a new blog post) are picked up
|
|
34
|
+
files: Callable[[], Iterable[Path]]
|
|
35
|
+
build: Callable[[], None]
|
|
36
|
+
# paths relative to afterpython/_build/ that `build` writes; they are
|
|
37
|
+
# removed before rebuilding so a deleted source doesn't leave stale data
|
|
38
|
+
outputs: tuple[str, ...] = ()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _rglob_files(path: Path, pattern: str = "*") -> list[Path]:
|
|
42
|
+
if not path.exists():
|
|
43
|
+
return []
|
|
44
|
+
return [p for p in path.rglob(pattern) if p.is_file()]
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _build_faq():
|
|
48
|
+
from afterpython.builders.faq_json import build_faq_json
|
|
49
|
+
|
|
50
|
+
build_faq_json()
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _build_metadata():
|
|
54
|
+
from afterpython.builders.metadata import build_metadata
|
|
55
|
+
|
|
56
|
+
build_metadata()
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _build_comments():
|
|
60
|
+
from afterpython.builders.comments_json import build_comments_json
|
|
61
|
+
|
|
62
|
+
build_comments_json()
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _build_readme_py():
|
|
66
|
+
from afterpython.builders.marimo_notebook import build_marimo_readme
|
|
67
|
+
|
|
68
|
+
build_marimo_readme()
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _build_content_listings():
|
|
72
|
+
from afterpython.builders.content_json import build_content_json
|
|
73
|
+
|
|
74
|
+
build_content_json()
|
|
75
|
+
# thumbnails and other images referenced by the listings, mirroring the
|
|
76
|
+
# dev branch of postbuild()
|
|
77
|
+
for content_type in CONTENT_TYPES:
|
|
78
|
+
public = ap.paths.afterpython_path / content_type / "_build" / "site" / "public"
|
|
79
|
+
if public.exists():
|
|
80
|
+
shutil.copytree(
|
|
81
|
+
public,
|
|
82
|
+
ap.paths.website_path / "static" / content_type / "build",
|
|
83
|
+
dirs_exist_ok=True,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def _copy_static():
|
|
88
|
+
# afterpython/static/ is copied as-is in postbuild(); there is nothing to
|
|
89
|
+
# build. Deleted files are left in _website/static/ because the template
|
|
90
|
+
# ships its own files there too and we can't tell them apart.
|
|
91
|
+
if ap.paths.static_path.exists():
|
|
92
|
+
shutil.copytree(
|
|
93
|
+
ap.paths.static_path, ap.paths.website_path / "static", dirs_exist_ok=True
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _sources(content_types: set[str]) -> list[_Source]:
|
|
98
|
+
afterpython_path = ap.paths.afterpython_path
|
|
99
|
+
config_files = [ap.paths.pyproject_path, afterpython_path / "afterpython.toml"]
|
|
100
|
+
readme_py = afterpython_path / "README.py"
|
|
101
|
+
# content types with a listing page; doc has none
|
|
102
|
+
listed = sorted(ct for ct in content_types if ct != "doc")
|
|
103
|
+
return [
|
|
104
|
+
_Source(
|
|
105
|
+
name="faq.yml",
|
|
106
|
+
files=lambda: [afterpython_path / "faq.yml"],
|
|
107
|
+
build=_build_faq,
|
|
108
|
+
outputs=("faq.json",),
|
|
109
|
+
),
|
|
110
|
+
_Source(
|
|
111
|
+
name="project metadata",
|
|
112
|
+
# README.md feeds the home page description
|
|
113
|
+
files=lambda: [
|
|
114
|
+
*config_files,
|
|
115
|
+
readme_py,
|
|
116
|
+
*ap.paths.user_path.glob("README*"),
|
|
117
|
+
],
|
|
118
|
+
build=_build_metadata,
|
|
119
|
+
outputs=("metadata.json",),
|
|
120
|
+
),
|
|
121
|
+
_Source(
|
|
122
|
+
# separate from metadata: it calls the giscus API, which README
|
|
123
|
+
# edits shouldn't trigger
|
|
124
|
+
name="comments config",
|
|
125
|
+
files=lambda: config_files,
|
|
126
|
+
build=_build_comments,
|
|
127
|
+
outputs=("comments.json",),
|
|
128
|
+
),
|
|
129
|
+
_Source(
|
|
130
|
+
name="README.py",
|
|
131
|
+
files=lambda: [readme_py],
|
|
132
|
+
build=_build_readme_py,
|
|
133
|
+
outputs=("readme_py",),
|
|
134
|
+
),
|
|
135
|
+
_Source(
|
|
136
|
+
name="afterpython/static/",
|
|
137
|
+
files=lambda: _rglob_files(ap.paths.static_path),
|
|
138
|
+
build=_copy_static,
|
|
139
|
+
),
|
|
140
|
+
_Source(
|
|
141
|
+
name="content listings",
|
|
142
|
+
# `myst start` rewrites these JSON files whenever a page changes
|
|
143
|
+
files=lambda: [
|
|
144
|
+
path
|
|
145
|
+
for ct in listed
|
|
146
|
+
for path in _rglob_files(
|
|
147
|
+
afterpython_path / ct / "_build" / "site", "*.json"
|
|
148
|
+
)
|
|
149
|
+
],
|
|
150
|
+
build=_build_content_listings,
|
|
151
|
+
outputs=tuple(f"{ct}.json" for ct in listed),
|
|
152
|
+
),
|
|
153
|
+
]
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
def _snapshot(source: _Source) -> dict[Path, float]:
|
|
157
|
+
mtimes = {}
|
|
158
|
+
for path in source.files():
|
|
159
|
+
try:
|
|
160
|
+
mtimes[path] = path.stat().st_mtime
|
|
161
|
+
except OSError: # missing, or deleted mid-scan
|
|
162
|
+
continue
|
|
163
|
+
return mtimes
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def _remove(path: Path):
|
|
167
|
+
if path.is_dir():
|
|
168
|
+
shutil.rmtree(path)
|
|
169
|
+
else:
|
|
170
|
+
path.unlink(missing_ok=True)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def rebuild_source(source: _Source):
|
|
174
|
+
"""Rebuild one source and publish its outputs to _website/static/."""
|
|
175
|
+
build_path = ap.paths.build_path
|
|
176
|
+
website_static = ap.paths.website_path / "static"
|
|
177
|
+
for output in source.outputs:
|
|
178
|
+
_remove(build_path / output)
|
|
179
|
+
_remove(website_static / output)
|
|
180
|
+
source.build()
|
|
181
|
+
for output in source.outputs:
|
|
182
|
+
built = build_path / output
|
|
183
|
+
if built.is_dir():
|
|
184
|
+
shutil.copytree(built, website_static / output, dirs_exist_ok=True)
|
|
185
|
+
elif built.exists():
|
|
186
|
+
shutil.copy2(built, website_static / output)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def watch_site_data(
|
|
190
|
+
content_types: set[str], stop_event: threading.Event, interval: float = 1.0
|
|
191
|
+
):
|
|
192
|
+
"""Rebuild a source's data files whenever one of its files changes.
|
|
193
|
+
|
|
194
|
+
Best effort: a half-saved or invalid file prints an error and the watcher
|
|
195
|
+
keeps going, so the next save can fix it.
|
|
196
|
+
"""
|
|
197
|
+
sources = _sources(content_types)
|
|
198
|
+
seen = {source.name: _snapshot(source) for source in sources}
|
|
199
|
+
while not stop_event.wait(interval):
|
|
200
|
+
for source in sources:
|
|
201
|
+
current = _snapshot(source)
|
|
202
|
+
if current == seen[source.name]:
|
|
203
|
+
continue
|
|
204
|
+
seen[source.name] = current
|
|
205
|
+
click.echo(
|
|
206
|
+
click.style(f"↻ {source.name} changed, rebuilding...", fg="cyan")
|
|
207
|
+
)
|
|
208
|
+
try:
|
|
209
|
+
rebuild_source(source)
|
|
210
|
+
except click.ClickException as e:
|
|
211
|
+
click.echo(click.style(f"✗ {e.format_message()}", fg="red"))
|
|
212
|
+
except Exception as e: # keep watching: a crash here would go unnoticed
|
|
213
|
+
click.echo(
|
|
214
|
+
click.style(f"✗ rebuilding {source.name} failed: {e!r}", fg="red")
|
|
215
|
+
)
|
|
@@ -5,7 +5,6 @@ from typing import TYPE_CHECKING
|
|
|
5
5
|
|
|
6
6
|
if TYPE_CHECKING:
|
|
7
7
|
from pathlib import Path
|
|
8
|
-
from typing import Literal
|
|
9
8
|
|
|
10
9
|
from afterpython._typing import NodeEnv
|
|
11
10
|
|
|
@@ -85,7 +84,7 @@ def _read_api_reference() -> bool:
|
|
|
85
84
|
return bool(website.get("api_reference", False))
|
|
86
85
|
|
|
87
86
|
|
|
88
|
-
def prebuild(dev_build: bool = False):
|
|
87
|
+
def prebuild(dev_build: bool = False, build_readme_py: bool = True):
|
|
89
88
|
def _check_initialized():
|
|
90
89
|
# Check if 'ap init' has been run
|
|
91
90
|
afterpython_toml = ap.paths.afterpython_path / "afterpython.toml"
|
|
@@ -117,21 +116,6 @@ def prebuild(dev_build: bool = False):
|
|
|
117
116
|
shutil.rmtree(path)
|
|
118
117
|
build_path.mkdir(parents=True, exist_ok=True)
|
|
119
118
|
|
|
120
|
-
def _get_readme_py_mode() -> Literal["wasm", "static"]:
|
|
121
|
-
"""Read `[website].readme_py` from afterpython.toml. Defaults to "wasm".
|
|
122
|
-
|
|
123
|
-
Falls back to "wasm" silently for unknown values rather than failing the
|
|
124
|
-
build — the metadata.json resolver does the same, keeping the two views
|
|
125
|
-
consistent.
|
|
126
|
-
"""
|
|
127
|
-
from afterpython._io.toml import _from_tomlkit
|
|
128
|
-
from afterpython.tools._afterpython import read_afterpython
|
|
129
|
-
|
|
130
|
-
afterpython = read_afterpython()
|
|
131
|
-
website = _from_tomlkit(afterpython.get("website", {}))
|
|
132
|
-
mode = str(website.get("readme_py", "wasm"))
|
|
133
|
-
return mode if mode in ("wasm", "static") else "wasm"
|
|
134
|
-
|
|
135
119
|
_check_initialized()
|
|
136
120
|
_clean_up_builds()
|
|
137
121
|
|
|
@@ -140,7 +124,12 @@ def prebuild(dev_build: bool = False):
|
|
|
140
124
|
build_metadata()
|
|
141
125
|
build_faq_json()
|
|
142
126
|
build_comments_json()
|
|
143
|
-
|
|
127
|
+
if build_readme_py:
|
|
128
|
+
build_marimo_readme()
|
|
129
|
+
else:
|
|
130
|
+
# _clean_up_builds() leaves _website/static/readme_py/ alone, so the
|
|
131
|
+
# home page keeps showing the previous export
|
|
132
|
+
click.echo("Skipping README.py (--no-readme-py flag)")
|
|
144
133
|
build_markdown()
|
|
145
134
|
# before build_jupyter_notebooks() so generated notebooks get the same
|
|
146
135
|
# thumbnail/molab post-processing as hand-written ones. Production builds
|
|
@@ -138,6 +138,11 @@ def _wait_for_myst_server(
|
|
|
138
138
|
is_flag=True,
|
|
139
139
|
help="Skip running the website dev server (pnpm dev). Useful when you want to run pnpm dev manually with custom options.",
|
|
140
140
|
)
|
|
141
|
+
@click.option(
|
|
142
|
+
"--no-readme-py",
|
|
143
|
+
is_flag=True,
|
|
144
|
+
help="Skip exporting the marimo afterpython/README.py at startup; the home page keeps the previous export. It is still re-exported when README.py changes.",
|
|
145
|
+
)
|
|
141
146
|
def dev(
|
|
142
147
|
ctx,
|
|
143
148
|
all: bool,
|
|
@@ -148,6 +153,7 @@ def dev(
|
|
|
148
153
|
guide: bool,
|
|
149
154
|
execute: bool,
|
|
150
155
|
no_website: bool,
|
|
156
|
+
no_readme_py: bool,
|
|
151
157
|
):
|
|
152
158
|
"""Run the development server for the project website.
|
|
153
159
|
|
|
@@ -167,6 +173,8 @@ def dev(
|
|
|
167
173
|
|
|
168
174
|
Use --no-website to skip the automatic 'pnpm dev' command, allowing you to run it manually
|
|
169
175
|
with custom Vite options in the afterpython/_website directory.
|
|
176
|
+
|
|
177
|
+
Use --no-readme-py to skip the (slow) marimo README.py export at startup.
|
|
170
178
|
"""
|
|
171
179
|
|
|
172
180
|
from afterpython.utils import handle_passthrough_help, is_website_initialized
|
|
@@ -233,7 +241,7 @@ def dev(
|
|
|
233
241
|
stop_watching = threading.Event()
|
|
234
242
|
|
|
235
243
|
try:
|
|
236
|
-
prebuild(dev_build=True)
|
|
244
|
+
prebuild(dev_build=True, build_readme_py=not no_readme_py)
|
|
237
245
|
|
|
238
246
|
# re-export marimo notebooks on save for the content types being served
|
|
239
247
|
if enabled_content_types:
|
|
@@ -304,6 +312,16 @@ def dev(
|
|
|
304
312
|
|
|
305
313
|
postbuild(dev_build=True)
|
|
306
314
|
|
|
315
|
+
# rebuild faq.json, metadata.json, blog.json etc. when their sources
|
|
316
|
+
# change; started after postbuild() so its first snapshot is current
|
|
317
|
+
from afterpython.builders.site_data import watch_site_data
|
|
318
|
+
|
|
319
|
+
threading.Thread(
|
|
320
|
+
target=watch_site_data,
|
|
321
|
+
args=(enabled_content_types, stop_watching),
|
|
322
|
+
daemon=True,
|
|
323
|
+
).start()
|
|
324
|
+
|
|
307
325
|
if not no_website:
|
|
308
326
|
node_env: NodeEnv = find_node_env()
|
|
309
327
|
click.echo("Running the web dev server...")
|
|
@@ -316,11 +334,10 @@ def dev(
|
|
|
316
334
|
click.echo(
|
|
317
335
|
"Skipping website dev server (--no-website flag). Run 'pnpm dev' manually in afterpython/_website/ with your custom options."
|
|
318
336
|
)
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
time.sleep(1)
|
|
337
|
+
# Keep running to maintain the MyST servers and the site data watcher
|
|
338
|
+
click.echo("Press Ctrl+C to stop...")
|
|
339
|
+
while True:
|
|
340
|
+
time.sleep(1)
|
|
324
341
|
except KeyboardInterrupt:
|
|
325
342
|
# Handle Ctrl+C during subprocess.run
|
|
326
343
|
pass
|
|
@@ -240,10 +240,9 @@ def init_myst(content_types: Iterable[tContentType] | None = None):
|
|
|
240
240
|
# "twitter": "",
|
|
241
241
|
},
|
|
242
242
|
}
|
|
243
|
-
# `myst init`
|
|
244
|
-
#
|
|
245
|
-
|
|
246
|
-
site_defaults["template"] = "article-theme"
|
|
243
|
+
# keep `myst init`'s book-theme for every content type, blog included:
|
|
244
|
+
# article-theme v2.0.0 (2026-11-10) fails `myst build --html` with
|
|
245
|
+
# 'No route matches URL "/_public/..."'
|
|
247
246
|
myst_yml_defaults = {
|
|
248
247
|
"extends": "../authors.yml",
|
|
249
248
|
"project": {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/templates/deploy-workflow-template.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/templates/pdoc/syntax-highlighting.css
RENAMED
|
File without changes
|
|
File without changes
|
{afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/templates/pre-commit-config-template.yaml
RENAMED
|
File without changes
|
{afterpython-0.4.7 → afterpython-0.4.9}/src/afterpython/templates/release-workflow-template.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|