Append missing ``[[{page_dir}/slug]]`` wikilinks to the summary page. Closes the bidirectional link the pages already hold toward the summary, inserting them under ``section`` (created if absent). Shared by the concept and entity summary-backlink wrappers below.
(
wiki_dir: Path,
doc_name: str,
slugs: list[str],
*,
page_dir: str,
section: str,
)
| 1209 | |
| 1210 | |
| 1211 | def _backlink_summary_pages( |
| 1212 | wiki_dir: Path, |
| 1213 | doc_name: str, |
| 1214 | slugs: list[str], |
| 1215 | *, |
| 1216 | page_dir: str, |
| 1217 | section: str, |
| 1218 | ) -> None: |
| 1219 | """Append missing ``[[{page_dir}/slug]]`` wikilinks to the summary page. |
| 1220 | |
| 1221 | Closes the bidirectional link the pages already hold toward the summary, |
| 1222 | inserting them under ``section`` (created if absent). Shared by the |
| 1223 | concept and entity summary-backlink wrappers below. |
| 1224 | """ |
| 1225 | summary_path = wiki_dir / "summaries" / f"{doc_name}.md" |
| 1226 | if not summary_path.exists(): |
| 1227 | return |
| 1228 | |
| 1229 | text = summary_path.read_text(encoding="utf-8") |
| 1230 | missing = [slug for slug in slugs if f"[[{page_dir}/{slug}]]" not in text] |
| 1231 | if not missing: |
| 1232 | return |
| 1233 | |
| 1234 | lines = text.split("\n") |
| 1235 | _ensure_h2_section(lines, section, quiet=True) |
| 1236 | for slug in reversed(missing): |
| 1237 | _insert_section_entry(lines, section, f"- [[{page_dir}/{slug}]]") |
| 1238 | atomic_write_text(summary_path, "\n".join(lines)) |
| 1239 | |
| 1240 | |
| 1241 | def _backlink_pages( |
no test coverage detected