From: Jean-Philippe ARGAUD Date: Thu, 23 Apr 2020 12:05:25 +0000 (+0200) Subject: Conditional use 'Read The Docs' theme for documentation (Tuleap [bos #18858]) X-Git-Tag: V9_5_0b~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=41318093d0b91e9fe6dd36bc3d3f3ea306fa9710;p=modules%2Fadao.git Conditional use 'Read The Docs' theme for documentation (Tuleap [bos #18858]) --- diff --git a/doc/en/conf.py b/doc/en/conf.py index 21890c6..d8e4f82 100644 --- a/doc/en/conf.py +++ b/doc/en/conf.py @@ -22,23 +22,30 @@ # # Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D -import sys, os, sphinx -import sphinx_rtd_theme +import sys, os, time, sphinx, logging + +# -- ADAO version information -------------------------------------------------- try: sys.path.append(os.path.abspath("../../bin")) import module_version - print("Import du module_version de bin...") + logging.debug('Using "module_version" that was found from "bin"...') except: pass try: sys.path.append(os.path.abspath("../../adao/adao/daCore")) import version as module_version - print("Import du module_version de daCore...") + logging.debug('Using "module_version" that was found from "daCore"...') except: pass +if "module_version" not in locals(): + module_version = lambda : None + module_version.name = "ADAO" + module_version.year = "%s"%(time.localtime()[0],) + module_version.version = "" + logging.warning('Using fallback "module_version" because none was found') -# -- Project information ----------------------------------------------------- +# -- Project information ------------------------------------------------------- project = u'%s'%module_version.name author = u'Jean-Philippe ARGAUD' @@ -48,45 +55,58 @@ release = '%s'%module_version.version doctitle = u"%s documentation"%module_version.name docfull = u"Aiding for Data Assimilation and Optimization" -# -- General configuration --------------------------------------------------- +# -- General configuration ----------------------------------------------------- from distutils.version import LooseVersion #, StrictVersion -if LooseVersion(sphinx.__version__) < LooseVersion("1.4.0"): - extensions = [ - 'sphinx.ext.pngmath', - 'sphinx_rtd_theme', - ] +__lv = LooseVersion(sphinx.__version__) +if __lv < LooseVersion("1.4.0"): + extensions = ['sphinx.ext.pngmath'] else: - extensions = [ - 'sphinx.ext.imgmath', - 'sphinx_rtd_theme', - ] + extensions = ['sphinx.ext.imgmath'] +try: + import sphinx_rtd_theme + extensions += ['sphinx_rtd_theme'] + use_rtd_theme = True + logging.debug('Using "sphinx_rtd_theme" that was found') +except: + use_rtd_theme = False + logging.debug('Not using "sphinx_rtd_theme" because none was found') # source_suffix = '.rst' source_encoding = 'utf-8' master_doc = 'index' language = 'en' -exclude_patterns = ['snippets', 'scripts', 'resources', '_build', 'Thumbs.db', '.DS_Store', 'Grenier'] +exclude_patterns = [ + 'snippets', + 'scripts', + 'resources', + '_build', + 'Thumbs.db', + '.DS_Store', + 'Grenier', + ] pygments_style = None templates_path = ['_templates'] exclude_trees = ['snippets',] -# -- Options for HTML output ------------------------------------------------- +# -- Options for HTML output --------------------------------------------------- -html_theme = "sphinx_rtd_theme" -# html_theme = 'default' -# html_theme = 'alabaster' +if use_rtd_theme: + html_theme = "sphinx_rtd_theme" +else: + html_theme = 'default' if __lv < LooseVersion("1.3.0") else 'classic' +# html_title = doctitle html_static_path = ['_static'] html_show_sourcelink = False -# -- Options for HTMLHelp output --------------------------------------------- +# -- Options for HTMLHelp output ----------------------------------------------- htmlhelp_basename = 'ADAOdoc' -# -- Options for LaTeX output ------------------------------------------------ +# -- Options for LaTeX output -------------------------------------------------- latex_elements = { - 'papersize': 'letterpaper', + 'papersize': 'a4paper', 'pointsize': '10pt', 'figure_align': 'htbp', } @@ -95,20 +115,20 @@ latex_documents = [ author, 'manual'), ] -# -- Options for manual page output ------------------------------------------ +# -- Options for manual page output -------------------------------------------- man_pages = [ (master_doc, 'adao', doctitle, [author], 1) ] -# -- Options for Texinfo output ---------------------------------------------- +# -- Options for Texinfo output ------------------------------------------------ texinfo_documents = [ (master_doc, 'ADAO', doctitle, author, 'ADAO', docfull, 'Miscellaneous'), ] -# -- Options for Epub output ------------------------------------------------- +# -- Options for Epub output --------------------------------------------------- epub_title = doctitle epub_author = author @@ -116,7 +136,7 @@ epub_publisher = author epub_copyright = copyright epub_exclude_files = ['search.html'] -# -- Options for PDF output -------------------------------------------------- +# -- Options for PDF output ---------------------------------------------------- pdf_documents = [ ('contents', u'ADAO', u'ADAO', author, dict(pdf_compressed = True)), @@ -125,4 +145,4 @@ pdf_stylesheets = ['sphinx','kerning','a4'] pdf_compressed = True pdf_inline_footnotes = True -# -- Extension configuration ------------------------------------------------- +# -- Extension configuration --------------------------------------------------- diff --git a/doc/fr/conf.py b/doc/fr/conf.py index b6d9aa4..e0dffd4 100644 --- a/doc/fr/conf.py +++ b/doc/fr/conf.py @@ -22,23 +22,30 @@ # # Author: Jean-Philippe Argaud, jean-philippe.argaud@edf.fr, EDF R&D -import sys, os, sphinx -import sphinx_rtd_theme +import sys, os, time, sphinx, logging + +# -- ADAO version information -------------------------------------------------- try: sys.path.append(os.path.abspath("../../bin")) import module_version - print("Import du module_version de bin...") + logging.debug('Using "module_version" that was found from "bin"...') except: pass try: sys.path.append(os.path.abspath("../../adao/adao/daCore")) import version as module_version - print("Import du module_version de daCore...") + logging.debug('Using "module_version" that was found from "daCore"...') except: pass +if "module_version" not in locals(): + module_version = lambda : None + module_version.name = "ADAO" + module_version.year = "%s"%(time.localtime()[0],) + module_version.version = "" + logging.warning('Using fallback "module_version" because none was found') -# -- Project information ----------------------------------------------------- +# -- Project information ------------------------------------------------------- project = u'%s'%module_version.name author = u'Jean-Philippe ARGAUD' @@ -48,42 +55,55 @@ release = '%s'%module_version.version doctitle = u"Documentation %s"%module_version.name docfull = u"Assimilation de Données et Aide à l'Optimisation" -# -- General configuration --------------------------------------------------- +# -- General configuration ----------------------------------------------------- from distutils.version import LooseVersion #, StrictVersion -if LooseVersion(sphinx.__version__) < LooseVersion("1.4.0"): - extensions = [ - 'sphinx.ext.pngmath', - 'sphinx_rtd_theme', - ] +__lv = LooseVersion(sphinx.__version__) +if __lv < LooseVersion("1.4.0"): + extensions = ['sphinx.ext.pngmath'] else: - extensions = [ - 'sphinx.ext.imgmath', - 'sphinx_rtd_theme', - ] + extensions = ['sphinx.ext.imgmath'] +try: + import sphinx_rtd_theme + extensions += ['sphinx_rtd_theme'] + use_rtd_theme = True + logging.debug('Using "sphinx_rtd_theme" that was found') +except: + use_rtd_theme = False + logging.debug('Not using "sphinx_rtd_theme" because none was found') # source_suffix = '.rst' source_encoding = 'utf-8' master_doc = 'index' language = 'fr' -exclude_patterns = ['snippets', 'scripts', 'resources', '_build', 'Thumbs.db', '.DS_Store', 'Grenier'] +exclude_patterns = [ + 'snippets', + 'scripts', + 'resources', + '_build', + 'Thumbs.db', + '.DS_Store', + 'Grenier', + ] pygments_style = None templates_path = ['_templates'] exclude_trees = ['snippets',] -# -- Options for HTML output ------------------------------------------------- +# -- Options for HTML output --------------------------------------------------- -html_theme = "sphinx_rtd_theme" -# html_theme = 'default' -# html_theme = 'alabaster' +if use_rtd_theme: + html_theme = "sphinx_rtd_theme" +else: + html_theme = 'default' if __lv < LooseVersion("1.3.0") else 'classic' +# html_title = doctitle html_static_path = ['_static'] html_show_sourcelink = False -# -- Options for HTMLHelp output --------------------------------------------- +# -- Options for HTMLHelp output ----------------------------------------------- htmlhelp_basename = 'ADAOdoc' -# -- Options for LaTeX output ------------------------------------------------ +# -- Options for LaTeX output -------------------------------------------------- latex_elements = { 'papersize': 'a4paper', @@ -95,20 +115,20 @@ latex_documents = [ author, 'manual'), ] -# -- Options for manual page output ------------------------------------------ +# -- Options for manual page output -------------------------------------------- man_pages = [ (master_doc, 'adao', doctitle, [author], 1) ] -# -- Options for Texinfo output ---------------------------------------------- +# -- Options for Texinfo output ------------------------------------------------ texinfo_documents = [ (master_doc, 'ADAO', doctitle, author, 'ADAO', docfull, 'Miscellaneous'), ] -# -- Options for Epub output ------------------------------------------------- +# -- Options for Epub output --------------------------------------------------- epub_title = doctitle epub_author = author @@ -116,7 +136,7 @@ epub_publisher = author epub_copyright = copyright epub_exclude_files = ['search.html'] -# -- Options for PDF output -------------------------------------------------- +# -- Options for PDF output ---------------------------------------------------- pdf_documents = [ ('contents', u'ADAO', u'ADAO', author, dict(pdf_compressed = True)), @@ -125,4 +145,4 @@ pdf_stylesheets = ['sphinx','kerning','a4'] pdf_compressed = True pdf_inline_footnotes = True -# -- Extension configuration ------------------------------------------------- +# -- Extension configuration ---------------------------------------------------