Last active
May 4, 2023 15:37
-
-
Save pawamoy/7b6712818054dcf596358711f18e878d to your computer and use it in GitHub Desktop.
mkdocs to manpage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export BUILD_MANPAGE=true | |
export PERMALINK=false | |
export SHOW_SOURCE=false | |
mkdocs build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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