From c151b9c6c7a8a0cdf614a144195dcd1ed27a87f1 Mon Sep 17 00:00:00 2001 From: Martin Larralde Date: Mon, 30 Sep 2019 14:21:34 +0200 Subject: [PATCH 1/6] Add option to use Bootstrap panels instead of alerts for admonitions --- .../bootstrap/static/bootstrap-sphinx.js_t | 24 ++++++++++++++++++- sphinx_bootstrap_theme/bootstrap/theme.conf | 3 +++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.js_t b/sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.js_t index 25050653..4df056f9 100644 --- a/sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.js_t +++ b/sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.js_t @@ -151,13 +151,35 @@ patchTables(); // Add Note, Warning styles. (BS v2,3 compatible). - $(".admonition").addClass("alert alert-info") + {% if theme_admonition_use_panel|tobool and theme_bootstrap_version == "3" %} + $(".admonition-title") + .removeClass("admonition-title") + .addClass("panel-heading").end(); + $(".admonition") + .addClass("panel panel-info") + .removeClass("admonition") + .filter(".warning, .caution") + .removeClass("panel-info") + .addClass("panel-warning").end() + .filter(".error, .danger") + .removeClass("panel-info") + .addClass("panel-danger").end() + .each(function() { + $(this) + .children() + .not(".panel-heading") + .wrapAll("
").end(); + }); + {% else %} + $(".admonition") + .addClass("alert alert-info") .filter(".warning, .caution") .removeClass("alert-info") .addClass("alert-warning").end() .filter(".error, .danger") .removeClass("alert-info") .addClass("alert-danger alert-error").end(); + {% endif %} // Inline code styles to Bootstrap style. $("tt.docutils.literal").not(".xref").each(function (i, e) { diff --git a/sphinx_bootstrap_theme/bootstrap/theme.conf b/sphinx_bootstrap_theme/bootstrap/theme.conf index 173f694b..d488ac67 100644 --- a/sphinx_bootstrap_theme/bootstrap/theme.conf +++ b/sphinx_bootstrap_theme/bootstrap/theme.conf @@ -63,3 +63,6 @@ bootswatch_theme = # Switch Bootstrap version? # Values: "3" (default) or "2" bootstrap_version = 3 + +# Use Bootstrap panels instead of alerts for admonitions +admonition_use_panel = true From 2bfc9159d3c31cb66e34b6d9e67ee1e0760a159a Mon Sep 17 00:00:00 2001 From: Martin Larralde Date: Mon, 30 Sep 2019 14:30:07 +0200 Subject: [PATCH 2/6] Reduce vertical padding of panels in `bootstrap-sphinx.css_t` --- .../bootstrap/static/bootstrap-sphinx.css_t | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.css_t b/sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.css_t index eafb2807..7dadb7f3 100644 --- a/sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.css_t +++ b/sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.css_t @@ -57,6 +57,20 @@ height: 100%; } +{% if theme_admonition_use_panel|tobool %} + +.panel-body { + padding: 0px; + padding-right: 15px; + padding-left: 15px; +} + +.panel-heading { + font-weight: bold; +} + +{% endif %} + .page-top { top: 0px; } From 008abbb4a22ed93aac5f4a0229274cef505f6e5f Mon Sep 17 00:00:00 2001 From: Martin Larralde Date: Mon, 30 Sep 2019 14:37:21 +0200 Subject: [PATCH 3/6] Disable `admonition_use_panel` by default --- sphinx_bootstrap_theme/bootstrap/theme.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx_bootstrap_theme/bootstrap/theme.conf b/sphinx_bootstrap_theme/bootstrap/theme.conf index d488ac67..94eb8ec6 100644 --- a/sphinx_bootstrap_theme/bootstrap/theme.conf +++ b/sphinx_bootstrap_theme/bootstrap/theme.conf @@ -65,4 +65,4 @@ bootswatch_theme = bootstrap_version = 3 # Use Bootstrap panels instead of alerts for admonitions -admonition_use_panel = true +admonition_use_panel = false From 011fb890ec588760c0c5fcf7a81790f7377cd066 Mon Sep 17 00:00:00 2001 From: Martin Larralde Date: Mon, 30 Sep 2019 14:56:01 +0200 Subject: [PATCH 4/6] Avoid removing `admonition` and `admontion-title` classes in panel mode --- .../bootstrap/static/bootstrap-sphinx.css_t | 13 ++++++++++--- .../bootstrap/static/bootstrap-sphinx.js_t | 2 -- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.css_t b/sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.css_t index 7dadb7f3..5ba9b570 100644 --- a/sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.css_t +++ b/sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.css_t @@ -59,10 +59,17 @@ {% if theme_admonition_use_panel|tobool %} -.panel-body { +p.admonition-title { + margin: 0px; +} + +div.admonition { padding: 0px; - padding-right: 15px; - padding-left: 15px; +} + +.panel-body { + padding-top: 10px; + padding-bottom: 5px; } .panel-heading { diff --git a/sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.js_t b/sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.js_t index 4df056f9..af5e0fa8 100644 --- a/sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.js_t +++ b/sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.js_t @@ -153,11 +153,9 @@ // Add Note, Warning styles. (BS v2,3 compatible). {% if theme_admonition_use_panel|tobool and theme_bootstrap_version == "3" %} $(".admonition-title") - .removeClass("admonition-title") .addClass("panel-heading").end(); $(".admonition") .addClass("panel panel-info") - .removeClass("admonition") .filter(".warning, .caution") .removeClass("panel-info") .addClass("panel-warning").end() From 075acfaec09581c1190ab11fe9bc12eafbcf9770 Mon Sep 17 00:00:00 2001 From: Martin Larralde Date: Mon, 11 Nov 2019 09:11:03 +0100 Subject: [PATCH 5/6] Update `README.rst` with new `admonition_use_panel` setting --- README.rst | 4 ++++ sphinx_bootstrap_theme/bootstrap/theme.conf | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index e5973e57..e9488bab 100644 --- a/README.rst +++ b/README.rst @@ -151,6 +151,10 @@ your "conf.py" file:: # Choose Bootstrap version. # Values: "3" (default) or "2" (in quotes) 'bootstrap_version': "3", + + # Use Bootstrap3 panels instead of alerts for admonitions + # Values: "true" or "false" (default) + admonition_use_panel: false, } Note for the navigation bar title that if you don't specify a theme option of diff --git a/sphinx_bootstrap_theme/bootstrap/theme.conf b/sphinx_bootstrap_theme/bootstrap/theme.conf index 94eb8ec6..13c3a14c 100644 --- a/sphinx_bootstrap_theme/bootstrap/theme.conf +++ b/sphinx_bootstrap_theme/bootstrap/theme.conf @@ -64,5 +64,6 @@ bootswatch_theme = # Values: "3" (default) or "2" bootstrap_version = 3 -# Use Bootstrap panels instead of alerts for admonitions +# Use Bootstrap3 panels instead of alerts for admonitions +# Values: "true" or "false" (default) admonition_use_panel = false From 0b30122c1beb8a09ea82689bf2fabb4445d5b54e Mon Sep 17 00:00:00 2001 From: Martin Larralde Date: Fri, 10 Sep 2021 15:31:38 +0200 Subject: [PATCH 6/6] Remove outdated `use_2to3` configuration option in `setup.py` --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 90509cfa..a469c9ba 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,7 @@ def read_file(name): setup( name="sphinx-bootstrap-theme", version=__version__, - use_2to3=True, + #use_2to3=True, description="Sphinx Bootstrap Theme.", long_description=read_file("README"), url="http://ryan-roemer.github.com/sphinx-bootstrap-theme/README.html",