From dfa597f2d095879590a213f6ba7a6275443dd384 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Wed, 19 Dec 2018 04:58:34 -0600 Subject: [PATCH] Added changelog as a translatable document. Copy license appropiately --- .gitlab-ci.yml | 1 - doc/generator.py | 36 ++++++++++++++++++++++++++---------- src/setup.py | 2 +- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 61f48ad..3847e28 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,6 @@ production: - python documentation_importer.py - cd ..\src - python ..\doc\generator.py - - copy ..\license.txt documentation\license.txt - python setup.py py2exe - cd .. - cd scripts diff --git a/doc/generator.py b/doc/generator.py index dd60064..e55d40c 100644 --- a/doc/generator.py +++ b/doc/generator.py @@ -1,21 +1,32 @@ # -*- coding: utf-8 -*- import markdown import os +import shutil from codecs import open as _open import languageHandler languageHandler.setLanguage("en") +import strings +import changelog -# the list of supported language codes of TW Blue +# the list of supported language codes languages = ["en", "es"] -def generate_document(language): - if os.path.exists("documentation") == False: - os.mkdir("documentation") - import strings +def generate_document(language, document_type="documentation"): reload(languageHandler) - languageHandler.setLanguage(language) - reload(strings) - markdown_file = markdown.markdown("\n".join(strings.documentation[1:]), extensions=["markdown.extensions.toc"]) + if document_type == "documentation": + translation_file = "socializer-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 = "socializer-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" first_html_block = """ @@ -24,20 +35,25 @@ def generate_document(language):

%s

- """ % (language, strings.documentation[0], strings.documentation[0]) + """ % (language, title, title) 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 = _open(os.path.join("documentation", language, filename), "w", encoding="utf-8") mdfile.write(first_html_block) mdfile.close() def create_documentation(): print("Creating documentation in the supported languages...\n") + if not os.path.exists("documentation"): + os.mkdir("documentation") + if os.path.exists(os.path.join("documentation", "license.txt")) == False: + shutil.copy(os.path.join("..", "license.txt"), os.path.join("documentation", "license.txt")) for i in languages: print("Creating documentation for: %s" % (i,)) generate_document(i) + generate_document(i, "changelog") print("Done") create_documentation() \ No newline at end of file diff --git a/src/setup.py b/src/setup.py index 5503fe4..d822e2c 100644 --- a/src/setup.py +++ b/src/setup.py @@ -47,7 +47,7 @@ def get_data(): ]+get_sounds()+get_locales()+get_documentation()+accessible_output2.find_datafiles()+enchant.utils.win32_data_files()+get_architecture_files()+sound_lib.find_datafiles() def get_documentation (): - answer = [] + answer = [("documentation", ["documentation/license.txt"])] depth = 6 for root, dirs, files in os.walk('documentation'): if depth == 0: