From 3540ea721d28056f6db853ee31d588a2330a269f Mon Sep 17 00:00:00 2001 From: Bernard Knaepen Date: Sun, 1 Nov 2020 17:55:13 +0100 Subject: [PATCH 1/6] Option for download button --- docs/conf.py | 3 ++- sphinx_book_theme/__init__.py | 1 + sphinx_book_theme/topbar/download.html | 4 ++-- src/jinja/theme.conf.j2 | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 61165bab..46c282b2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -96,7 +96,8 @@ }, "use_edit_page_button": True, "use_issues_button": True, - "use_repository_button": True + "use_repository_button": True, + "use_download_button": True # For testing # "home_page_in_toc": True, # "single_page": True, diff --git a/sphinx_book_theme/__init__.py b/sphinx_book_theme/__init__.py index 1cfcd78f..b94e390a 100644 --- a/sphinx_book_theme/__init__.py +++ b/sphinx_book_theme/__init__.py @@ -316,6 +316,7 @@ def add_header_level_recursive(ul, level): "theme_use_edit_page_button", "theme_use_repository_button", "theme_use_issues_button", + "theme_use_download_button", ] for key in btns: if key in context: diff --git a/sphinx_book_theme/topbar/download.html b/sphinx_book_theme/topbar/download.html index d2c3cc79..2c78bee8 100644 --- a/sphinx_book_theme/topbar/download.html +++ b/sphinx_book_theme/topbar/download.html @@ -1,8 +1,8 @@ +{% if page_source_suffix and theme_use_download_button %} +{% endif %} diff --git a/src/jinja/theme.conf.j2 b/src/jinja/theme.conf.j2 index 9d2b9cf6..c245ff3b 100644 --- a/src/jinja/theme.conf.j2 +++ b/src/jinja/theme.conf.j2 @@ -17,6 +17,7 @@ navbar_footer_text = extra_navbar = Theme by the Executable Book Project extra_footer = use_issues_button = False +use_download_button = False use_repository_button = False theme_dev_mode = False show_navbar_depth = 1 From 9495db4965f3a93238405c3b2a24909123f69fef Mon Sep 17 00:00:00 2001 From: Bernard Knaepen Date: Sun, 1 Nov 2020 18:08:01 +0100 Subject: [PATCH 2/6] For tests --- sphinx_book_theme/theme.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/sphinx_book_theme/theme.conf b/sphinx_book_theme/theme.conf index ac753b55..e01bd846 100644 --- a/sphinx_book_theme/theme.conf +++ b/sphinx_book_theme/theme.conf @@ -17,6 +17,7 @@ navbar_footer_text = extra_navbar = Theme by the Executable Book Project extra_footer = use_issues_button = False +use_download_button = False use_repository_button = False theme_dev_mode = False show_navbar_depth = 1 From a67bec17b865fc07c23149aef71cc4ecfccd5a97 Mon Sep 17 00:00:00 2001 From: Bernard Knaepen Date: Sun, 1 Nov 2020 22:21:45 +0100 Subject: [PATCH 3/6] For tests --- sphinx_book_theme/theme.conf | 2 +- src/jinja/theme.conf.j2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sphinx_book_theme/theme.conf b/sphinx_book_theme/theme.conf index e01bd846..340f527b 100644 --- a/sphinx_book_theme/theme.conf +++ b/sphinx_book_theme/theme.conf @@ -18,6 +18,6 @@ extra_navbar = Theme by the Executable Boo extra_footer = use_issues_button = False use_download_button = False -use_repository_button = False +use_repository_button = True theme_dev_mode = False show_navbar_depth = 1 diff --git a/src/jinja/theme.conf.j2 b/src/jinja/theme.conf.j2 index c245ff3b..a317fad5 100644 --- a/src/jinja/theme.conf.j2 +++ b/src/jinja/theme.conf.j2 @@ -18,6 +18,6 @@ extra_navbar = Theme by the Executable Boo extra_footer = use_issues_button = False use_download_button = False -use_repository_button = False +use_repository_button = True theme_dev_mode = False show_navbar_depth = 1 From acda1af56bf6679a079aa297f4ede684092f98d9 Mon Sep 17 00:00:00 2001 From: Bernard Knaepen Date: Sun, 1 Nov 2020 22:57:43 +0100 Subject: [PATCH 4/6] Proper defaults --- sphinx_book_theme/theme.conf | 4 ++-- src/jinja/theme.conf.j2 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sphinx_book_theme/theme.conf b/sphinx_book_theme/theme.conf index 340f527b..e9d89d4e 100644 --- a/sphinx_book_theme/theme.conf +++ b/sphinx_book_theme/theme.conf @@ -17,7 +17,7 @@ navbar_footer_text = extra_navbar = Theme by the Executable Book Project extra_footer = use_issues_button = False -use_download_button = False -use_repository_button = True +use_download_button = True +use_repository_button = False theme_dev_mode = False show_navbar_depth = 1 diff --git a/src/jinja/theme.conf.j2 b/src/jinja/theme.conf.j2 index a317fad5..6060575a 100644 --- a/src/jinja/theme.conf.j2 +++ b/src/jinja/theme.conf.j2 @@ -17,7 +17,7 @@ navbar_footer_text = extra_navbar = Theme by the Executable Book Project extra_footer = use_issues_button = False -use_download_button = False -use_repository_button = True +use_download_button = True +use_repository_button = False theme_dev_mode = False show_navbar_depth = 1 From 1791a111c4304276b413bc46a9ae2e0eea257c99 Mon Sep 17 00:00:00 2001 From: Bernard Knaepen Date: Sun, 1 Nov 2020 23:24:51 +0100 Subject: [PATCH 5/6] Documentation for Download page button option. --- docs/configure.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/configure.md b/docs/configure.md index ac395f4a..ba6589c0 100644 --- a/docs/configure.md +++ b/docs/configure.md @@ -87,6 +87,17 @@ html_theme_options = { ... } ``` +## Download page button + +You can add a button allowing users to download the currently viewed page in several formats: raw, pdf or ipynb if available. To include this button, use the following configuration: + +```python +html_theme_options = { + ... + "use_download_button": True, + ... +} +``` ## Use a single-page version of this theme From 7d714a31731cef3bc5e10ad398941e530c512d57 Mon Sep 17 00:00:00 2001 From: Bernard Knaepen Date: Sun, 1 Nov 2020 23:30:51 +0100 Subject: [PATCH 6/6] Trailing whitespace --- docs/configure.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configure.md b/docs/configure.md index ba6589c0..39c0630c 100644 --- a/docs/configure.md +++ b/docs/configure.md @@ -89,7 +89,7 @@ html_theme_options = { ``` ## Download page button -You can add a button allowing users to download the currently viewed page in several formats: raw, pdf or ipynb if available. To include this button, use the following configuration: +You can add a button allowing users to download the currently viewed page in several formats: raw, pdf or ipynb if available. To include this button, use the following configuration: ```python html_theme_options = {