You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@incubator.apache.org by jm...@apache.org on 2025/12/24 18:55:53 UTC
(incubator) branch master updated: search titles as well
This is an automated email from the ASF dual-hosted git repository.
jmclean pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator.git
The following commit(s) were added to refs/heads/master by this push:
new 59e42bf66 search titles as well
59e42bf66 is described below
commit 59e42bf6677cbeddeda4b4d5924e7043ca1a8825
Author: Justin Mclean <jm...@apache.org>
AuthorDate: Thu Dec 25 05:55:39 2025 +1100
search titles as well
---
tools/seealso/pagefind.py | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/tools/seealso/pagefind.py b/tools/seealso/pagefind.py
index 176ae7abf..7473fed61 100644
--- a/tools/seealso/pagefind.py
+++ b/tools/seealso/pagefind.py
@@ -38,20 +38,33 @@ TYPE_ICONS = {
}
def main() -> int:
- ap = argparse.ArgumentParser()
- ap.add_argument("yaml_path", help="Path to resources.yml")
- ap.add_argument("--out-dir", required=True, help="e.g. /tmp/incubator-site/training")
- ap.add_argument("--items-dir", default="_pagefind_items")
+ ap = argparse.ArgumentParser(
+ description="Generate Pagefind item HTML files from resources.yml"
+ )
+ ap.add_argument("yaml_path", help="Path to resources.yml (or resources.yaml)")
+ ap.add_argument(
+ "--out-dir",
+ required=True,
+ help="Output directory to write item pages into (e.g. $WORKDIR/training)",
+ )
+ ap.add_argument(
+ "--items-dir",
+ default="_pagefind_items",
+ help="Subdirectory under --out-dir for generated HTML items",
+ )
args = ap.parse_args()
yaml_path = Path(args.yaml_path).resolve()
out_dir = Path(args.out_dir).resolve()
out_dir.mkdir(parents=True, exist_ok=True)
+ if not yaml_path.exists():
+ raise SystemExit(f"ERROR: YAML not found: {yaml_path}")
+
data = yaml.safe_load(yaml_path.read_text(encoding="utf-8"))
resources = data.get("resources", [])
if not isinstance(resources, list):
- raise SystemExit("ERROR: resources.yaml must contain top-level 'resources:' list")
+ raise SystemExit("ERROR: resources.yml must contain a top-level 'resources:' list")
items_dir = out_dir / args.items_dir
items_dir.mkdir(parents=True, exist_ok=True)
@@ -75,17 +88,18 @@ def main() -> int:
desc = strip_leading_title_prefix(title, desc_raw)
icon = TYPE_ICONS.get(rtype, "")
- titled = f"{icon} {title}".strip() if icon else title
+ display_title = f"{icon} {title}".strip() if icon else title
body = f"""
<main data-pagefind-body>
+ <h1 hidden aria-hidden="true">{esc(title)}</h1>
<p>{esc(desc)}</p>
</main>
""".strip()
meta_filters = f"""
<div hidden aria-hidden="true">
<span data-pagefind-meta="url">{esc(url)}</span>
- <span data-pagefind-meta="title">{esc(titled)}</span>
+ <span data-pagefind-meta="title">{esc(display_title)}</span>
<span data-pagefind-filter="type">{esc(rtype)}</span>
{''.join(f'<span data-pagefind-filter="theme">{esc(t)}</span>' for t in themes)}
---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@incubator.apache.org
For additional commands, e-mail: cvs-help@incubator.apache.org