Merged in erikb85/sphinx (pull request #154)

Removing "sphinx" prefix from Latex class parsing
This commit is contained in:
Takayuki Shimizukawa 2013-09-23 22:53:10 +09:00
commit dab3f56267
3 changed files with 18 additions and 2 deletions

View File

@ -1016,11 +1016,17 @@ These options influence LaTeX output.
"sphinx" package in order to define Sphinx' custom LaTeX commands.
"howto" documents will not get appendices. Also, howtos will have a simpler
title page.
* *toctree_only*: Must be ``True`` or ``False``. If ``True``, the *startdoc*
document itself is not included in the output, only the documents
referenced by it via TOC trees. With this option, you can put extra stuff
in the master document that shows up in the HTML, but not the LaTeX output.
.. versionadded:: 1.2
In the past including your own document class required you to prepend the
document class name with the string "sphinx". This is not necessary
anymore.
.. versionadded:: 0.3
The 6th item ``toctree_only``. Tuples with 5 items are still accepted.

View File

@ -236,7 +236,7 @@ latex_elements = {
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto/manual]).
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('%(master_str)s', '%(project_fn)s.tex', u'%(project_doc_texescaped_str)s',
u'%(author_texescaped_str)s', 'manual'),

View File

@ -167,6 +167,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
'transition': '\n\n\\bigskip\\hrule{}\\bigskip\n\n',
}
# sphinx specific document classes
docclasses = ('howto', 'manual')
def __init__(self, document, builder):
nodes.NodeVisitor.__init__(self, document)
self.builder = builder
@ -179,7 +182,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.elements = self.default_elements.copy()
self.elements.update({
'wrapperclass': 'sphinx' + document.settings.docclass,
'wrapperclass': self.format_docclass(document.settings.docclass),
'papersize': papersize,
'pointsize': builder.config.latex_font_size,
# if empty, the title is set to the first section title
@ -276,6 +279,13 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.previous_spanning_column = 0
self.remember_multirow = {}
def format_docclass(self, docclass):
""" prepends prefix to sphinx document classes
"""
if docclass in self.docclasses:
docclass = 'sphinx' + docclass
return docclass
def astext(self):
return (HEADER % self.elements +
self.highlighter.get_stylesheet() +