diff options
author | Fred Drake <fdrake@acm.org> | 1998-03-04 06:33:43 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 1998-03-04 06:33:43 (GMT) |
commit | b98cd39e208c20f973874380cd05865b88a10ee6 (patch) | |
tree | 725b7d2212873e202762824d4f6eedc80ec95a88 | |
parent | 34d6f5b0be1adb3e5f1e9fcb3d18bcb0695b8826 (diff) | |
download | cpython-b98cd39e208c20f973874380cd05865b88a10ee6.zip cpython-b98cd39e208c20f973874380cd05865b88a10ee6.tar.gz cpython-b98cd39e208c20f973874380cd05865b88a10ee6.tar.bz2 |
changeit(): Added support for \deprecated{}.
Chunk.__repr__(), main(): Allow Chunk objects to get the buffer, to make the
representation contain text instead of a pair of indexes. This makes debugging
a little easier.
-rw-r--r-- | Doc/partparse.py | 29 | ||||
-rw-r--r-- | Doc/tools/partparse.py | 29 |
2 files changed, 56 insertions, 2 deletions
diff --git a/Doc/partparse.py b/Doc/partparse.py index d3b850f..33e4ad4 100644 --- a/Doc/partparse.py +++ b/Doc/partparse.py @@ -197,8 +197,14 @@ class Chunk: self.where = where self.data = data + __datatypes = [chunk_type[CSNAME], chunk_type[PLAIN], chunk_type[CSLINE]] + def __repr__(self): - return 'chunk' + `self.chtype, self.where, self.data` + if self.chtype in self.__datatypes: + data = s(self.buf, self.data) + else: + data = self.data + return 'chunk' + `self.chtype, self.where, data` # and the wrapper chunk = Chunk @@ -2142,6 +2148,26 @@ def changeit(buf, pp): i = i - 1 length = length + len(data) - 2 + elif s_buf_data == 'deprecated': + length, newi = getnextarg(length, buf, pp, i) + version = pp[i:newi][0] + print "version =", version + length, newi2 = getnextarg(length, buf, pp, newi) + action = pp[newi:newi2] + print "action =", action + del pp[i-1:newi2] + length = length - (newi2 - i) - 1 + stuff = [chunk(PLAIN, ch.where, 'Deprecated since release '), + version, + chunk(PLAIN, ch.where, '.')] + chunks = [chunk(CSNAME, ch.where, 'strong'), + chunk(GROUP, ch.where, stuff), + chunk(PLAIN, ch.where, ' ')] + action \ + + [chunk(DENDLINE, ch.where, '\n')] + i = i - 1 + pp[i:i] = chunks + length = length + len(chunks) + elif s_buf_data == "quad": ch.chtype = PLAIN ch.data = " " @@ -2341,6 +2367,7 @@ def main(): for file in args: if len(args) > 1: print '='*20, file, '='*20 buf = open(file, 'r').read() + chunk.buf = buf w, pp = parseit(buf) startchange() changeit(buf, pp) diff --git a/Doc/tools/partparse.py b/Doc/tools/partparse.py index d3b850f..33e4ad4 100644 --- a/Doc/tools/partparse.py +++ b/Doc/tools/partparse.py @@ -197,8 +197,14 @@ class Chunk: self.where = where self.data = data + __datatypes = [chunk_type[CSNAME], chunk_type[PLAIN], chunk_type[CSLINE]] + def __repr__(self): - return 'chunk' + `self.chtype, self.where, self.data` + if self.chtype in self.__datatypes: + data = s(self.buf, self.data) + else: + data = self.data + return 'chunk' + `self.chtype, self.where, data` # and the wrapper chunk = Chunk @@ -2142,6 +2148,26 @@ def changeit(buf, pp): i = i - 1 length = length + len(data) - 2 + elif s_buf_data == 'deprecated': + length, newi = getnextarg(length, buf, pp, i) + version = pp[i:newi][0] + print "version =", version + length, newi2 = getnextarg(length, buf, pp, newi) + action = pp[newi:newi2] + print "action =", action + del pp[i-1:newi2] + length = length - (newi2 - i) - 1 + stuff = [chunk(PLAIN, ch.where, 'Deprecated since release '), + version, + chunk(PLAIN, ch.where, '.')] + chunks = [chunk(CSNAME, ch.where, 'strong'), + chunk(GROUP, ch.where, stuff), + chunk(PLAIN, ch.where, ' ')] + action \ + + [chunk(DENDLINE, ch.where, '\n')] + i = i - 1 + pp[i:i] = chunks + length = length + len(chunks) + elif s_buf_data == "quad": ch.chtype = PLAIN ch.data = " " @@ -2341,6 +2367,7 @@ def main(): for file in args: if len(args) > 1: print '='*20, file, '='*20 buf = open(file, 'r').read() + chunk.buf = buf w, pp = parseit(buf) startchange() changeit(buf, pp) |