Skip to content

Instantly share code, notes, and snippets.

@pawamoy
Last active May 4, 2023 15:37
Show Gist options
  • Save pawamoy/7b6712818054dcf596358711f18e878d to your computer and use it in GitHub Desktop.
Save pawamoy/7b6712818054dcf596358711f18e878d to your computer and use it in GitHub Desktop.
mkdocs to manpage
export BUILD_MANPAGE=true
export PERMALINK=false
export SHOW_SOURCE=false
mkdocs build
import os
import subprocess
pages = {}
if os.getenv("BUILD_MANPAGE"):
def on_page_content(html, page, **kwargs):
pages[page.file.src_uri] = html
def on_post_build(**kwargs):
combined = "\n\n".join(pages.values())
with open("site.html", "w") as file:
file.write(combined)
subprocess.run("pandoc --standalone --to man site.html -o site.1".split())
os.remove("site.html")
hooks:
- manpage.py
markdown_extensions:
- toc:
permalink: !ENV [PERMALINK, "¤"]
plugins:
- mkdocstrings:
handlers:
python:
options:
show_source: !ENV [SHOW_SOURCE, true]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment