""" Convert the docs to html, so that they can be copy-pasted into the BayernCollab Wiki """ import os, markdown DOC_DIR = "~/cpd-dev/cpdctrl-gui/cpdctrl_gui/resources" OUT_DIR = "~/cpd-dev/docs" def convert(filepath: str): with open(filepath, "r") as file: content = file.read() html = markdown.markdown(content, output_format="html") return html if __name__ == '__main__': DOC_DIR = os.path.expanduser(DOC_DIR) docs = [os.path.join(DOC_DIR, f) for f in os.listdir(DOC_DIR)] docs.sort() OUT_DIR = os.path.expanduser(OUT_DIR) if not os.path.isdir(OUT_DIR): os.makedirs(OUT_DIR) for file in docs: if file.endswith(".md"): html_file = os.path.join(OUT_DIR, os.path.basename(file).replace(".md", ".html")) print(f"{file} -> {html_file}") html = convert(file) html = html.replace("
", "
") with open(html_file, "w") as file: file.write(html)