afterpython 0.4.8__tar.gz → 0.5.0__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.8 → afterpython-0.5.0}/PKG-INFO +1 -1
- {afterpython-0.4.8 → afterpython-0.5.0}/pyproject.toml +1 -1
- {afterpython-0.4.8 → afterpython-0.5.0}/pyproject.toml.orig +1 -1
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/builders/__init__.py +2 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/builders/build_pdoc.py +2 -1
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/builders/metadata.py +3 -0
- afterpython-0.5.0/src/afterpython/builders/seo.py +218 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/build.py +7 -2
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/sync.py +5 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/templates/afterpython-template.toml +2 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/tools/myst.py +6 -10
- {afterpython-0.4.8 → afterpython-0.5.0}/README.md +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/__init__.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/_io/toml.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/_io/yaml.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/_paths.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/_typing.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/builders/comments_json.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/builders/content_json.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/builders/faq_json.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/builders/index_md.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/builders/jupyter_notebook.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/builders/llms_txt.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/builders/marimo_content.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/builders/marimo_notebook.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/builders/markdown.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/builders/site_data.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/builders/url_md.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/__init__.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/add.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/bump.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/changelog.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/check.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/clean.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/commit_msg.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/dev.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/format.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/init.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/init_branch_rules.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/install.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/lint.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/lock.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/prek.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/preview.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/release.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/remove.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/serve.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/start.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/commands/update.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/cli/main.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/const.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/main.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/pcu.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/py.typed +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/templates/ci-workflow-template.yml +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/templates/cliff-template.toml +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/templates/dependabot-template.yml +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/templates/deploy-workflow-template.yml +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/templates/pdoc/custom.css +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/templates/pdoc/frame.html.jinja2 +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/templates/pdoc/module.html.jinja2 +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/templates/pdoc/syntax-highlighting.css +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/templates/pdoc/theme.css +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/templates/pre-commit-config-template.yaml +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/templates/release-workflow-template.yml +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/templates/ruff-template.toml +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/templates/ty-template.toml +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/tools/_afterpython.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/tools/_git.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/tools/branch_rules.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/tools/github_actions.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/tools/prek.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/tools/pyproject.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/utils.py +0 -0
- {afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: afterpython
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
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
|
|
@@ -12,6 +12,7 @@ from afterpython.builders.marimo_content import build_marimo_content
|
|
|
12
12
|
from afterpython.builders.marimo_notebook import build_marimo_readme
|
|
13
13
|
from afterpython.builders.markdown import build_markdown
|
|
14
14
|
from afterpython.builders.metadata import build_metadata
|
|
15
|
+
from afterpython.builders.seo import build_seo
|
|
15
16
|
from afterpython.builders.url_md import build_url_md
|
|
16
17
|
|
|
17
18
|
__all__ = (
|
|
@@ -25,6 +26,7 @@ __all__ = (
|
|
|
25
26
|
"build_markdown",
|
|
26
27
|
"build_metadata",
|
|
27
28
|
"build_pdoc",
|
|
29
|
+
"build_seo",
|
|
28
30
|
"build_url_md",
|
|
29
31
|
"create_placeholder_index_md_files",
|
|
30
32
|
"delete_placeholder_index_md_files",
|
|
@@ -66,5 +66,6 @@ def build_pdoc(base_path: str) -> None:
|
|
|
66
66
|
if result.returncode != 0:
|
|
67
67
|
raise click.ClickException(
|
|
68
68
|
f"pdoc failed with exit code {result.returncode}. "
|
|
69
|
-
|
|
69
|
+
"To skip API reference generation, set `api_reference = false` "
|
|
70
|
+
"under [website] in afterpython.toml."
|
|
70
71
|
)
|
|
@@ -55,6 +55,9 @@ def build_metadata():
|
|
|
55
55
|
|
|
56
56
|
afterpython = read_afterpython()
|
|
57
57
|
website = _from_tomlkit(afterpython.get("website", {}))
|
|
58
|
+
# homepage <title>, e.g. "PyTrade - Python Trading Resources & Tutorials";
|
|
59
|
+
# empty means the frontend falls back to its own default
|
|
60
|
+
metadata_json["site_title"] = str(website.get("title", "")).strip()
|
|
58
61
|
metadata_json["announcement"] = str(website.get("announcement", "")).strip()
|
|
59
62
|
metadata_json["readme_py"] = _resolve_readme_py(website)
|
|
60
63
|
# Logos are served from the site root in _website/ (assets copied from
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"""Post-process the final static site (afterpython/_website/build/) for SEO.
|
|
2
|
+
|
|
3
|
+
Runs after `pnpm build`, on the HTML that actually gets deployed, so it covers
|
|
4
|
+
both the SvelteKit pages and the MyST content pages without touching either
|
|
5
|
+
generator:
|
|
6
|
+
|
|
7
|
+
- one canonical URL per page: `x/index.html` -> `{url}/x/`, `x.html` -> `{url}/x`,
|
|
8
|
+
matching how GitHub Pages serves them (no redirect, no duplicate)
|
|
9
|
+
- `<link rel="canonical">` injected into every indexable page
|
|
10
|
+
- internal links rewritten to that canonical form, so `/doc/quickstart` (301 on
|
|
11
|
+
GitHub Pages) becomes `/doc/quickstart/`
|
|
12
|
+
- `noindex` on the SPA fallback (200.html) and 404.html
|
|
13
|
+
- sitemap.xml listing every indexable page, plus a robots.txt pointing to it
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
|
|
18
|
+
import html
|
|
19
|
+
import posixpath
|
|
20
|
+
import re
|
|
21
|
+
from functools import partial
|
|
22
|
+
from pathlib import Path, PurePosixPath
|
|
23
|
+
from xml.sax.saxutils import escape
|
|
24
|
+
|
|
25
|
+
import click
|
|
26
|
+
|
|
27
|
+
import afterpython as ap
|
|
28
|
+
|
|
29
|
+
# pages that must not be indexed or listed in the sitemap
|
|
30
|
+
NOINDEX_FILES = {"200.html", "404.html"}
|
|
31
|
+
|
|
32
|
+
_HEAD_OPEN = re.compile(r"<head[^>]*>", re.IGNORECASE)
|
|
33
|
+
_CANONICAL = re.compile(r"<link[^>]*rel=[\"']?canonical", re.IGNORECASE)
|
|
34
|
+
_ROBOTS_NOINDEX = re.compile(
|
|
35
|
+
r"<meta[^>]*name=[\"']?robots[\"']?[^>]*noindex", re.IGNORECASE
|
|
36
|
+
)
|
|
37
|
+
# SvelteKit's prerendered redirect, e.g. blog/x.html -> blog/x/ (old post links)
|
|
38
|
+
_META_REFRESH = re.compile(r"<meta[^>]*http-equiv=[\"']?refresh", re.IGNORECASE)
|
|
39
|
+
# href on any tag, skipping external (scheme:) and fragment-only links
|
|
40
|
+
_HREF = re.compile(
|
|
41
|
+
r"""(\shref=)(["'])(?![a-zA-Z][\w+.-]*:|#)([^"']+)\2""", re.IGNORECASE
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _canonical_path(rel: PurePosixPath) -> str:
|
|
46
|
+
"""URL path (without base path) under which GitHub Pages serves `rel` with a 200."""
|
|
47
|
+
if rel.name == "index.html":
|
|
48
|
+
parent = rel.parent.as_posix()
|
|
49
|
+
return "/" if parent == "." else f"/{parent}/"
|
|
50
|
+
return "/" + rel.with_suffix("").as_posix()
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _is_redirect(text: str) -> bool:
|
|
54
|
+
head = text.split("</head>", 1)[0]
|
|
55
|
+
return bool(_META_REFRESH.search(head))
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def _canonical_map(build_dir: Path) -> dict[str, str]:
|
|
59
|
+
"""Map every URL path a page answers to (with and without the trailing
|
|
60
|
+
slash) to that page's canonical path."""
|
|
61
|
+
# redirect stubs aren't pages: they never win over x/index.html
|
|
62
|
+
canonicals = {
|
|
63
|
+
_canonical_path(PurePosixPath(f.relative_to(build_dir).as_posix()))
|
|
64
|
+
for f in build_dir.rglob("*.html")
|
|
65
|
+
if not _is_redirect(f.read_text(encoding="utf-8"))
|
|
66
|
+
}
|
|
67
|
+
mapping: dict[str, str] = {}
|
|
68
|
+
for canonical in sorted(canonicals):
|
|
69
|
+
bare = canonical.rstrip("/") or "/"
|
|
70
|
+
# `x.html` wins over `x/index.html` when both exist: it's what
|
|
71
|
+
# SvelteKit prerenders for routes like /faq and /blog
|
|
72
|
+
if canonical != "/" and canonical.endswith("/") and bare in canonicals:
|
|
73
|
+
continue
|
|
74
|
+
mapping[bare] = canonical
|
|
75
|
+
mapping[bare.rstrip("/") + "/"] = canonical
|
|
76
|
+
return mapping
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _rewrite_href(
|
|
80
|
+
match: re.Match,
|
|
81
|
+
page_dir: str,
|
|
82
|
+
base_path: str,
|
|
83
|
+
canonical_by_path: dict[str, str],
|
|
84
|
+
) -> str:
|
|
85
|
+
"""Fix the trailing slash of an internal link so it doesn't redirect.
|
|
86
|
+
|
|
87
|
+
Only the slash changes, so absolute (`/doc/x`) and relative (`./doc`, how
|
|
88
|
+
SvelteKit writes links) hrefs both keep their form.
|
|
89
|
+
"""
|
|
90
|
+
prefix, quote, url = match.group(1), match.group(2), match.group(3)
|
|
91
|
+
path, sep, rest = _split_url(url)
|
|
92
|
+
if not path or path.startswith("//"):
|
|
93
|
+
return match.group(0)
|
|
94
|
+
if path.startswith("/"):
|
|
95
|
+
if base_path:
|
|
96
|
+
if path != base_path and not path.startswith(base_path + "/"):
|
|
97
|
+
return match.group(0)
|
|
98
|
+
local = path[len(base_path) :] or "/"
|
|
99
|
+
else:
|
|
100
|
+
local = path
|
|
101
|
+
else:
|
|
102
|
+
local = posixpath.normpath(posixpath.join(page_dir, path))
|
|
103
|
+
if path.endswith("/") and not local.endswith("/"):
|
|
104
|
+
local += "/"
|
|
105
|
+
canonical = canonical_by_path.get(html.unescape(local))
|
|
106
|
+
if canonical is None or canonical == local:
|
|
107
|
+
return match.group(0)
|
|
108
|
+
new_path = path + "/" if canonical.endswith("/") else path.rstrip("/")
|
|
109
|
+
return f"{prefix}{quote}{new_path}{sep}{rest}{quote}"
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _split_url(url: str) -> tuple[str, str, str]:
|
|
113
|
+
"""Split '/a/b?x#y' into ('/a/b', '?', 'x#y')."""
|
|
114
|
+
for i, ch in enumerate(url):
|
|
115
|
+
if ch in "?#":
|
|
116
|
+
return url[:i], ch, url[i + 1 :]
|
|
117
|
+
return url, "", ""
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _read_website_url() -> str:
|
|
121
|
+
from afterpython._io.toml import _from_tomlkit
|
|
122
|
+
from afterpython.tools._afterpython import read_afterpython
|
|
123
|
+
|
|
124
|
+
website = _from_tomlkit(read_afterpython().get("website", {}))
|
|
125
|
+
return str(website.get("url", "")).strip().rstrip("/")
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def build_seo(base_path: str = ""):
|
|
129
|
+
"""Add canonical tags, fix internal links and write sitemap.xml/robots.txt.
|
|
130
|
+
|
|
131
|
+
Args:
|
|
132
|
+
base_path: BASE_PATH the site was built with ("" for a custom domain,
|
|
133
|
+
"/repo" for a default GitHub Pages URL); internal links carry it.
|
|
134
|
+
"""
|
|
135
|
+
build_dir = ap.paths.website_path / "build"
|
|
136
|
+
if not build_dir.exists():
|
|
137
|
+
return
|
|
138
|
+
website_url = _read_website_url()
|
|
139
|
+
if not website_url:
|
|
140
|
+
click.echo(
|
|
141
|
+
"Warning: [website].url is not set in afterpython.toml, "
|
|
142
|
+
"skipping canonical tags and sitemap.xml"
|
|
143
|
+
)
|
|
144
|
+
return
|
|
145
|
+
# website.url already includes the base path for github.io sites
|
|
146
|
+
site_root = website_url
|
|
147
|
+
if base_path and website_url.endswith(base_path):
|
|
148
|
+
site_root = website_url[: -len(base_path)]
|
|
149
|
+
|
|
150
|
+
click.echo("Adding canonical tags and building sitemap.xml...")
|
|
151
|
+
canonical_by_path = _canonical_map(build_dir)
|
|
152
|
+
|
|
153
|
+
sitemap_urls: list[str] = []
|
|
154
|
+
for file in sorted(build_dir.rglob("*.html")):
|
|
155
|
+
rel = PurePosixPath(file.relative_to(build_dir).as_posix())
|
|
156
|
+
text = file.read_text(encoding="utf-8")
|
|
157
|
+
original = text
|
|
158
|
+
if _is_redirect(text):
|
|
159
|
+
continue
|
|
160
|
+
noindex = rel.as_posix() in NOINDEX_FILES or bool(_ROBOTS_NOINDEX.search(text))
|
|
161
|
+
|
|
162
|
+
page_path = _canonical_path(rel)
|
|
163
|
+
# directory relative links resolve against: /x/ for x/index.html, / for x.html
|
|
164
|
+
page_dir = (
|
|
165
|
+
page_path if page_path.endswith("/") else posixpath.dirname(page_path)
|
|
166
|
+
)
|
|
167
|
+
text = _HREF.sub(
|
|
168
|
+
partial(
|
|
169
|
+
_rewrite_href,
|
|
170
|
+
page_dir=page_dir,
|
|
171
|
+
base_path=base_path,
|
|
172
|
+
canonical_by_path=canonical_by_path,
|
|
173
|
+
),
|
|
174
|
+
text,
|
|
175
|
+
)
|
|
176
|
+
# a shadowed x/index.html points at its x.html twin
|
|
177
|
+
canonical_url = (
|
|
178
|
+
site_root + base_path + canonical_by_path.get(page_path, page_path)
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
head = _HEAD_OPEN.search(text)
|
|
182
|
+
if head:
|
|
183
|
+
if rel.as_posix() in NOINDEX_FILES and not _ROBOTS_NOINDEX.search(text):
|
|
184
|
+
tag = '<meta name="robots" content="noindex">'
|
|
185
|
+
text = text[: head.end()] + tag + text[head.end() :]
|
|
186
|
+
elif not noindex and not _CANONICAL.search(text):
|
|
187
|
+
tag = f'<link rel="canonical" href="{html.escape(canonical_url)}">'
|
|
188
|
+
text = text[: head.end()] + tag + text[head.end() :]
|
|
189
|
+
|
|
190
|
+
if not noindex and head:
|
|
191
|
+
sitemap_urls.append(canonical_url)
|
|
192
|
+
if text != original:
|
|
193
|
+
file.write_text(text, encoding="utf-8")
|
|
194
|
+
|
|
195
|
+
_write_sitemap(build_dir, sitemap_urls)
|
|
196
|
+
_write_robots_txt(build_dir, f"{site_root}{base_path}/sitemap.xml")
|
|
197
|
+
click.echo(f"✓ sitemap.xml lists {len(sitemap_urls)} pages")
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def _write_sitemap(build_dir: Path, urls: list[str]):
|
|
201
|
+
lines = ['<?xml version="1.0" encoding="UTF-8"?>']
|
|
202
|
+
lines.append('<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">')
|
|
203
|
+
lines.extend(f" <url><loc>{escape(url)}</loc></url>" for url in sorted(set(urls)))
|
|
204
|
+
lines.append("</urlset>")
|
|
205
|
+
(build_dir / "sitemap.xml").write_text("\n".join(lines) + "\n", encoding="utf-8")
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def _write_robots_txt(build_dir: Path, sitemap_url: str):
|
|
209
|
+
"""Write robots.txt, or add the Sitemap line to a user-provided one."""
|
|
210
|
+
robots = build_dir / "robots.txt"
|
|
211
|
+
line = f"Sitemap: {sitemap_url}"
|
|
212
|
+
if robots.exists():
|
|
213
|
+
text = robots.read_text(encoding="utf-8")
|
|
214
|
+
if "sitemap:" in text.lower():
|
|
215
|
+
return
|
|
216
|
+
robots.write_text(text.rstrip("\n") + f"\n\n{line}\n", encoding="utf-8")
|
|
217
|
+
else:
|
|
218
|
+
robots.write_text(f"User-agent: *\nAllow: /\n\n{line}\n", encoding="utf-8")
|
|
@@ -26,6 +26,7 @@ from afterpython.builders import (
|
|
|
26
26
|
build_markdown,
|
|
27
27
|
build_metadata,
|
|
28
28
|
build_pdoc,
|
|
29
|
+
build_seo,
|
|
29
30
|
build_url_md,
|
|
30
31
|
create_placeholder_index_md_files,
|
|
31
32
|
delete_placeholder_index_md_files,
|
|
@@ -103,8 +104,9 @@ def prebuild(dev_build: bool = False, build_readme_py: bool = True):
|
|
|
103
104
|
content_build_paths = [
|
|
104
105
|
website_static_path / content_type for content_type in CONTENT_TYPES
|
|
105
106
|
]
|
|
106
|
-
# Also wipe the API reference static dir so a
|
|
107
|
-
# leave stale pages from a prior run
|
|
107
|
+
# Also wipe the API reference static dir so a build with
|
|
108
|
+
# `api_reference = false` doesn't leave stale pages from a prior run
|
|
109
|
+
# live on the deployed site.
|
|
108
110
|
api_static_path = website_static_path / "api_reference"
|
|
109
111
|
for path in [
|
|
110
112
|
build_path,
|
|
@@ -339,3 +341,6 @@ def build(ctx: click.Context, execute: bool):
|
|
|
339
341
|
)
|
|
340
342
|
if result.returncode != 0:
|
|
341
343
|
raise Exit(result.returncode)
|
|
344
|
+
|
|
345
|
+
# on the final HTML, so it covers both SvelteKit and MyST pages
|
|
346
|
+
build_seo(base_path=base_path)
|
|
@@ -67,6 +67,10 @@ def sync():
|
|
|
67
67
|
company_name = str(_from_tomlkit(afterpython.get("company", {})).get("name", ""))
|
|
68
68
|
company_url = str(_from_tomlkit(afterpython.get("company", {})).get("url", ""))
|
|
69
69
|
website_url = str(_from_tomlkit(afterpython.get("website", {})).get("url", ""))
|
|
70
|
+
# empty string disables analytics: MyST only emits gtag for a truthy id
|
|
71
|
+
google_analytics_id = str(
|
|
72
|
+
_from_tomlkit(afterpython.get("website", {})).get("google_analytics_id", "")
|
|
73
|
+
).strip()
|
|
70
74
|
try:
|
|
71
75
|
website_favicon = normalize_static_path(
|
|
72
76
|
str(_from_tomlkit(afterpython.get("website", {})).get("favicon", ""))
|
|
@@ -151,6 +155,7 @@ def sync():
|
|
|
151
155
|
else "",
|
|
152
156
|
"logo_text": project_name,
|
|
153
157
|
"logo_url": website_url,
|
|
158
|
+
"analytics_google": google_analytics_id,
|
|
154
159
|
},
|
|
155
160
|
# FIXME: disable nav bar for now until myst fixes the issue with the nav bar
|
|
156
161
|
# the current issue is they prepend the BASE_URL to the nav bar links even they are external
|
|
@@ -5,6 +5,8 @@ url = "" # used in myst.yml's venue.url
|
|
|
5
5
|
|
|
6
6
|
[website]
|
|
7
7
|
url = ""
|
|
8
|
+
title = "" # homepage <title>, put your main search keywords here, e.g. "pytrade - Python Trading Resources & Tutorials"
|
|
9
|
+
google_analytics_id = "" # e.g. "G-XXXXXXXXXX"; empty disables Google Analytics on doc/blog/... pages
|
|
8
10
|
favicon = "favicon.ico"
|
|
9
11
|
logo = "logo.svg"
|
|
10
12
|
logo_dark = "logo.svg"
|
|
@@ -234,16 +234,12 @@ def init_myst(content_types: Iterable[tContentType] | None = None):
|
|
|
234
234
|
env=node_env,
|
|
235
235
|
check=True,
|
|
236
236
|
)
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
# `myst init` defaults every project to book-theme; blog posts are
|
|
244
|
-
# standalone articles, so article-theme fits them better.
|
|
245
|
-
if content_type == "blog":
|
|
246
|
-
site_defaults["template"] = "article-theme"
|
|
237
|
+
# analytics_google is filled in by `ap sync` from
|
|
238
|
+
# [website].google_analytics_id in afterpython.toml
|
|
239
|
+
site_defaults: dict[str, Any] = {"options": {}}
|
|
240
|
+
# keep `myst init`'s book-theme for every content type, blog included:
|
|
241
|
+
# article-theme v2.0.0 (2026-11-10) fails `myst build --html` with
|
|
242
|
+
# 'No route matches URL "/_public/..."'
|
|
247
243
|
myst_yml_defaults = {
|
|
248
244
|
"extends": "../authors.yml",
|
|
249
245
|
"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
|
{afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/templates/deploy-workflow-template.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/templates/pdoc/syntax-highlighting.css
RENAMED
|
File without changes
|
|
File without changes
|
{afterpython-0.4.8 → afterpython-0.5.0}/src/afterpython/templates/pre-commit-config-template.yaml
RENAMED
|
File without changes
|
{afterpython-0.4.8 → afterpython-0.5.0}/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
|