This is an automated email from the ASF dual-hosted git repository.

ash pushed a commit to branch theme_options_instead_of_custom_config
in repository https://gitbox.apache.org/repos/asf/airflow-site.git

commit ae05b04ba05c1ba66af8b474cff062302033fac4
Author: Ash Berlin-Taylor <[email protected]>
AuthorDate: Wed Dec 9 12:42:22 2020 +0000

    Add theme options to theme.conf
    
    Rather than using custom config properties, and then putting them in to
    the theme context, this uses Sphinx's built in mechanism that
    automatically exposes every option in `theme.conf` with a `theme_`
    prefix.
---
 .../sphinx_airflow_theme/__init__.py               | 24 ++++------------------
 .../sphinx_airflow_theme/header.html               |  6 +++---
 .../sphinx_airflow_theme/theme.conf                |  1 +
 3 files changed, 8 insertions(+), 23 deletions(-)

diff --git a/sphinx_airflow_theme/sphinx_airflow_theme/__init__.py 
b/sphinx_airflow_theme/sphinx_airflow_theme/__init__.py
index 11cb41b..50283a8 100644
--- a/sphinx_airflow_theme/sphinx_airflow_theme/__init__.py
+++ b/sphinx_airflow_theme/sphinx_airflow_theme/__init__.py
@@ -28,29 +28,13 @@ def get_html_theme_path():
     return cur_dir
 
 
-def setup_my_func(app, pagename, templatename, context, doctree):
-    context["navbar_links"] = app.config.sphinx_airflow_theme_navbar_links
-    context["hide_website_buttons"] = (
-        app.config.sphinx_airflow_theme_hide_website_buttons
-    )
+def setup_my_func(app, config):
+    # We can't set this in the theme.conf, cos we want it to be a non-string 
type
+    config.html_theme_options.setdefault([{'href': '/index.html', 'text': 
'Documentation'}])
 
 
 # See 
http://www.sphinx-doc.org/en/stable/theming.html#distribute-your-theme-as-a-python-package
 def setup(app: Sphinx):
-    app.add_config_value(
-        'sphinx_airflow_theme_navbar_links',
-        default=[
-            {'href': '/docs/', 'text': 'Documentation'}
-        ],
-        rebuild='html'
-    )
-    app.add_config_value(
-        'sphinx_airflow_theme_hide_website_buttons',
-        default=False,
-        rebuild='html',
-        types=[bool]
-    )
-
     app.add_html_theme('sphinx_airflow_theme', 
path.abspath(path.dirname(__file__)))
     app.add_stylesheet('_gen/css/main-custom.min.css')
-    app.connect("html-page-context", setup_my_func)
+    app.connect("config-inited", setup_my_func)
diff --git a/sphinx_airflow_theme/sphinx_airflow_theme/header.html 
b/sphinx_airflow_theme/sphinx_airflow_theme/header.html
index cd533ab..ad89d7b 100644
--- a/sphinx_airflow_theme/sphinx_airflow_theme/header.html
+++ b/sphinx_airflow_theme/sphinx_airflow_theme/header.html
@@ -55,14 +55,14 @@
             <div class="navbar__menu-content" id="main_navbar">
 
                 <div class="navbar__links-container">
-                    {% for link in navbar_links %}
+                    {% for link in theme_navbar_links %}
                         <a class="navbar__text-link" href="{{ link.href }}">
                             {{ link.text }}
                         </a>
                     {% endfor %}
                 </div>
 
-                {% if not hide_website_buttons %}
+                {% if not theme_hide_website_buttons %}
                 <a href="/docs/stable/start.html">
                     <button class="btn-filled 
bodytext__medium--white">Install</button>
                 </a>
@@ -117,7 +117,7 @@
                         {% endfor %}
 
                     </div>
-                    {% if not hide_website_buttons %}
+                    {% if not theme_hide_website_buttons %}
                     <a href="/install/">
 
                         <button id="" class="btn-filled 
bodytext__medium--white ">Install</button>
diff --git a/sphinx_airflow_theme/sphinx_airflow_theme/theme.conf 
b/sphinx_airflow_theme/sphinx_airflow_theme/theme.conf
index 577040e..383cee2 100644
--- a/sphinx_airflow_theme/sphinx_airflow_theme/theme.conf
+++ b/sphinx_airflow_theme/sphinx_airflow_theme/theme.conf
@@ -6,3 +6,4 @@ pygments_style = default
 [options]
 canonical_url =
 analytics_id =
+hide_website_buttons = false

Reply via email to