From 6314f8bb3690c5e8cdc28e17615e31d23940bf05 Mon Sep 17 00:00:00 2001 From: MCamp859 Date: Wed, 3 Mar 2021 14:13:23 -0500 Subject: [PATCH] Adds starlingxdocs_plus theme for version button This theme extends legacy openstackdocstheme and starlingxdocstheme. This first patch set to test theme additions. Button is not displayed in this patch. Change-Id: I3bedd09e63e7706ff6da3e5a4a87cc460dacd99a Signed-off-by: MCamp859 --- .../_themes/starlingxdocs_plus/__init__.py | 26 +++++++++++++++ .../starlingxdocs_plus/static/custom.css | 3 ++ .../_themes/starlingxdocs_plus/theme.conf | 2 ++ .../_themes/starlingxdocs_plus/titlerow.html | 33 +++++++++++++++++++ doc/source/conf.py | 30 +++++++++++++---- 5 files changed, 87 insertions(+), 7 deletions(-) create mode 100644 doc/source/_themes/starlingxdocs_plus/__init__.py create mode 100644 doc/source/_themes/starlingxdocs_plus/static/custom.css create mode 100644 doc/source/_themes/starlingxdocs_plus/theme.conf create mode 100644 doc/source/_themes/starlingxdocs_plus/titlerow.html diff --git a/doc/source/_themes/starlingxdocs_plus/__init__.py b/doc/source/_themes/starlingxdocs_plus/__init__.py new file mode 100644 index 000000000..ea977fe89 --- /dev/null +++ b/doc/source/_themes/starlingxdocs_plus/__init__.py @@ -0,0 +1,26 @@ +import openstackdocstheme as osdt + +def _html_page_context(app, pagename, templatename, context, doctree): + context['this_version']=app.config.starlingxdocs_plus_this_version + context['other_versions']=app.config.starlingxdocs_plus_other_versions + context['bug_project'] = app.config.starlingxdocs_plus_bug_project + context['bug_tag'] = app.config.starlingxdocs_plus_bug_tag + +def setup(app): + app.add_html_theme( + 'openstackdocs', + osdt.__path__[0] + '/theme/openstackdocs', + ) + app.add_html_theme( + 'starlingxdocs', + osdt.__path__[0] + '/theme/starlingxdocs', + ) + app.add_config_value('starlingxdocs_plus_this_version','','env') + app.add_config_value('starlingxdocs_plus_other_versions', [], 'env') + app.add_config_value('starlingxdocs_plus_repo_name','','env') + app.add_config_value('starlingxdocs_plus_project','','env') + app.add_config_value('starlingxdocs_plus_auto_name', False, 'env') + app.add_config_value('starlingxdocs_plus_bug_project','','env') + app.add_config_value('starlingxdocs_plus_bug_tag','','env') + app.connect('html-page-context', _html_page_context) + app.add_css_file("custom.css") \ No newline at end of file diff --git a/doc/source/_themes/starlingxdocs_plus/static/custom.css b/doc/source/_themes/starlingxdocs_plus/static/custom.css new file mode 100644 index 000000000..5dfbe0014 --- /dev/null +++ b/doc/source/_themes/starlingxdocs_plus/static/custom.css @@ -0,0 +1,3 @@ +.version-dropdown-content { + top: 12px; +} \ No newline at end of file diff --git a/doc/source/_themes/starlingxdocs_plus/theme.conf b/doc/source/_themes/starlingxdocs_plus/theme.conf new file mode 100644 index 000000000..3bc19c914 --- /dev/null +++ b/doc/source/_themes/starlingxdocs_plus/theme.conf @@ -0,0 +1,2 @@ +[theme] +inherit = starlingxdocs \ No newline at end of file diff --git a/doc/source/_themes/starlingxdocs_plus/titlerow.html b/doc/source/_themes/starlingxdocs_plus/titlerow.html new file mode 100644 index 000000000..538f57b04 --- /dev/null +++ b/doc/source/_themes/starlingxdocs_plus/titlerow.html @@ -0,0 +1,33 @@ +
+
+ {%- if theme_sidebar_dropdown == 'os_docs' %} +

{{ title }}

+ {% else %} +

StarlingX API Documentation

+ {%- endif %} +
+
+ {%- block otherversions %} + {%- if other_versions %} +
+ {{ _('version') }} +
+

{{ this_version }}

+ {%- for ver in other_versions: %} +

{{ ver[0] }}

+ {%- endfor %} +
+
+ {%- endif %} + {%- endblock %} + {% if prev %} + + {% endif %} + {% if next %} + + {% endif %} + {%- if bug_project %} + + {% endif %} +
+
diff --git a/doc/source/conf.py b/doc/source/conf.py index 6d209702f..7d2f760b9 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -14,6 +14,7 @@ # import os import sys +sys.path.insert(0,os.path.abspath('_themes')) # sys.path.insert(0, os.path.abspath('.')) @@ -34,7 +35,8 @@ author = 'StarlingX' # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'openstackdocstheme', +# 'openstackdocstheme', + 'starlingxdocs_plus' ] # Add any paths that contain templates here, relative to this directory. @@ -65,11 +67,12 @@ exclude_patterns = [] pygments_style = 'native' # General information about the project. -openstackdocs_repo_name = 'openstack/stx-docs' -openstackdocs_project = 'StarlingX' -openstackdocs_auto_name = False -openstackdocs_bug_project = 'starlingx' -openstackdocs_bug_tag = 'stx.docs' +# Legacy openstackdocstheme variables +# openstackdocs_repo_name = 'openstack/stx-docs' +# openstackdocs_project = 'StarlingX' +# openstackdocs_auto_name = False +# openstackdocs_bug_project = 'starlingx' +# openstackdocs_bug_tag = 'stx.docs' # Common substitution strings such as organization, product @@ -82,7 +85,8 @@ rst_prolog = open('./shared/strings.txt', 'r').read() # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'starlingxdocs' +html_theme_path = ['_themes'] +html_theme = 'starlingxdocs_plus' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -165,3 +169,15 @@ texinfo_documents = [ author, 'stx-docs', 'One line description of project.', 'Miscellaneous'), ] + +# -- Options for starlingxdocs_plus theme output ----------------------------- +# General information about the project. + +starlingxdocs_plus_repo_name = 'openstack/stx-docs' +starlingxdocs_plus_project = 'StarlingX' +starlingxdocs_plus_auto_name = False +starlingxdocs_plus_bug_project = 'starlingx' +starlingxdocs_plus_bug_tag = 'stx.docs' +starlingxdocs_plus_this_version = "latest" +# starlingxdocs_plus_other_versions = [("even later","even-later"),("sooner","sooner")] +starlingxdocs_plus_other_versions = []