mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
#4246: Limit width of text body for all themes
This commit is contained in:
parent
c892fe98f7
commit
bf29ffb284
1
AUTHORS
1
AUTHORS
@ -34,6 +34,7 @@ Other contributors, listed alphabetically, are:
|
|||||||
* Horst Gutmann -- internationalization support
|
* Horst Gutmann -- internationalization support
|
||||||
* Martin Hans -- autodoc improvements
|
* Martin Hans -- autodoc improvements
|
||||||
* Doug Hellmann -- graphviz improvements
|
* Doug Hellmann -- graphviz improvements
|
||||||
|
* Tim Hoffmann -- theme improvements
|
||||||
* Timotheus Kampik - JS theme & search enhancements
|
* Timotheus Kampik - JS theme & search enhancements
|
||||||
* Dave Kuhlman -- original LaTeX writer
|
* Dave Kuhlman -- original LaTeX writer
|
||||||
* Blaise Laflamme -- pyramid theme
|
* Blaise Laflamme -- pyramid theme
|
||||||
|
2
CHANGES
2
CHANGES
@ -13,6 +13,8 @@ Incompatible changes
|
|||||||
* #3929: apidoc: Move sphinx.apidoc to sphinx.ext.apidoc
|
* #3929: apidoc: Move sphinx.apidoc to sphinx.ext.apidoc
|
||||||
* #4226: apidoc: Generate new style makefile (make-mode)
|
* #4226: apidoc: Generate new style makefile (make-mode)
|
||||||
* #4274: sphinx-build returns 2 as an exit code on argument error
|
* #4274: sphinx-build returns 2 as an exit code on argument error
|
||||||
|
* #4246: Limit width of text body for all themes. Conifigurable via theme
|
||||||
|
options ``body_min_width`` and ``body_max_width``.
|
||||||
|
|
||||||
Deprecated
|
Deprecated
|
||||||
----------
|
----------
|
||||||
|
@ -114,8 +114,19 @@ These themes are:
|
|||||||
- **nosidebar** (true or false): Don't include the sidebar. Defaults to
|
- **nosidebar** (true or false): Don't include the sidebar. Defaults to
|
||||||
``False``.
|
``False``.
|
||||||
|
|
||||||
- **sidebarwidth** (an integer): Width of the sidebar in pixels. (Do not
|
- **sidebarwidth** (int or str): Width of the sidebar in pixels.
|
||||||
include ``px`` in the value.) Defaults to 230 pixels.
|
This can be an int, which is interpreted as pixels or a valid CSS
|
||||||
|
dimension string such as '70em' or '50%'. Defaults to 230 pixels.
|
||||||
|
|
||||||
|
- **body_min_width** (int or str): Minimal width of the document body.
|
||||||
|
This can be an int, which is interpreted as pixels or a valid CSS
|
||||||
|
dimension string such as '70em' or '50%'. Use 0 if you don't want
|
||||||
|
a width limit. Defaults may depend on the theme (often 450px).
|
||||||
|
|
||||||
|
- **body_max_width** (int or str): Maximal width of the document body.
|
||||||
|
This can be an int, which is interpreted as pixels or a valid CSS
|
||||||
|
dimension string such as '70em' or '50%'. Use 'none' if you don't
|
||||||
|
want a width limit. Defaults may depend on the theme (often 800px).
|
||||||
|
|
||||||
* **alabaster** -- `Alabaster theme`_ is a modified "Kr" Sphinx theme from @kennethreitz
|
* **alabaster** -- `Alabaster theme`_ is a modified "Kr" Sphinx theme from @kennethreitz
|
||||||
(especially as used in his Requests project), which was itself originally based on
|
(especially as used in his Requests project), which was itself originally based on
|
||||||
|
@ -45,6 +45,25 @@ def _toint(val):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def _todim(val):
|
||||||
|
# type (int or unicode) -> unicode
|
||||||
|
"""
|
||||||
|
Make val a css dimension. In particular the following transformations
|
||||||
|
are performed:
|
||||||
|
|
||||||
|
- None -> 'initial' (default CSS value)
|
||||||
|
- 0 -> '0'
|
||||||
|
- ints and string representations of ints are interpreted as pixels.
|
||||||
|
|
||||||
|
Everything else is returned unchanged.
|
||||||
|
"""
|
||||||
|
if val is None:
|
||||||
|
return 'initial'
|
||||||
|
elif str(val).isdigit():
|
||||||
|
return '0' if int(val) == 0 else '%spx' % val
|
||||||
|
return val
|
||||||
|
|
||||||
|
|
||||||
def _slice_index(values, slices):
|
def _slice_index(values, slices):
|
||||||
# type: (List, int) -> Iterator[List]
|
# type: (List, int) -> Iterator[List]
|
||||||
seq = list(values)
|
seq = list(values)
|
||||||
@ -164,6 +183,7 @@ class BuiltinTemplateLoader(TemplateBridge, BaseLoader):
|
|||||||
extensions=extensions)
|
extensions=extensions)
|
||||||
self.environment.filters['tobool'] = _tobool
|
self.environment.filters['tobool'] = _tobool
|
||||||
self.environment.filters['toint'] = _toint
|
self.environment.filters['toint'] = _toint
|
||||||
|
self.environment.filters['todim'] = _todim
|
||||||
self.environment.filters['slice_index'] = _slice_index
|
self.environment.filters['slice_index'] = _slice_index
|
||||||
self.environment.globals['debug'] = contextfunction(pformat)
|
self.environment.globals['debug'] = contextfunction(pformat)
|
||||||
self.environment.globals['accesskey'] = contextfunction(accesskey)
|
self.environment.globals['accesskey'] = contextfunction(accesskey)
|
||||||
|
@ -269,7 +269,7 @@ div.document ol {
|
|||||||
/* Sidebar */
|
/* Sidebar */
|
||||||
|
|
||||||
div.sidebar {
|
div.sidebar {
|
||||||
width: {{ theme_sidebarwidth }};
|
width: {{ theme_sidebarwidth|todim }};
|
||||||
float: right;
|
float: right;
|
||||||
font-size: .9em;
|
font-size: .9em;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ div.sphinxsidebarwrapper {
|
|||||||
|
|
||||||
div.sphinxsidebar {
|
div.sphinxsidebar {
|
||||||
float: left;
|
float: left;
|
||||||
width: {{ theme_sidebarwidth|toint }}px;
|
width: {{ theme_sidebarwidth|todim }};
|
||||||
margin-left: -100%;
|
margin-left: -100%;
|
||||||
font-size: 90%;
|
font-size: 90%;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
@ -199,6 +199,11 @@ table.modindextable td {
|
|||||||
|
|
||||||
/* -- general body styles --------------------------------------------------- */
|
/* -- general body styles --------------------------------------------------- */
|
||||||
|
|
||||||
|
div.body {
|
||||||
|
min-width: {{ theme_body_min_width|todim }};
|
||||||
|
max-width: {{ theme_body_max_width|todim }};
|
||||||
|
}
|
||||||
|
|
||||||
div.body p, div.body dd, div.body li, div.body blockquote {
|
div.body p, div.body dd, div.body li, div.body blockquote {
|
||||||
-moz-hyphens: auto;
|
-moz-hyphens: auto;
|
||||||
-ms-hyphens: auto;
|
-ms-hyphens: auto;
|
||||||
|
@ -7,4 +7,6 @@ sidebars = localtoc.html, relations.html, sourcelink.html, searchbox.html
|
|||||||
[options]
|
[options]
|
||||||
nosidebar = false
|
nosidebar = false
|
||||||
sidebarwidth = 230
|
sidebarwidth = 230
|
||||||
|
body_min_width = 450
|
||||||
|
body_max_width = 800
|
||||||
navigation_with_keys = False
|
navigation_with_keys = False
|
||||||
|
@ -32,7 +32,7 @@ div.documentwrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
div.bodywrapper {
|
div.bodywrapper {
|
||||||
margin: 0 0 0 {{ theme_sidebarwidth|toint }}px;
|
margin: 0 0 0 {{ theme_sidebarwidth|todim }};
|
||||||
}
|
}
|
||||||
|
|
||||||
div.body {
|
div.body {
|
||||||
@ -43,7 +43,7 @@ div.body {
|
|||||||
|
|
||||||
{%- if theme_rightsidebar|tobool %}
|
{%- if theme_rightsidebar|tobool %}
|
||||||
div.bodywrapper {
|
div.bodywrapper {
|
||||||
margin: 0 {{ theme_sidebarwidth|toint }}px 0 0;
|
margin: 0 {{ theme_sidebarwidth|todim }} 0 0;
|
||||||
}
|
}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ body {
|
|||||||
margin: auto;
|
margin: auto;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
font-family: "DejaVu Sans", Arial, Helvetica, sans-serif;
|
font-family: "DejaVu Sans", Arial, Helvetica, sans-serif;
|
||||||
min-width: 59em;
|
min-width: {{ theme_body_min_width|todim }};
|
||||||
max-width: 70em;
|
max-width: {{ theme_body_max_width|todim }};
|
||||||
color: {{ theme_textcolor }};
|
color: {{ theme_textcolor }};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ pygments_style = autumn
|
|||||||
|
|
||||||
[options]
|
[options]
|
||||||
full_logo = false
|
full_logo = false
|
||||||
|
body_min_width = 59em
|
||||||
|
body_max_width = 70em
|
||||||
textcolor = #333333
|
textcolor = #333333
|
||||||
headingcolor = #0c3762
|
headingcolor = #0c3762
|
||||||
linkcolor = #dc3c01
|
linkcolor = #dc3c01
|
||||||
|
@ -28,7 +28,7 @@ div.documentwrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
div.bodywrapper {
|
div.bodywrapper {
|
||||||
margin: 0 0 0 {{ theme_sidebarwidth|toint }}px;
|
margin: 0 0 0 {{ theme_sidebarwidth|todim }};
|
||||||
}
|
}
|
||||||
|
|
||||||
hr {
|
hr {
|
||||||
|
@ -28,7 +28,7 @@ div.documentwrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
div.bodywrapper {
|
div.bodywrapper {
|
||||||
margin: 0 0 0 {{ theme_sidebarwidth }}px;
|
margin: 0 0 0 {{ theme_sidebarwidth|todim }};
|
||||||
}
|
}
|
||||||
|
|
||||||
hr {
|
hr {
|
||||||
@ -92,7 +92,7 @@ div.related a {
|
|||||||
}
|
}
|
||||||
|
|
||||||
div.related ul {
|
div.related ul {
|
||||||
padding-left: {{ theme_sidebarwidth|toint + 10 }}px;
|
padding-left: calc({{ theme_sidebarwidth|todim }} + 10px);
|
||||||
}
|
}
|
||||||
|
|
||||||
div.sphinxsidebar {
|
div.sphinxsidebar {
|
||||||
|
@ -98,7 +98,8 @@ h1.heading span {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#contentwrapper {
|
#contentwrapper {
|
||||||
max-width: 680px;
|
min-width: {{ theme_body_min_width|todim }};
|
||||||
|
max-width: {{ theme_body_max_width|todim }};
|
||||||
padding: 0 18px 20px 18px;
|
padding: 0 18px 20px 18px;
|
||||||
margin: 0 auto 0 auto;
|
margin: 0 auto 0 auto;
|
||||||
border-right: 1px solid #eee;
|
border-right: 1px solid #eee;
|
||||||
|
@ -4,6 +4,8 @@ stylesheet = scrolls.css
|
|||||||
pygments_style = tango
|
pygments_style = tango
|
||||||
|
|
||||||
[options]
|
[options]
|
||||||
|
body_min_width = 0
|
||||||
|
body_max_width = 680
|
||||||
headerbordercolor = #1752b4
|
headerbordercolor = #1752b4
|
||||||
subheadlinecolor = #0d306b
|
subheadlinecolor = #0d306b
|
||||||
linkcolor = #1752b4
|
linkcolor = #1752b4
|
||||||
|
@ -38,7 +38,7 @@ div.document {
|
|||||||
}
|
}
|
||||||
|
|
||||||
div.bodywrapper {
|
div.bodywrapper {
|
||||||
margin: 0 {{ theme_sidebarwidth|toint + 10 }}px 0 0;
|
margin: 0 calc({{ theme_sidebarwidth|todim }} + 10px) 0 0;
|
||||||
border-right: 1px solid #ccc;
|
border-right: 1px solid #ccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ div.sphinxsidebarwrapper {
|
|||||||
div.sphinxsidebar {
|
div.sphinxsidebar {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0.5em 15px 15px 0;
|
padding: 0.5em 15px 15px 0;
|
||||||
width: {{ theme_sidebarwidth|toint - 20 }}px;
|
width: calc({{ theme_sidebarwidth|todim }} - 20px);
|
||||||
float: right;
|
float: right;
|
||||||
font-size: 1em;
|
font-size: 1em;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
|
@ -23,10 +23,12 @@ div.documentwrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
div.bodywrapper {
|
div.bodywrapper {
|
||||||
margin: 0 {{ theme_sidebarwidth }}px 0 0;
|
margin: 0 {{ theme_sidebarwidth|todim }} 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
div.body {
|
div.body {
|
||||||
|
min-width: {{ theme_body_min_width|todim }};
|
||||||
|
max-width: {{ theme_body_max_width|todim }};
|
||||||
background-color: white;
|
background-color: white;
|
||||||
padding: 0 20px 30px 20px;
|
padding: 0 20px 30px 20px;
|
||||||
}
|
}
|
||||||
@ -40,7 +42,7 @@ div.sphinxsidebarwrapper {
|
|||||||
div.sphinxsidebar {
|
div.sphinxsidebar {
|
||||||
float: right;
|
float: right;
|
||||||
margin-left: -100%;
|
margin-left: -100%;
|
||||||
width: {{ theme_sidebarwidth }}px;
|
width: {{ theme_sidebarwidth|todim }};
|
||||||
}
|
}
|
||||||
|
|
||||||
div.clearer {
|
div.clearer {
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
[theme]
|
[theme]
|
||||||
inherit = basic
|
inherit = basic
|
||||||
stylesheet = traditional.css
|
stylesheet = traditional.css
|
||||||
|
|
||||||
|
[options]
|
||||||
|
body_min_width = 0
|
||||||
|
body_max_width = none
|
||||||
|
Loading…
Reference in New Issue
Block a user