summaryrefslogtreecommitdiff
path: root/docutils
diff options
context:
space:
mode:
authorwiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2006-08-16 21:09:30 +0000
committerwiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2006-08-16 21:09:30 +0000
commit1981a0d65fe50f3667d2f9d600863785b5a1ea0c (patch)
treec4a3092d726e04beaecfb4a03a3e3aea5dd547ed /docutils
parenta92cb66ac150bd8bd3ec0060411ce793e85346ca (diff)
downloaddocutils-1981a0d65fe50f3667d2f9d600863785b5a1ea0c.tar.gz
some refactoring on macro naming convention
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk/docutils@4682 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'docutils')
-rw-r--r--docutils/writers/newlatex2e/__init__.py48
-rw-r--r--docutils/writers/newlatex2e/base.tex32
2 files changed, 41 insertions, 39 deletions
diff --git a/docutils/writers/newlatex2e/__init__.py b/docutils/writers/newlatex2e/__init__.py
index aaddc3fe8..b77624de8 100644
--- a/docutils/writers/newlatex2e/__init__.py
+++ b/docutils/writers/newlatex2e/__init__.py
@@ -107,7 +107,7 @@ class LaTeXException(Exception):
class SkipAttrParentLaTeX(LaTeXException):
"""
- Do not generate ``\Dattr`` and ``\renewcommand{\Dparent}{...}`` for this
+ Do not generate ``\DECattr`` and ``\renewcommand{\DEVparent}{...}`` for this
node.
To be raised from ``before_...`` methods.
@@ -116,7 +116,7 @@ class SkipAttrParentLaTeX(LaTeXException):
class SkipParentLaTeX(LaTeXException):
"""
- Do not generate ``\renewcommand{\DNparent}{...}`` for this node.
+ Do not generate ``\renewcommand{\DEVparent}{...}`` for this node.
To be raised from ``before_...`` methods.
"""
@@ -199,8 +199,8 @@ class LaTeXTranslator(nodes.SparseNodeVisitor):
a('')
a('% Docutils settings:')
lang = self.settings.language_code or ''
- a(r'\providecommand{\Dlanguageiso}{%s}' % lang)
- a(r'\providecommand{\Dlanguagebabel}{%s}' % self.iso639_to_babel.get(
+ a(r'\providecommand{\DEVlanguageiso}{%s}' % lang)
+ a(r'\providecommand{\DEVlanguagebabel}{%s}' % self.iso639_to_babel.get(
lang, self.iso639_to_babel.get(lang.split('_')[0], '')))
a('')
if self.user_stylesheet_path:
@@ -214,14 +214,10 @@ class LaTeXTranslator(nodes.SparseNodeVisitor):
a(r'\providecommand{\DN%s}[1]{#1}' % node_name.replace('_', ''))
a('')
a('% Auxiliary definitions:')
- a(r'\providecommand{\Dsetattr}[2]{}')
- a(r'\providecommand{\Dparent}{} % variable')
- a(r'\providecommand{\Dattr}[5]{#5}')
- a(r'\providecommand{\Dattrlen}{} % variable')
- a(r'\providecommand{\Dtitleastext}{x} % variable')
- a(r'\providecommand{\Dsinglebackref}{} % variable')
- a(r'\providecommand{\Dmultiplebackrefs}{} % variable')
- a(r'\providecommand{\Dparagraphindented}{false} % variable')
+ for attr in (r'\DEVparent \DEVattrlen \DEVtitleastext '
+ r'\DEVsinglebackref \DEVmultiplebackrefs').split():
+ a(r'\providecommand{%s}{DOCUTILSUNINITIALIZEDVARIABLE}' % attr)
+ a(r'\providecommand{\DEVparagraphindented}{false}')
a('\n\n')
unicode_map = unicode_map.unicode_map # comprehensive Unicode map
@@ -377,11 +373,11 @@ class LaTeXTranslator(nodes.SparseNodeVisitor):
return index > 0
def before_paragraph(self, node):
- self.append(r'\renewcommand{\Dparagraphindented}{%s}'
+ self.append(r'\renewcommand{\DEVparagraphindented}{%s}'
% (self.is_indented(node) and 'true' or 'false'))
def before_title(self, node):
- self.append(r'\renewcommand{\Dtitleastext}{%s}'
+ self.append(r'\renewcommand{\DEVtitleastext}{%s}'
% self.encode(node.astext()))
self.append(r'\renewcommand{\Dhassubtitle}{%s}'
% ((len(node.parent) > 2 and
@@ -492,23 +488,23 @@ class LaTeXTranslator(nodes.SparseNodeVisitor):
def before_raw(self, node):
if 'latex' in node.get('format', '').split():
# We're inserting the text in before_raw and thus outside
- # of \DN... and \Dattr in order to make grouping with
+ # of \DN... and \DECattr in order to make grouping with
# curly brackets work.
self.append(node.astext())
raise nodes.SkipChildren
def process_backlinks(self, node, type):
- self.append(r'\renewcommand{\Dsinglebackref}{}')
- self.append(r'\renewcommand{\Dmultiplebackrefs}{}')
+ self.append(r'\renewcommand{\DEVsinglebackref}{}')
+ self.append(r'\renewcommand{\DEVmultiplebackrefs}{}')
if len(node['backrefs']) > 1:
refs = []
for i in range(len(node['backrefs'])):
refs.append(r'\Dmulti%sbacklink{%s}{%s}'
% (type, node['backrefs'][i], i + 1))
- self.append(r'\renewcommand{\Dmultiplebackrefs}{(%s){ }}'
+ self.append(r'\renewcommand{\DEVmultiplebackrefs}{(%s){ }}'
% ', '.join(refs))
elif len(node['backrefs']) == 1:
- self.append(r'\renewcommand{\Dsinglebackref}{%s}'
+ self.append(r'\renewcommand{\DEVsinglebackref}{%s}'
% node['backrefs'][0])
def visit_footnote(self, node):
@@ -595,7 +591,7 @@ class LaTeXTranslator(nodes.SparseNodeVisitor):
if isinstance(node.parent.parent, nodes.thead):
node['tableheaderentry'] = 'true'
- # Don't add \renewcommand{\Dparent}{...} because there must
+ # Don't add \renewcommand{\DEVparent}{...} because there must
# not be any non-expandable commands in front of \multicolumn.
raise SkipParentLaTeX
@@ -630,7 +626,7 @@ class LaTeXTranslator(nodes.SparseNodeVisitor):
return cmp(a1, a2)
def propagate_attributes(self, node):
- # Propagate attributes using \Dattr macros.
+ # Propagate attributes using \DECattr macros.
node_name = self.node_name(node)
attlist = []
if isinstance(node, nodes.Element):
@@ -643,16 +639,16 @@ class LaTeXTranslator(nodes.SparseNodeVisitor):
pass_contents = self.pass_contents(node)
for key, value in attlist:
if isinstance(value, ListType):
- self.append(r'\renewcommand{\Dattrlen}{%s}' % len(value))
+ self.append(r'\renewcommand{\DEVattrlen}{%s}' % len(value))
for i in range(len(value)):
- self.append(r'\Dattr{%s}{%s}{%s}{%s}{' %
+ self.append(r'\DECattr{%s}{%s}{%s}{%s}{' %
(i+1, key, self.encode(value[i], attval=key),
node_name))
if not pass_contents:
self.append('}')
numatts += len(value)
else:
- self.append(r'\Dattr{}{%s}{%s}{%s}{' %
+ self.append(r'\DECattr{}{%s}{%s}{%s}{' %
(key, self.encode(unicode(value), attval=key),
node_name))
if not pass_contents:
@@ -681,7 +677,7 @@ class LaTeXTranslator(nodes.SparseNodeVisitor):
def pass_contents(self, node):
r"""
Return true if the node contents should be passed in
- parameters of \DN... and \Dattr.
+ parameters of \DN... and \DECattr.
"""
return not isinstance(node, (nodes.document, nodes.section))
@@ -710,7 +706,7 @@ class LaTeXTranslator(nodes.SparseNodeVisitor):
# attribute_deleters will be appended to self.context.
attribute_deleters = []
if not skip_parent and not isinstance(node, nodes.document):
- self.append(r'\renewcommand{\Dparent}{%s}'
+ self.append(r'\renewcommand{\DEVparent}{%s}'
% self.node_name(node.parent))
for name, value in node.attlist():
if not isinstance(value, ListType) and not ':' in name:
diff --git a/docutils/writers/newlatex2e/base.tex b/docutils/writers/newlatex2e/base.tex
index 2d3003508..480c50df8 100644
--- a/docutils/writers/newlatex2e/base.tex
+++ b/docutils/writers/newlatex2e/base.tex
@@ -7,9 +7,13 @@
% Naming conventions:
% \D...: All macros introduced by the Docutils LaTeX writer.
-% \Dname: Generic variable or function.
% \DSname: Setup function (called at the bottom of this stylesheet).
% \DNnode{contents}: Handler for Docutils document tree node `node`.
+% \DEVname: External variable. \providecommand and \renewcommand are called on
+% this by the Python module.
+% \DECname: External command. It is called by the Python module and must be
+% defined in this stylesheet.
+% \Dname: Generic variable or function.
% Having to intersperse code with \makeatletter-\makeatother pairs is very
% annoying, so we call \makeatletter at the top and \makeatother at the
@@ -156,7 +160,7 @@
\providecommand{\DSlanguage}{%
% Set up babel.
- \usepackage[\Dlanguagebabel]{babel}
+ \usepackage[\DEVlanguagebabel]{babel}
}
\providecommand{\Difdefined}[3]{\@ifundefined{#1}{#3}{#2}}
@@ -177,7 +181,7 @@
}%
}
-\providecommand{\Dattr}[5]{%
+\providecommand{\DECattr}[5]{%
% Global attribute dispatcher, called inside the document tree.
% Parameters:
% 1. Attribute number.
@@ -301,7 +305,7 @@
% ---------- End of Link Handling ----------
\providecommand{\DNparagraph}[1]{%
- \ifthenelse{\equal{\Dparagraphindented}{true}}{\indent}{\noindent}%
+ \ifthenelse{\equal{\DEVparagraphindented}{true}}{\indent}{\noindent}%
#1%
}
\providecommand{\Dformatboxtitle}[1]{{\Large\textbf{#1}}}
@@ -333,7 +337,7 @@
\providecommand{\Dbookmarksectiontitle}[1]{%
% Return text suitable for use in \section*, \subsection*, etc.,
% containing a PDF bookmark. Parameter: The title (as node tree).
- \Draisedlink{\Dpdfbookmark{\Dtitleastext}}%
+ \Draisedlink{\Dpdfbookmark{\DEVtitleastext}}%
#1%
}
\providecommand{\Dsectiontitlehook}[1]{#1}
@@ -376,10 +380,12 @@
}
\providecommand{\Dhassubtitle}{false}
\providecommand{\DNtitle}[1]{%
- \csname D\Dparent title\endcsname{#1}%
+ % Dispatch to \D<parent>title.
+ \csname D\DEVparent title\endcsname{#1}%
}
\providecommand{\DNsubtitle}[1]{%
- \csname D\Dparent subtitle\endcsname{#1}%
+ % Dispatch to \D<parent>subtitle.
+ \csname D\DEVparent subtitle\endcsname{#1}%
}
\providecommand{\DNliteralblock}[1]{%
@@ -716,7 +722,7 @@
\providecommand{\Dlineblockindentation}{2.5em}
\providecommand{\DNlineblock}[1]{%
\Dmakelistenvironment{}{%
- \ifthenelse{\equal{\Dparent}{lineblock}}{%
+ \ifthenelse{\equal{\DEVparent}{lineblock}}{%
% Parent is a line block, so indent.
\setlength{\leftmargin}{\Dlineblockindentation}%
}{%
@@ -836,23 +842,23 @@
\providecommand{\Dthislabel}{}
\providecommand{\DNlabel}[1]{%
\renewcommand{\Dthislabel}{#1}
- \ifthenelse{\not\equal{\Dsinglebackref}{}}{%
+ \ifthenelse{\not\equal{\DEVsinglebackref}{}}{%
\let\Doriginallabel=\Dthislabel%
\def\Dthislabel{%
- \Dsinglefootnotebacklink{\Dsinglebackref}{\Doriginallabel}%
+ \Dsinglefootnotebacklink{\DEVsinglebackref}{\Doriginallabel}%
}%
}{}%
- \ifthenelse{\equal{\Dparent}{footnote}}{%
+ \ifthenelse{\equal{\DEVparent}{footnote}}{%
% Footnote label.
\Dformatfootnotelabel{\Dthislabel}%
}{%
- \ifthenelse{\equal{\Dparent}{citation}}{%
+ \ifthenelse{\equal{\DEVparent}{citation}}{%
% Citation label.
\Dformatcitationlabel{\Dthislabel}%
}{}%
}%
% If there are multiple backrefs, add them now.
- \Dformatmultiplebackrefs{\Dmultiplebackrefs}%
+ \Dformatmultiplebackrefs{\DEVmultiplebackrefs}%
}
\providecommand{\Dsinglefootnotebacklink}[2]{%
% Create normal backlink of a footnote label. Parameters: