INNER CODE UNIT · Python
build_manifest
OWASP/wstg · .github/ebooks/build-link-manifest.py:86
def build_manifest(root: str, output: str) -> None:
"""Walk all .md files in root, extract headings, write manifest."""
root = os.path.abspath(root)
manifest: dict[str, dict[str, str]] = {}
for dirpath, dirnames, filenames in os.walk(root, topdown=True):
dirnames.sort()
for filename in sorted(filenames):
if not filename.lower().endswith(".md"):
continue
full_path = os.path.join(dirpath, filename)
rel_path = os.path.relpath(full_path, root)
try:
result = subprocess.run(
["pandoc", "-t", "json", full_path],
capture_output=True,