From 2c32f57f92788fa7923b4f35745d406b8407e0ac Mon Sep 17 00:00:00 2001 From: Chad Baker Date: Mon, 29 Jan 2024 11:46:05 -0700 Subject: [PATCH] first commit --- python/fastsim/generate_doc.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 python/fastsim/generate_doc.py diff --git a/python/fastsim/generate_doc.py b/python/fastsim/generate_doc.py new file mode 100644 index 00000000..5c764e81 --- /dev/null +++ b/python/fastsim/generate_doc.py @@ -0,0 +1,30 @@ +import fastsim as fsim +from pathlib import Path + +from pydoc_markdown.interfaces import Context +from pydoc_markdown.contrib.loaders.python import PythonLoader +from pydoc_markdown.contrib.renderers.markdown import MarkdownRenderer + +def main(): + context = Context(directory=fsim.package_root()) + loader = PythonLoader( + search_path=[fsim.package_root()], + ignore_when_discovered=["test", "tests", "setup", "demos"] + ) + renderer = MarkdownRenderer( + # TODO: figure out what options in here will produce same result as + # `pydoc-markdown -I python --render-toc > docs/src/python-doc.md` + # # Commented args + # render_toc=True, + # render_toc_title=False, + # toc_maxdepth=1, + ) + + loader.init(context) + renderer.init(context) + + modules = loader.load() + + with open(fsim.package_root() / "../../docs/src/python-doc.md", "w") as f: + f.write(renderer.render_to_string(modules)) +