Append the source summary wikilink to each page under '## Related Documents'. Shared by the concept and entity page-backlink wrappers.
(
wiki_dir: Path,
doc_name: str,
slugs: list[str],
*,
page_dir: str,
)
| 1239 | |
| 1240 | |
| 1241 | def _backlink_pages( |
| 1242 | wiki_dir: Path, |
| 1243 | doc_name: str, |
| 1244 | slugs: list[str], |
| 1245 | *, |
| 1246 | page_dir: str, |
| 1247 | ) -> None: |
| 1248 | """Append the source summary wikilink to each page under '## Related |
| 1249 | Documents'. Shared by the concept and entity page-backlink wrappers.""" |
| 1250 | link = f"[[summaries/{doc_name}]]" |
| 1251 | pages_dir = wiki_dir / page_dir |
| 1252 | |
| 1253 | for slug in slugs: |
| 1254 | path = pages_dir / f"{slug}.md" |
| 1255 | if not path.exists(): |
| 1256 | continue |
| 1257 | text = path.read_text(encoding="utf-8") |
| 1258 | if link in text: |
| 1259 | continue |
| 1260 | lines = text.split("\n") |
| 1261 | _ensure_h2_section(lines, "## Related Documents", quiet=True) |
| 1262 | _insert_section_entry(lines, "## Related Documents", f"- {link}") |
| 1263 | atomic_write_text(path, "\n".join(lines)) |
| 1264 | |
| 1265 | |
| 1266 | def _backlink_summary(wiki_dir: Path, doc_name: str, concept_slugs: list[str]) -> None: |
no test coverage detected