Conditional prefix prepending for docclasses

To remove the prefix for document classes completely is not necessary. Old
style config files can still work if there is a corresponding condition which
prepends 'sphinx' only when the configured document class is one of the Sphinx
specific classes.
This commit is contained in:
Erik Bernoth 2013-09-20 11:45:56 +02:00
parent 22d3976af2
commit 804b6a0cdb

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': 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() +