2014-11-07 16:28:27 -06:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import markdown
|
|
|
|
import os
|
|
|
|
from codecs import open as _open
|
|
|
|
import languageHandler
|
|
|
|
languageHandler.setLanguage("en")
|
|
|
|
import strings
|
2016-10-09 10:45:47 -05:00
|
|
|
import changelog
|
2014-11-07 16:28:27 -06:00
|
|
|
|
|
|
|
# the list of supported language codes of TW Blue
|
2017-07-16 04:26:45 -05:00
|
|
|
languages = ["en", "es", "fr", "de", "it", "gl", "ja", "ru", "ro", "eu"]
|
2014-11-07 16:28:27 -06:00
|
|
|
#"eu", "ar", "ca", "es", "fi", "fr", "gl", "hu", "it", "pl", "pt", "ru", "tr"]
|
|
|
|
|
2016-10-09 10:45:47 -05:00
|
|
|
def generate_document(language, document_type="documentation"):
|
2014-11-07 16:28:27 -06:00
|
|
|
reload(languageHandler)
|
2016-10-09 10:45:47 -05:00
|
|
|
if document_type == "documentation":
|
|
|
|
translation_file = "twblue-documentation"
|
|
|
|
languageHandler.setLanguage(language, translation_file)
|
|
|
|
reload(strings)
|
|
|
|
markdown_file = markdown.markdown("\n".join(strings.documentation[1:]), extensions=["markdown.extensions.toc"])
|
|
|
|
title = strings.documentation[0]
|
|
|
|
filename = "manual.html"
|
|
|
|
elif document_type == "changelog":
|
|
|
|
translation_file = "twblue-changelog"
|
|
|
|
languageHandler.setLanguage(language, translation_file)
|
|
|
|
reload(changelog)
|
|
|
|
markdown_file = markdown.markdown("\n".join(changelog.documentation[1:]), extensions=["markdown.extensions.toc"])
|
|
|
|
title = changelog.documentation[0]
|
|
|
|
filename = "changelog.html"
|
2014-11-07 16:28:27 -06:00
|
|
|
first_html_block = """<!doctype html>
|
|
|
|
<html lang="%s">
|
|
|
|
<head>
|
|
|
|
<title>%s</title>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<header><h1>%s</h1></header>
|
2016-10-09 10:45:47 -05:00
|
|
|
""" % (language, title, title)
|
2014-11-07 16:28:27 -06:00
|
|
|
first_html_block = first_html_block+ markdown_file
|
|
|
|
first_html_block = first_html_block + "\n</body>\n</html>"
|
|
|
|
if not os.path.exists(language):
|
|
|
|
os.mkdir(language)
|
2016-10-09 10:45:47 -05:00
|
|
|
mdfile = _open("%s/%s" % (language, filename), "w", encoding="utf-8")
|
2014-11-07 16:28:27 -06:00
|
|
|
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)
|
2016-10-09 10:45:47 -05:00
|
|
|
generate_document(i, "changelog")
|
2014-11-07 16:28:27 -06:00
|
|
|
print("Done")
|
|
|
|
|
|
|
|
create_documentation()
|