[Zope-Checkins] CVS: Zope/lib/python/docutils/transforms - __init__.py:1.3 components.py:1.3 frontmatter.py:1.3 misc.py:1.3 parts.py:1.3 peps.py:1.3 references.py:1.3 universal.py:1.3
Andreas Jung
andreas@andreas-jung.com
Thu, 10 Jul 2003 11:50:37 -0400
Update of /cvs-repository/Zope/lib/python/docutils/transforms
In directory cvs.zope.org:/tmp/cvs-serv8556/transforms
Modified Files:
__init__.py components.py frontmatter.py misc.py parts.py
peps.py references.py universal.py
Log Message:
docutils update
=== Zope/lib/python/docutils/transforms/__init__.py 1.2 => 1.3 ===
=== Zope/lib/python/docutils/transforms/components.py 1.2 => 1.3 ===
=== Zope/lib/python/docutils/transforms/frontmatter.py 1.2 => 1.3 ===
--- Zope/lib/python/docutils/transforms/frontmatter.py:1.2 Sat Feb 1 04:26:17 2003
+++ Zope/lib/python/docutils/transforms/frontmatter.py Thu Jul 10 11:50:00 2003
@@ -105,6 +105,8 @@
default_priority = 320
def apply(self):
+ if not getattr(self.document.settings, 'doctitle_xform', 1):
+ return
if self.promote_document_title():
self.promote_document_subtitle()
@@ -229,7 +231,25 @@
default_priority = 340
+ biblio_nodes = {
+ 'author': nodes.author,
+ 'authors': nodes.authors,
+ 'organization': nodes.organization,
+ 'address': nodes.address,
+ 'contact': nodes.contact,
+ 'version': nodes.version,
+ 'revision': nodes.revision,
+ 'status': nodes.status,
+ 'date': nodes.date,
+ 'copyright': nodes.copyright,
+ 'dedication': nodes.topic,
+ 'abstract': nodes.topic}
+ """Canonical field name (lowcased) to node class name mapping for
+ bibliographic fields (field_list)."""
+
def apply(self):
+ if not getattr(self.document.settings, 'docinfo_xform', 1):
+ return
document = self.document
index = document.first_child_not_matching_class(
nodes.PreBibliographic)
@@ -252,38 +272,37 @@
for field in field_list:
try:
name = field[0][0].astext()
- normedname = utils.normalize_name(name)
+ normedname = nodes.fully_normalize_name(name)
if not (len(field) == 2 and bibliofields.has_key(normedname)
and self.check_empty_biblio_field(field, name)):
raise TransformError
- biblioclass = bibliofields[normedname]
+ canonical = bibliofields[normedname]
+ biblioclass = self.biblio_nodes[canonical]
if issubclass(biblioclass, nodes.TextElement):
if not self.check_compound_biblio_field(field, name):
raise TransformError
utils.clean_rcs_keywords(
field[1][0], self.rcs_keyword_substitutions)
docinfo.append(biblioclass('', '', *field[1][0]))
- else: # multiple body elements possible
- if issubclass(biblioclass, nodes.authors):
- self.extract_authors(field, name, docinfo)
- elif issubclass(biblioclass, nodes.topic):
- if topics[normedname]:
- field[-1] += self.document.reporter.warning(
- 'There can only be one "%s" field.' % name,
- base_node=field)
- raise TransformError
- title = nodes.title(name, labels[normedname])
- topics[normedname] = biblioclass(
- '', title, CLASS=normedname, *field[1].children)
- else:
- docinfo.append(biblioclass('', *field[1].children))
+ elif issubclass(biblioclass, nodes.authors):
+ self.extract_authors(field, name, docinfo)
+ elif issubclass(biblioclass, nodes.topic):
+ if topics[canonical]:
+ field[-1] += self.document.reporter.warning(
+ 'There can only be one "%s" field.' % name,
+ base_node=field)
+ raise TransformError
+ title = nodes.title(name, labels[canonical])
+ topics[canonical] = biblioclass(
+ '', title, CLASS=canonical, *field[1].children)
+ else:
+ docinfo.append(biblioclass('', *field[1].children))
except TransformError:
if len(field[-1]) == 1 \
and isinstance(field[-1][0], nodes.paragraph):
utils.clean_rcs_keywords(
field[-1][0], self.rcs_keyword_substitutions)
docinfo.append(field)
- continue
nodelist = []
if len(docinfo) != 0:
nodelist.append(docinfo)
=== Zope/lib/python/docutils/transforms/misc.py 1.2 => 1.3 ===
--- Zope/lib/python/docutils/transforms/misc.py:1.2 Sat Feb 1 04:26:17 2003
+++ Zope/lib/python/docutils/transforms/misc.py Thu Jul 10 11:50:00 2003
@@ -10,6 +10,7 @@
__docformat__ = 'reStructuredText'
+from docutils import nodes
from docutils.transforms import Transform, TransformError
@@ -31,3 +32,31 @@
pending = self.startnode
pending.details['callback'](pending)
pending.parent.remove(pending)
+
+
+class ClassAttribute(Transform):
+
+ default_priority = 210
+
+ def apply(self):
+ pending = self.startnode
+ class_value = pending.details['class']
+ parent = pending.parent
+ child = pending
+ while parent:
+ for index in range(parent.index(child) + 1, len(parent)):
+ element = parent[index]
+ if isinstance(element, nodes.comment):
+ continue
+ element.set_class(class_value)
+ pending.parent.remove(pending)
+ return
+ else:
+ child = parent
+ parent = parent.parent
+ error = self.document.reporter.error(
+ 'No suitable element following "%s" directive'
+ % pending.details['directive'],
+ nodes.literal_block(pending.rawsource, pending.rawsource),
+ line=pending.line)
+ pending.parent.replace(pending, error)
=== Zope/lib/python/docutils/transforms/parts.py 1.2 => 1.3 ===
--- Zope/lib/python/docutils/transforms/parts.py:1.2 Sat Feb 1 04:26:17 2003
+++ Zope/lib/python/docutils/transforms/parts.py Thu Jul 10 11:50:00 2003
@@ -73,8 +73,11 @@
def apply(self):
topic = nodes.topic(CLASS='contents')
- title = self.startnode.details['title']
- if self.startnode.details.has_key('local'):
+ details = self.startnode.details
+ if details.has_key('class'):
+ topic.set_class(details['class'])
+ title = details['title']
+ if details.has_key('local'):
startnode = self.startnode.parent
# @@@ generate an error if the startnode (directive) not at
# section/document top-level? Drag it up until it is?
@@ -89,13 +92,13 @@
topic += title
else:
name = self.language.labels['contents']
- name = utils.normalize_name(name)
+ name = nodes.fully_normalize_name(name)
if not self.document.has_name(name):
topic['name'] = name
self.document.note_implicit_target(topic)
self.toc_id = topic['id']
- if self.startnode.details.has_key('backlinks'):
- self.backlinks = self.startnode.details['backlinks']
+ if details.has_key('backlinks'):
+ self.backlinks = details['backlinks']
else:
self.backlinks = self.document.settings.toc_backlinks
contents = self.build_contents(startnode)
=== Zope/lib/python/docutils/transforms/peps.py 1.2 => 1.3 ===
=== Zope/lib/python/docutils/transforms/references.py 1.2 => 1.3 ===
--- Zope/lib/python/docutils/transforms/references.py:1.2 Sat Feb 1 04:26:17 2003
+++ Zope/lib/python/docutils/transforms/references.py Thu Jul 10 11:50:00 2003
@@ -668,11 +668,17 @@
def apply(self):
defs = self.document.substitution_defs
+ normed = self.document.substitution_names
for refname, refs in self.document.substitution_refs.items():
for ref in refs:
+ key = None
if defs.has_key(refname):
- ref.parent.replace(ref, defs[refname].get_children())
+ key = refname
else:
+ normed_name = refname.lower()
+ if normed.has_key(normed_name):
+ key = normed[normed_name]
+ if key is None:
msg = self.document.reporter.error(
'Undefined substitution referenced: "%s".'
% refname, base_node=ref)
@@ -682,6 +688,8 @@
prbid = self.document.set_id(prb)
msg.add_backref(prbid)
ref.parent.replace(ref, prb)
+ else:
+ ref.parent.replace(ref, defs[key].get_children())
self.document.substitution_refs = None # release replaced references
@@ -747,6 +755,8 @@
self.document.note_autofootnote_ref(refnode)
self.document.note_footnote_ref(refnode)
index = ref.parent.index(ref) + 1
- reflist = [nodes.Text(' '), refnode]
+ reflist = [refnode]
+ if not self.document.settings.trim_footnote_reference_space:
+ reflist.insert(0, nodes.Text(' '))
ref.parent.insert(index, reflist)
return footnote
=== Zope/lib/python/docutils/transforms/universal.py 1.2 => 1.3 ===
--- Zope/lib/python/docutils/transforms/universal.py:1.2 Sat Feb 1 04:26:17 2003
+++ Zope/lib/python/docutils/transforms/universal.py Thu Jul 10 11:50:00 2003
@@ -102,7 +102,7 @@
for msg in unfiltered:
if msg['level'] >= threshold and not msg.parent:
messages.append(msg)
- if len(messages) > 0:
+ if messages:
section = nodes.section(CLASS='system-messages')
# @@@ get this from the language module?
section += nodes.title('', 'Docutils System Messages')