From adca5ad4605dedbaa92c00dd6ce24ac6e71a196a Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sun, 29 Jun 2014 22:02:39 -0400 Subject: [PATCH 1/5] reflect Bootstrap's org change See twbs/bootstrap#9899 --- sphinx_bootstrap_theme/example_module.py | 2 +- sphinx_bootstrap_theme/html_bootstrap_translator.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sphinx_bootstrap_theme/example_module.py b/sphinx_bootstrap_theme/example_module.py index 6a352d35..e7616703 100644 --- a/sphinx_bootstrap_theme/example_module.py +++ b/sphinx_bootstrap_theme/example_module.py @@ -1,5 +1,5 @@ # coding=utf-8 -"""Example Module to show of :py:mod:`sphinx.autodoc` features with **Twitter Bootstrap**. +"""Example Module to show off :py:mod:`sphinx.autodoc` features with **Bootstrap**. .. moduleauthor:: Torbjörn Klatt """ diff --git a/sphinx_bootstrap_theme/html_bootstrap_translator.py b/sphinx_bootstrap_theme/html_bootstrap_translator.py index eaede035..499cad9a 100644 --- a/sphinx_bootstrap_theme/html_bootstrap_translator.py +++ b/sphinx_bootstrap_theme/html_bootstrap_translator.py @@ -1,5 +1,5 @@ # coding=utf-8 -"""A custom Sphinx HTML Translator for *Twitter Bootstrap* layout +"""A custom Sphinx HTML Translator for *Bootstrap* layout .. moduleauthor:: Torbjörn Klatt """ @@ -73,7 +73,7 @@ class BootstrapTranslator(HTMLTranslator): This is a specialization of the default HTML Translator of the docutils package. Only a couple of functions have been overridden to produce valid HTML to be - directly styled with *Twitter Bootstrap*. + directly styled with *Bootstrap*. """ # overridden @@ -143,9 +143,9 @@ def visit_paragraph(self, node): def visit_attribution(self, node): """Attribution line (e.g. in block quotes) - With *Twitter Bootstrap* we are able to style a special attribution - paragraph (read "*footer*") at the end of block quotes with the ReST - directive ``epigraph``. + With *Bootstrap* we are able to style a special attribution paragraph + (read "*footer*") at the end of block quotes with the ReST directive + ``epigraph``. .. admonition:: Example From b8620f1eca9c60519437d4579c053753c7b56af3 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Mon, 7 Jul 2014 17:33:12 -0400 Subject: [PATCH 2/5] Correctly handle hlist node. --- .../html_bootstrap_translator.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/sphinx_bootstrap_theme/html_bootstrap_translator.py b/sphinx_bootstrap_theme/html_bootstrap_translator.py index 499cad9a..5ea6b308 100644 --- a/sphinx_bootstrap_theme/html_bootstrap_translator.py +++ b/sphinx_bootstrap_theme/html_bootstrap_translator.py @@ -68,7 +68,7 @@ def debug_print(node): class BootstrapTranslator(HTMLTranslator): - """Custom HTML Translator for a Bootstrap-ifyied Sphinx layout + """Custom HTML Translator for a Bootstrap-ified Sphinx layout This is a specialization of the default HTML Translator of the docutils package. @@ -341,6 +341,21 @@ def visit_list_item(self, node): if len(node): node[0]['classes'].append('first') + # overridden + def visit_hlist(self, node): + """A hlist. Compact version of a list. + """ + atts = {'class': 'hlist'} + self.body.append(self.starttag(node, 'div', **atts)) + + def depart_hlist(self, node): + self.body.append('') + + def visit_hlistcol(self, node): + pass + def depart_hlistcol(self, node): + pass + # overridden def visit_definition_list(self, node): """Bootstrap-ified Definition List From 3525cfb95a8760b680da4d42c3f488f2b6b6f081 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Mon, 7 Jul 2014 17:39:06 -0400 Subject: [PATCH 3/5] Revert changes to .bs-sidenav CSS. --- .../bootstrap/static/bootstrap-sphinx.css_t | 59 +++++++++---------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.css_t b/sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.css_t index 572c0f5b..0b1787eb 100644 --- a/sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.css_t +++ b/sphinx_bootstrap_theme/bootstrap/static/bootstrap-sphinx.css_t @@ -117,56 +117,55 @@ td.field-body { /* First level of nav */ .bs-sidenav { - top: 80px; -// margin-top: 30px; -// margin-bottom: 30px; -// padding-top: 10px; -// padding-bottom: 10px; -// text-shadow: 0 1px 0 #fff; -// background-color: #f7f5fa; -// border-radius: 5px; + margin-top: 30px; + margin-bottom: 30px; + padding-top: 10px; + padding-bottom: 10px; + text-shadow: 0 1px 0 #fff; + background-color: #f7f5fa; + border-radius: 5px; } /* All levels of nav */ .bs-sidenav .nav > li > a { -// display: block; -// color: #716b7a; -// padding: 5px 20px; + display: block; + color: #716b7a; + padding: 5px 20px; } .bs-sidenav .nav > li > a:hover, .bs-sidenav .nav > li > a:focus { -// text-decoration: none; -// background-color: #e5e3e9; -// border-right: 1px solid #dbd8e0; + text-decoration: none; + background-color: #e5e3e9; + border-right: 1px solid #dbd8e0; } .bs-sidenav .nav > .active > a, .bs-sidenav .nav > .active:hover > a, .bs-sidenav .nav > .active:focus > a { -// font-weight: bold; -// color: #563d7c; -// background-color: transparent; -// border-right: 1px solid #563d7c; + font-weight: bold; + color: #563d7c; + background-color: transparent; + border-right: 1px solid #563d7c; } .bs-sidenav .nav .nav > li > a { -// padding-top: 3px; -// padding-bottom: 3px; -// padding-left: 30px; -// font-size: 90%; + padding-top: 3px; + padding-bottom: 3px; + padding-left: 30px; + font-size: 90%; } .bs-sidenav .nav .nav .nav > li > a { -// padding-top: 3px; -// padding-bottom: 3px; -// padding-left: 40px; -// font-size: 90%; + padding-top: 3px; + padding-bottom: 3px; + padding-left: 40px; + font-size: 90%; } .bs-sidenav .nav .nav .nav .nav > li > a { -// padding-top: 3px; -// padding-bottom: 3px; -// padding-left: 50px; -// font-size: 90%; + padding-top: 3px; + padding-bottom: 3px; + padding-left: 50px; + font-size: 90%; } /* Show and affix the side nav when space allows it */ From 99df5f1f03a94f7169921851b875aef30e5b61fa Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Mon, 7 Jul 2014 18:10:01 -0400 Subject: [PATCH 4/5] Handle tabular_col_spec node. --- sphinx_bootstrap_theme/html_bootstrap_translator.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sphinx_bootstrap_theme/html_bootstrap_translator.py b/sphinx_bootstrap_theme/html_bootstrap_translator.py index 5ea6b308..07b3d01b 100644 --- a/sphinx_bootstrap_theme/html_bootstrap_translator.py +++ b/sphinx_bootstrap_theme/html_bootstrap_translator.py @@ -456,6 +456,12 @@ def depart_table(self, node): self.compact_p = self.context.pop() self.body.append('\n') + # LaTeX only + def visit_tabular_col_spec(self, node): + pass + def depart_tabular_col_spec(self, node): + pass + def visit_desc(self, node): self.body.append( self.starttag(node, 'div', From afc945af35544810b99ae99ed77b3d625b2df0cf Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Mon, 7 Jul 2014 18:10:14 -0400 Subject: [PATCH 5/5] Handle autosummary extension nodes. --- .../html_bootstrap_translator.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sphinx_bootstrap_theme/html_bootstrap_translator.py b/sphinx_bootstrap_theme/html_bootstrap_translator.py index 07b3d01b..07aae66a 100644 --- a/sphinx_bootstrap_theme/html_bootstrap_translator.py +++ b/sphinx_bootstrap_theme/html_bootstrap_translator.py @@ -789,3 +789,18 @@ def depart_literal(self, node): if node.parent.tagname != 'reference': self.protect_literal_text -= 1 self.body.append('') + + # autosummary extension + def visit_autosummary_table(self, node): + from sphinx.ext.autosummary import autosummary_table_visit_html + autosummary_table_visit_html(self, node) + + def depart_autosummary_table(self, node): + pass + + def visit_autosummary_toc(self, node): + from sphinx.ext.autosummary import autosummary_toc_visit_html + autosummary_toc_visit_html(self, node) + + def depart_autosummary_toc(self, node): + pass