From f27950b78d22a04d8f69fccf1da0641b12346aa8 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 15 Jan 2011 11:33:45 +0100 Subject: [PATCH] #554: Add theme option ``sidebarwidth`` to the basic theme. --- CHANGES | 2 ++ doc/theming.rst | 17 +++++---- sphinx/jinja2glue.py | 7 ++++ .../basic/static/{basic.css => basic.css_t} | 2 +- sphinx/themes/basic/theme.conf | 1 + sphinx/themes/default/static/default.css_t | 4 +-- sphinx/themes/nature/static/nature.css_t | 2 +- sphinx/themes/pyramid/static/pyramid.css_t | 4 +-- .../static/{sphinxdoc.css => sphinxdoc.css_t} | 4 +-- .../{traditional.css => traditional.css_t} | 36 ++----------------- 10 files changed, 31 insertions(+), 48 deletions(-) rename sphinx/themes/basic/static/{basic.css => basic.css_t} (99%) rename sphinx/themes/sphinxdoc/static/{sphinxdoc.css => sphinxdoc.css_t} (98%) rename sphinx/themes/traditional/static/{traditional.css => traditional.css_t} (95%) diff --git a/CHANGES b/CHANGES index 02dc9618a..4c66adc9e 100644 --- a/CHANGES +++ b/CHANGES @@ -98,6 +98,8 @@ Release 1.1 (in development) * #594: :confval:`trim_doctest_flags` now also removes ```` indicators. +* #554: Add theme option ``sidebarwidth`` to the basic theme. + * C++ domain now supports array definitions. diff --git a/doc/theming.rst b/doc/theming.rst index 4892299f0..3d5c36f59 100644 --- a/doc/theming.rst +++ b/doc/theming.rst @@ -89,12 +89,15 @@ These themes are: * **basic** -- This is a basically unstyled layout used as the base for the other themes, and usable as the base for custom themes as well. The HTML - contains all important elements like sidebar and relation bar. There is one - option (which is inherited by the other themes): + contains all important elements like sidebar and relation bar. There are + these options (which are inherited by the other themes): - **nosidebar** (true or false): Don't include the sidebar. Defaults to false. + - **sidebarwidth** (an integer): Width of the sidebar in pixels. (Do not + include ``px`` in the value.) Defaults to 230 pixels. + * **default** -- This is the default theme, which looks like `the Python documentation `_. It can be customized via these options: @@ -142,7 +145,8 @@ These themes are: - **headfont** (CSS font-family): Font for headings. * **sphinxdoc** -- The theme used for this documentation. It features a sidebar - on the right side. There are currently no options beyond *nosidebar*. + on the right side. There are currently no options beyond *nosidebar* and + *sidebarwidth*. * **scrolls** -- A more lightweight theme, based on `the Jinja documentation `_. The following color options are available: @@ -176,10 +180,11 @@ These themes are: is ``justify``. * **nature** -- A greenish theme. There are currently no options beyond - *nosidebar*. + *nosidebar* and *sidebarwidth*. * **pyramid** -- A theme from the Pyramid web framework project, designed by - Blaise Laflamme. THere are currently no options beyond *nosidebar*. + Blaise Laflamme. THere are currently no options beyond *nosidebar* and + *sidebarwidth*. * **haiku** -- A theme without sidebar inspired by the `Haiku OS user guide `_. The following @@ -193,7 +198,7 @@ These themes are: **hoverlinkcolor** (CSS colors): Colors for various body elements. * **traditional** -- A theme resembling the old Python documentation. There are - currently no options beyond *nosidebar*. + currently no options beyond *nosidebar* and *sidebarwidth*. * **epub** -- A theme for the epub builder. There are currently no options. This theme tries to save visual space which is a sparse resource on ebook diff --git a/sphinx/jinja2glue.py b/sphinx/jinja2glue.py index 1c5390dc6..f9b97e3d8 100644 --- a/sphinx/jinja2glue.py +++ b/sphinx/jinja2glue.py @@ -26,6 +26,12 @@ def _tobool(val): return val.lower() in ('true', '1', 'yes', 'on') return bool(val) +def _toint(val): + try: + return int(val) + except ValueError: + return 0 + def accesskey(context, key): """Helper to output each access key only once.""" if '_accesskeys' not in context: @@ -100,6 +106,7 @@ class BuiltinTemplateLoader(TemplateBridge, BaseLoader): self.environment = SandboxedEnvironment(loader=self, extensions=extensions) self.environment.filters['tobool'] = _tobool + self.environment.filters['toint'] = _toint self.environment.globals['debug'] = contextfunction(pformat) self.environment.globals['accesskey'] = contextfunction(accesskey) if use_i18n: diff --git a/sphinx/themes/basic/static/basic.css b/sphinx/themes/basic/static/basic.css_t similarity index 99% rename from sphinx/themes/basic/static/basic.css rename to sphinx/themes/basic/static/basic.css_t index 6882a5830..cd5149620 100644 --- a/sphinx/themes/basic/static/basic.css +++ b/sphinx/themes/basic/static/basic.css_t @@ -49,7 +49,7 @@ div.sphinxsidebarwrapper { div.sphinxsidebar { float: left; - width: 230px; + width: {{ theme_sidebarwidth|toint }}px; margin-left: -100%; font-size: 90%; } diff --git a/sphinx/themes/basic/theme.conf b/sphinx/themes/basic/theme.conf index d1fe6d1f9..f7283730b 100644 --- a/sphinx/themes/basic/theme.conf +++ b/sphinx/themes/basic/theme.conf @@ -5,3 +5,4 @@ pygments_style = none [options] nosidebar = false +sidebarwidth = 230 \ No newline at end of file diff --git a/sphinx/themes/default/static/default.css_t b/sphinx/themes/default/static/default.css_t index ba20dca75..85c9436a9 100644 --- a/sphinx/themes/default/static/default.css_t +++ b/sphinx/themes/default/static/default.css_t @@ -32,7 +32,7 @@ div.documentwrapper { } div.bodywrapper { - margin: 0 0 0 230px; + margin: 0 0 0 {{ theme_sidebarwidth|toint }}px; } div.body { @@ -43,7 +43,7 @@ div.body { {%- if theme_rightsidebar|tobool %} div.bodywrapper { - margin: 0 230px 0 0; + margin: 0 {{ theme_sidebarwidth|toint }}px 0 0; } {%- endif %} diff --git a/sphinx/themes/nature/static/nature.css_t b/sphinx/themes/nature/static/nature.css_t index f9986c906..a98bd4209 100644 --- a/sphinx/themes/nature/static/nature.css_t +++ b/sphinx/themes/nature/static/nature.css_t @@ -28,7 +28,7 @@ div.documentwrapper { } div.bodywrapper { - margin: 0 0 0 230px; + margin: 0 0 0 {{ theme_sidebarwidth|toint }}px; } hr { diff --git a/sphinx/themes/pyramid/static/pyramid.css_t b/sphinx/themes/pyramid/static/pyramid.css_t index 283a96ff3..442cbec06 100644 --- a/sphinx/themes/pyramid/static/pyramid.css_t +++ b/sphinx/themes/pyramid/static/pyramid.css_t @@ -28,7 +28,7 @@ div.documentwrapper { } div.bodywrapper { - margin: 0 0 0 230px; + margin: 0 0 0 {{ theme_sidebarwidth }}px; } hr { @@ -92,7 +92,7 @@ div.related a { } div.related ul { - padding-left: 240px; + padding-left: {{ theme_sidebarwidth|toint + 10 }}px; } div.sphinxsidebar { diff --git a/sphinx/themes/sphinxdoc/static/sphinxdoc.css b/sphinx/themes/sphinxdoc/static/sphinxdoc.css_t similarity index 98% rename from sphinx/themes/sphinxdoc/static/sphinxdoc.css rename to sphinx/themes/sphinxdoc/static/sphinxdoc.css_t index 0a4280747..f535696b2 100644 --- a/sphinx/themes/sphinxdoc/static/sphinxdoc.css +++ b/sphinx/themes/sphinxdoc/static/sphinxdoc.css_t @@ -38,7 +38,7 @@ div.document { } div.bodywrapper { - margin: 0 240px 0 0; + margin: 0 {{ theme_sidebarwidth|toint + 10 }}px 0 0; border-right: 1px solid #ccc; } @@ -88,7 +88,7 @@ div.sphinxsidebarwrapper { div.sphinxsidebar { margin: 0; padding: 0.5em 15px 15px 0; - width: 210px; + width: {{ theme_sidebarwidth|toint - 20 }}px; float: right; font-size: 1em; text-align: left; diff --git a/sphinx/themes/traditional/static/traditional.css b/sphinx/themes/traditional/static/traditional.css_t similarity index 95% rename from sphinx/themes/traditional/static/traditional.css rename to sphinx/themes/traditional/static/traditional.css_t index bac58c0d7..51567255b 100644 --- a/sphinx/themes/traditional/static/traditional.css +++ b/sphinx/themes/traditional/static/traditional.css_t @@ -23,7 +23,7 @@ div.documentwrapper { } div.bodywrapper { - margin: 0 230px 0 0; + margin: 0 {{ theme_sidebarwidth }}px 0 0; } div.body { @@ -40,7 +40,7 @@ div.sphinxsidebarwrapper { div.sphinxsidebar { float: right; margin-left: -100%; - width: 230px; + width: {{ theme_sidebarwidth }}px; } div.clearer { @@ -667,38 +667,6 @@ h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt { font-style: italic; } -form.comment { - margin: 0; - padding: 10px 30px 10px 30px; - background-color: #eee; -} - -form.comment h3 { - background-color: #326591; - color: white; - margin: -10px -30px 10px -30px; - padding: 5px; - font-size: 1.4em; -} - -form.comment input, -form.comment textarea { - border: 1px solid #ccc; - padding: 2px; - font-family: sans-serif; - font-size: 13px; -} - -form.comment input[type="text"] { - width: 240px; -} - -form.comment textarea { - width: 100%; - height: 200px; - margin-bottom: 10px; -} - /* :::: PRINT :::: */ @media print { div.documentwrapper {