# -*- coding: utf-8 -*- import markdown import os from codecs import open as _open import languageHandler languageHandler.setLanguage("en") # the list of supported language codes of TW Blue languages = ["en", "es"] def generate_document(language): if os.path.exists("documentation") == False: os.mkdir("documentation") import strings reload(languageHandler) languageHandler.setLanguage(language) reload(strings) markdown_file = markdown.markdown("\n".join(strings.documentation[1:]), extensions=["markdown.extensions.toc"]) first_html_block = """ %s

%s

""" % (language, strings.documentation[0], strings.documentation[0]) first_html_block = first_html_block+ markdown_file first_html_block = first_html_block + "\n\n" if not os.path.exists(os.path.join("documentation", language)): os.mkdir(os.path.join("documentation", language)) mdfile = _open("%s/manual.html" % os.path.join("documentation", language), "w", encoding="utf-8") mdfile.write(first_html_block) mdfile.close() def create_documentation(): print("Creating documentation in the supported languages...\n") for i in languages: print("Creating documentation for: %s" % (i,)) generate_document(i) print("Done") create_documentation()