[Docstring-checkins] CVS: dps/dps nodes.py,1.38,1.39
Status: Pre-Alpha
Brought to you by:
goodger
|
From: David G. <go...@us...> - 2002-04-13 17:08:15
|
Update of /cvsroot/docstring/dps/dps
In directory usw-pr-cvs1:/tmp/cvs-serv15882/dps/dps
Modified Files:
nodes.py
Log Message:
Reworked references.
Index: nodes.py
===================================================================
RCS file: /cvsroot/docstring/dps/dps/nodes.py,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** nodes.py 28 Mar 2002 04:46:24 -0000 1.38
--- nodes.py 13 Apr 2002 17:08:10 -0000 1.39
***************
*** 24,28 ****
from types import IntType, SliceType, StringType, TupleType, ListType
from UserString import MutableString
! from dps import utils
import dps
--- 24,28 ----
from types import IntType, SliceType, StringType, TupleType, ListType
from UserString import MutableString
! import utils
import dps
***************
*** 244,248 ****
def starttag(self):
parts = [self.tagname]
! for name, value in self.attlist:
if value is None: # boolean attribute
parts.append(name)
--- 244,248 ----
def starttag(self):
parts = [self.tagname]
! for name, value in self.attlist():
if value is None: # boolean attribute
parts.append(name)
***************
*** 336,339 ****
--- 336,343 ----
return self.attributes.has_key(attr)
+ def delattr(self, attr):
+ if self.attributes.has_key(attr):
+ del self.attributes[attr]
+
def setdefault(self, key, failobj=None):
return self.attributes.setdefault(key, failobj)
***************
*** 447,451 ****
# ========
! class ToBeResolved:
resolved = 0
--- 451,455 ----
# ========
! class Resolvable:
resolved = 0
***************
*** 454,459 ****
class BackLinkable:
! def add_refid(self, refid):
! self.setdefault('refid', []).append(refid)
--- 458,463 ----
class BackLinkable:
! def add_backref(self, refid):
! self.setdefault('backrefs', []).append(refid)
***************
*** 494,502 ****
class Inline: pass
- class Referential(ToBeResolved):
! refnode = None
! """Resolved reference to a node."""
--- 498,509 ----
class Inline: pass
+ class Referential(Resolvable): pass
+ #refnode = None
+ #"""Resolved reference to a node."""
! class Targetable(Resolvable):
!
! referenced = 0
***************
*** 523,531 ****
nodes."""
! self.external_targets = {}
! """Mapping of target names to external target nodes."""
! self.indirect_targets = {}
! """Mapping of target names to indirect target nodes."""
self.substitution_defs = {}
--- 530,541 ----
nodes."""
! self.external_targets = []
! """List of external target nodes."""
! self.internal_targets = []
! """List of internal target nodes."""
!
! self.indirect_targets = []
! """List of indirect target nodes."""
self.substitution_defs = {}
***************
*** 533,537 ****
self.refnames = {}
! """Mapping of reference names to lists of reference nodes."""
self.nameids = {}
--- 543,550 ----
self.refnames = {}
! """Mapping of names to lists of referencing nodes."""
!
! self.refids = {}
! """Mapping of ids to lists of referencing nodes."""
self.nameids = {}
***************
*** 569,578 ****
"""List of symbol footnote_reference nodes."""
self.pending = []
"""List of pending elements @@@."""
- self.anonymous_start = 1
- """Initial anonymous hyperlink number."""
-
self.autofootnote_start = 1
"""Initial auto-numbered footnote number."""
--- 582,594 ----
"""List of symbol footnote_reference nodes."""
+ self.footnotes = []
+ """List of manually-numbered footnote nodes."""
+
+ self.citations = []
+ """List of citation nodes."""
+
self.pending = []
"""List of pending elements @@@."""
self.autofootnote_start = 1
"""Initial auto-numbered footnote number."""
***************
*** 598,602 ****
id = node['id']
if self.ids.has_key(id) and self.ids[id] is not node:
! msg = self.reporter.error('Duplicate ID: "%s".' % id)
msgnode += msg
else:
--- 614,618 ----
id = node['id']
if self.ids.has_key(id) and self.ids[id] is not node:
! msg = self.reporter.severe('Duplicate ID: "%s".' % id)
msgnode += msg
else:
***************
*** 611,642 ****
self.ids[id] = node
if node.has_key('name'):
! name = node['name']
! self.nameids[name] = id
return id
! def note_implicit_target(self, targetnode, msgnode=None):
if msgnode == None:
msgnode = self.messages
! id = self.set_id(targetnode, msgnode)
! name = targetnode['name']
if self.explicit_targets.has_key(name) \
or self.implicit_targets.has_key(name):
msg = self.reporter.info(
! 'Duplicate implicit target name: "%s".' % name, refid=id)
msgnode += msg
self.clear_target_names(name, self.implicit_targets)
! del targetnode['name']
! targetnode['dupname'] = name
! self.implicit_targets[name] = targetnode
! def note_explicit_target(self, targetnode, msgnode=None):
if msgnode == None:
msgnode = self.messages
! id = self.set_id(targetnode, msgnode)
! name = targetnode['name']
if self.explicit_targets.has_key(name):
level = 2
! if targetnode.has_key('refuri'): # external target, dups OK
! refuri = targetnode['refuri']
t = self.explicit_targets[name]
if t.has_key('name') and t.has_key('refuri') \
--- 627,659 ----
self.ids[id] = node
if node.has_key('name'):
! self.nameids[node['name']] = id
return id
! def note_implicit_target(self, target, msgnode=None):
if msgnode == None:
msgnode = self.messages
! id = self.set_id(target, msgnode)
! name = target['name']
if self.explicit_targets.has_key(name) \
or self.implicit_targets.has_key(name):
msg = self.reporter.info(
! 'Duplicate implicit target name: "%s".' % name, backrefs=[id])
msgnode += msg
self.clear_target_names(name, self.implicit_targets)
! del target['name']
! target['dupname'] = name
! self.implicit_targets[name] = None
! else:
! self.implicit_targets[name] = target
! def note_explicit_target(self, target, msgnode=None):
if msgnode == None:
msgnode = self.messages
! id = self.set_id(target, msgnode)
! name = target['name']
if self.explicit_targets.has_key(name):
level = 2
! if target.has_key('refuri'): # external target, dups OK
! refuri = target['refuri']
t = self.explicit_targets[name]
if t.has_key('name') and t.has_key('refuri') \
***************
*** 645,661 ****
msg = self.reporter.system_message(
level, 'Duplicate explicit target name: "%s".' % name,
! refid=id)
msgnode += msg
self.clear_target_names(name, self.explicit_targets,
self.implicit_targets)
if level > 1:
! del targetnode['name']
! targetnode['dupname'] = name
elif self.implicit_targets.has_key(name):
msg = self.reporter.info(
! 'Duplicate implicit target name: "%s".' % name, refid=id)
msgnode += msg
self.clear_target_names(name, self.implicit_targets)
! self.explicit_targets[name] = targetnode
def clear_target_names(self, name, *targetdicts):
--- 662,678 ----
msg = self.reporter.system_message(
level, 'Duplicate explicit target name: "%s".' % name,
! backrefs=[id])
msgnode += msg
self.clear_target_names(name, self.explicit_targets,
self.implicit_targets)
if level > 1:
! del target['name']
! target['dupname'] = name
elif self.implicit_targets.has_key(name):
msg = self.reporter.info(
! 'Duplicate implicit target name: "%s".' % name, backrefs=[id])
msgnode += msg
self.clear_target_names(name, self.implicit_targets)
! self.explicit_targets[name] = target
def clear_target_names(self, name, *targetdicts):
***************
*** 671,709 ****
self.refnames.setdefault(node['refname'], []).append(node)
! def note_external_target(self, targetnode):
! self.external_targets[targetnode['name']] = targetnode
! def note_indirect_target(self, targetnode):
! self.indirect_targets[targetnode['name']] = targetnode
! self.note_refname(targetnode)
! def note_anonymous_target(self, targetnode):
! self.anonymous_targets.append(targetnode)
! def note_anonymous_ref(self, refnode):
! self.anonymous_refs.append(refnode)
def note_autofootnote(self, footnote):
self.autofootnotes.append(footnote)
! def note_autofootnote_ref(self, refnode):
! self.autofootnote_refs.append(refnode)
def note_symbol_footnote(self, footnote):
self.symbol_footnotes.append(footnote)
! def note_symbol_footnote_ref(self, refnode):
! self.symbol_footnote_refs.append(refnode)
! def note_footnote_ref(self, refnode):
! self.footnote_refs.setdefault(refnode['refname'], []).append(refnode)
! self.note_refname(refnode)
! def note_citation_ref(self, refnode):
! self.citation_refs.setdefault(refnode['refname'], []).append(refnode)
! self.note_refname(refnode)
! def note_substitution_def(self, substitutiondefnode, msgnode=None):
! name = substitutiondefnode['name']
if self.substitution_defs.has_key(name):
msg = self.reporter.error(
--- 688,748 ----
self.refnames.setdefault(node['refname'], []).append(node)
! def note_refid(self, node):
! self.refids.setdefault(node['refid'], []).append(node)
! def note_external_target(self, target):
! self.external_targets.append(target)
! def note_internal_target(self, target):
! self.internal_targets.append(target)
! def note_indirect_target(self, target):
! self.indirect_targets.append(target)
! if target.has_key('name'):
! self.note_refname(target)
!
! def note_anonymous_target(self, target):
! self.set_id(target)
! self.anonymous_targets.append(target)
!
! def note_anonymous_ref(self, ref):
! self.anonymous_refs.append(ref)
def note_autofootnote(self, footnote):
+ self.set_id(footnote)
self.autofootnotes.append(footnote)
! def note_autofootnote_ref(self, ref):
! self.set_id(ref)
! self.autofootnote_refs.append(ref)
def note_symbol_footnote(self, footnote):
+ self.set_id(footnote)
self.symbol_footnotes.append(footnote)
! def note_symbol_footnote_ref(self, ref):
! self.set_id(ref)
! self.symbol_footnote_refs.append(ref)
! def note_footnote(self, footnote):
! self.set_id(footnote)
! self.footnotes.append(footnote)
! def note_footnote_ref(self, ref):
! self.set_id(ref)
! self.footnote_refs.setdefault(ref['refname'], []).append(ref)
! self.note_refname(ref)
! def note_citation(self, citation):
! self.set_id(citation)
! self.citations.append(citation)
!
! def note_citation_ref(self, ref):
! self.set_id(ref)
! self.citation_refs.setdefault(ref['refname'], []).append(ref)
! self.note_refname(ref)
!
! def note_substitution_def(self, subdef, msgnode=None):
! name = subdef['name']
if self.substitution_defs.has_key(name):
msg = self.reporter.error(
***************
*** 716,727 ****
del oldnode['name']
# keep only the last definition
! self.substitution_defs[name] = substitutiondefnode
! def note_substitution_ref(self, subrefnode):
self.substitution_refs.setdefault(
! subrefnode['refname'], []).append(subrefnode)
! def note_pending(self, pendingnode):
! self.pending.append(pendingnode)
--- 755,766 ----
del oldnode['name']
# keep only the last definition
! self.substitution_defs[name] = subdef
! def note_substitution_ref(self, subref):
self.substitution_refs.setdefault(
! subref['refname'], []).append(subref)
! def note_pending(self, pending):
! self.pending.append(pending)
***************
*** 835,839 ****
class comment(Special, PreBibliographic, TextElement): pass
class substitution_definition(Special, TextElement): pass
! class target(Special, Inline, TextElement, ToBeResolved): pass
class footnote(General, Element, BackLinkable): pass
class citation(General, Element, BackLinkable): pass
--- 874,878 ----
class comment(Special, PreBibliographic, TextElement): pass
class substitution_definition(Special, TextElement): pass
! class target(Special, Inline, TextElement, Targetable): pass
class footnote(General, Element, BackLinkable): pass
class citation(General, Element, BackLinkable): pass
***************
*** 907,914 ****
internals = [
'.. internal attributes:',
! ' pending.transform: %s.%s' % (self.transform.__module__,
self.transform.__name__),
! ' pending.stage: %r' % self.stage,
! ' pending.details:']
details = self.details.items()
details.sort()
--- 946,953 ----
internals = [
'.. internal attributes:',
! ' .transform: %s.%s' % (self.transform.__module__,
self.transform.__name__),
! ' .stage: %r' % self.stage,
! ' .details:']
details = self.details.items()
details.sort()
***************
*** 945,949 ****
class footnote_reference(Inline, Referential, TextElement): pass
class citation_reference(Inline, Referential, TextElement): pass
! class substitution_reference(Inline, Referential, TextElement): pass
class image(General, Inline, TextElement): pass
class problematic(Inline, TextElement): pass
--- 984,988 ----
class footnote_reference(Inline, Referential, TextElement): pass
class citation_reference(Inline, Referential, TextElement): pass
! class substitution_reference(Inline, TextElement): pass
class image(General, Inline, TextElement): pass
class problematic(Inline, TextElement): pass
|