mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Added the `latex_docclass` config value and made the "twoside"
documentclass option overridable by "oneside".
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -1,6 +1,9 @@
|
|||||||
Release 1.0 (in development)
|
Release 1.0 (in development)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
* Added the ``latex_docclass`` config value and made the "twoside"
|
||||||
|
documentclass option overridable by "oneside".
|
||||||
|
|
||||||
* Added the ``extlinks`` extension.
|
* Added the ``extlinks`` extension.
|
||||||
|
|
||||||
* Allow searching for object names including the module name, like
|
* Allow searching for object names including the module name, like
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ latex_logo = '_static/sphinx.png'
|
|||||||
|
|
||||||
# Additional stuff for the LaTeX preamble.
|
# Additional stuff for the LaTeX preamble.
|
||||||
latex_elements = {
|
latex_elements = {
|
||||||
'fontpkg': '\\usepackage{palatino}'
|
'fontpkg': '\\usepackage{palatino}',
|
||||||
}
|
}
|
||||||
|
|
||||||
# Put TODOs into the output.
|
# Put TODOs into the output.
|
||||||
|
|||||||
@@ -660,6 +660,14 @@ These options influence LaTeX output.
|
|||||||
``'shorthandoff'``
|
``'shorthandoff'``
|
||||||
``'printmodindex'``
|
``'printmodindex'``
|
||||||
|
|
||||||
|
.. confval:: latex_docclass
|
||||||
|
|
||||||
|
A dictionary mapping ``'howto'`` and ``'manual'`` to names of real document
|
||||||
|
classes that will be used as the base for the two Sphinx classes. Default
|
||||||
|
is to use ``'article'`` for ``'howto'`` and ``'report'`` for ``'manual'``.
|
||||||
|
|
||||||
|
.. versionadded:: 1.0
|
||||||
|
|
||||||
.. confval:: latex_additional_files
|
.. confval:: latex_additional_files
|
||||||
|
|
||||||
A list of file names, relative to the configuration directory, to copy to the
|
A list of file names, relative to the configuration directory, to copy to the
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ class Config(object):
|
|||||||
latex_font_size = ('10pt', None),
|
latex_font_size = ('10pt', None),
|
||||||
latex_elements = ({}, None),
|
latex_elements = ({}, None),
|
||||||
latex_additional_files = ([], None),
|
latex_additional_files = ([], None),
|
||||||
|
latex_docclass = ({}, None),
|
||||||
# now deprecated - use latex_elements
|
# now deprecated - use latex_elements
|
||||||
latex_preamble = ('', None),
|
latex_preamble = ('', None),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,14 +1,25 @@
|
|||||||
%
|
%
|
||||||
% howto.cls for Sphinx
|
% sphinxhowto.cls for Sphinx (http://sphinx.pocoo.org/)
|
||||||
%
|
%
|
||||||
|
|
||||||
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
|
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
|
||||||
\ProvidesClass{howto}[2008/10/18 Document class (Sphinx HOWTO)]
|
\ProvidesClass{sphinxhowto}[2009/06/02 Document class (Sphinx HOWTO)]
|
||||||
|
|
||||||
% Pass all given class options to the parent class.
|
% 'oneside' option overriding the 'twoside' default
|
||||||
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
|
\newif\if@oneside
|
||||||
|
\DeclareOption{oneside}{\@onesidetrue}
|
||||||
|
% Pass remaining document options to the parent class.
|
||||||
|
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\sphinxdocclass}}
|
||||||
\ProcessOptions\relax
|
\ProcessOptions\relax
|
||||||
\LoadClass[twoside]{article}
|
|
||||||
|
% Default to two-side document
|
||||||
|
\if@oneside
|
||||||
|
% nothing to do (oneside is the default)
|
||||||
|
\else
|
||||||
|
\PassOptionsToClass{twoside}{\sphinxdocclass}
|
||||||
|
\fi
|
||||||
|
|
||||||
|
\LoadClass{\sphinxdocclass}
|
||||||
|
|
||||||
% Set some sane defaults for section numbering depth and TOC depth. You can
|
% Set some sane defaults for section numbering depth and TOC depth. You can
|
||||||
% reset these counters in your preamble.
|
% reset these counters in your preamble.
|
||||||
@@ -1,14 +1,28 @@
|
|||||||
%
|
%
|
||||||
% manual.cls for Sphinx
|
% sphinxmanual.cls for Sphinx (http://sphinx.pocoo.org/)
|
||||||
%
|
%
|
||||||
|
|
||||||
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
|
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
|
||||||
\ProvidesClass{manual}[2008/10/18 Document class (Sphinx manual)]
|
\ProvidesClass{sphinxmanual}[2009/06/02 Document class (Sphinx manual)]
|
||||||
|
|
||||||
% Pass all given class options to the parent class.
|
% chapters starting at odd pages (overridden by 'openany' document option)
|
||||||
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
|
\PassOptionsToClass{openright}{\sphinxdocclass}
|
||||||
|
|
||||||
|
% 'oneside' option overriding the 'twoside' default
|
||||||
|
\newif\if@oneside
|
||||||
|
\DeclareOption{oneside}{\@onesidetrue}
|
||||||
|
% Pass remaining document options to the parent class.
|
||||||
|
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\sphinxdocclass}}
|
||||||
\ProcessOptions\relax
|
\ProcessOptions\relax
|
||||||
\LoadClass[twoside,openright]{report}
|
|
||||||
|
% Defaults two-side document
|
||||||
|
\if@oneside
|
||||||
|
% nothing to do (oneside is the default)
|
||||||
|
\else
|
||||||
|
\PassOptionsToClass{twoside}{\sphinxdocclass}
|
||||||
|
\fi
|
||||||
|
|
||||||
|
\LoadClass{\sphinxdocclass}
|
||||||
|
|
||||||
% Set some sane defaults for section numbering depth and TOC depth. You can
|
% Set some sane defaults for section numbering depth and TOC depth. You can
|
||||||
% reset these counters in your preamble.
|
% reset these counters in your preamble.
|
||||||
@@ -28,7 +28,8 @@ from sphinx.util.texescape import tex_escape_map
|
|||||||
from sphinx.util.smartypants import educateQuotesLatex
|
from sphinx.util.smartypants import educateQuotesLatex
|
||||||
|
|
||||||
HEADER = r'''%% Generated by Sphinx.
|
HEADER = r'''%% Generated by Sphinx.
|
||||||
\documentclass[%(papersize)s,%(pointsize)s%(classoptions)s]{%(docclass)s}
|
\def\sphinxdocclass{%(docclass)s}
|
||||||
|
\documentclass[%(papersize)s,%(pointsize)s%(classoptions)s]{%(wrapperclass)s}
|
||||||
%(inputenc)s
|
%(inputenc)s
|
||||||
%(utf8extra)s
|
%(utf8extra)s
|
||||||
%(fontenc)s
|
%(fontenc)s
|
||||||
@@ -135,7 +136,6 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
ignore_missing_images = False
|
ignore_missing_images = False
|
||||||
|
|
||||||
default_elements = {
|
default_elements = {
|
||||||
'docclass': 'manual',
|
|
||||||
'papersize': 'letterpaper',
|
'papersize': 'letterpaper',
|
||||||
'pointsize': '10pt',
|
'pointsize': '10pt',
|
||||||
'classoptions': '',
|
'classoptions': '',
|
||||||
@@ -175,7 +175,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
|
|
||||||
self.elements = self.default_elements.copy()
|
self.elements = self.default_elements.copy()
|
||||||
self.elements.update({
|
self.elements.update({
|
||||||
'docclass': document.settings.docclass,
|
'wrapperclass': 'sphinx' + document.settings.docclass,
|
||||||
'papersize': papersize,
|
'papersize': papersize,
|
||||||
'pointsize': builder.config.latex_font_size,
|
'pointsize': builder.config.latex_font_size,
|
||||||
# if empty, the title is set to the first section title
|
# if empty, the title is set to the first section title
|
||||||
@@ -189,6 +189,11 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
'modindexname': _('Module Index'),
|
'modindexname': _('Module Index'),
|
||||||
'indexname': _('Index'),
|
'indexname': _('Index'),
|
||||||
})
|
})
|
||||||
|
if document.settings.docclass == 'howto':
|
||||||
|
docclass = builder.config.latex_docclass.get('howto', 'article')
|
||||||
|
else:
|
||||||
|
docclass = builder.config.latex_docclass.get('manual', 'report')
|
||||||
|
self.elements['docclass'] = docclass
|
||||||
if builder.config.latex_logo:
|
if builder.config.latex_logo:
|
||||||
self.elements['logo'] = '\\includegraphics{%s}\\par' % \
|
self.elements['logo'] = '\\includegraphics{%s}\\par' % \
|
||||||
path.basename(builder.config.latex_logo)
|
path.basename(builder.config.latex_logo)
|
||||||
|
|||||||
Reference in New Issue
Block a user