Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9c7c6be

Browse files
committed
Clean up name->name conversion a little, *make sure it happens in all the
right places*!
1 parent 414f261 commit 9c7c6be

2 files changed

Lines changed: 36 additions & 24 deletions

File tree

Doc/partparse.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,18 @@ def startchange():
10131013
# same for enumerate
10141014
enumeratesymbols = ['1', 'A', 'a']
10151015

1016+
d = {}
1017+
for name in ('url', 'module', 'function', 'cfunction',
1018+
'keyword', 'method', 'exception', 'constant',
1019+
'email', 'class', 'member', 'cdata', 'ctype',
1020+
'member'):
1021+
d[name] = 'code'
1022+
d['program'] = 'strong'
1023+
d['sectcode'] = 'code'
1024+
convertible_csname = d.has_key
1025+
conversion = d.get
1026+
del d, name
1027+
10161028
##
10171029
## \begin{ {func,data,exc}desc }{name}...
10181030
## the resulting texi-code is dependent on the contents of indexsubitem
@@ -1391,6 +1403,8 @@ def changeit(buf, pp):
13911403
if pp[i].chtype != chunk_type[PLAIN]:
13921404
raise error, 'Sorry, expected plain text argument'
13931405
hist.itemargmacro = s(buf, pp[i].data)
1406+
if convertible_csname(hist.itemargmacro):
1407+
hist.itemargmacro = conversion(hist.itemargmacro)
13941408
del pp[i:newi]
13951409
length = length - (newi-i)
13961410

@@ -1593,9 +1607,6 @@ def changeit(buf, pp):
15931607
ch.chtype = chunk_type[PLAIN]
15941608
ch.data = release_version
15951609

1596-
elif s_buf_data == 'program':
1597-
ch.data = "strong"
1598-
15991610
elif s_buf_data == 'item':
16001611
ch.chtype = chunk_type[CSLINE]
16011612
length, newi = getoptarg(length, buf, pp, i)
@@ -1641,10 +1652,10 @@ def changeit(buf, pp):
16411652
if command in regindices:
16421653

16431654
arg = [chunk(CSNAME, ch.where, 't'),
1644-
chunk(GROUP, ch.where, arg)]
1655+
chunk(GROUP, ch.where, arg)]
16451656
else:
16461657
cat_arg = [chunk(CSNAME, ch.where, 'r'),
1647-
chunk(GROUP, ch.where, cat_arg)]
1658+
chunk(GROUP, ch.where, cat_arg)]
16481659

16491660
ingroupch = arg + \
16501661
[chunk(PLAIN, ch.where, ' ')] + \
@@ -1868,9 +1879,6 @@ def changeit(buf, pp):
18681879
pp.insert(i, chunk(GROUP, ch.where, ingroupch))
18691880
length, i = length+1, i+1
18701881

1871-
elif s_buf_data == 'sectcode':
1872-
ch.data = 'code'
1873-
18741882
elif s_buf_data in ('stmodindex', 'refstmodindex'):
18751883
ch.chtype = chunk_type[CSLINE]
18761884
# use the program index as module index
@@ -2086,10 +2094,8 @@ def changeit(buf, pp):
20862094
elif s_buf_data in ('noindent', 'indexsubitem', 'footnote'):
20872095
pass
20882096

2089-
elif s_buf_data in ('url', 'module', 'function', 'cfunction',
2090-
'keyword', 'method', 'exception', 'constant',
2091-
'email', 'class', 'member', 'cdata', 'ctype'):
2092-
ch.data = "code"
2097+
elif convertible_csname(s_buf_data):
2098+
ch.data = conversion(s_buf_data)
20932099

20942100
elif s_buf_data == 'label':
20952101
name = s(buf, pp[i].data[0].data)

Doc/tools/partparse.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,18 @@ def startchange():
10131013
# same for enumerate
10141014
enumeratesymbols = ['1', 'A', 'a']
10151015

1016+
d = {}
1017+
for name in ('url', 'module', 'function', 'cfunction',
1018+
'keyword', 'method', 'exception', 'constant',
1019+
'email', 'class', 'member', 'cdata', 'ctype',
1020+
'member'):
1021+
d[name] = 'code'
1022+
d['program'] = 'strong'
1023+
d['sectcode'] = 'code'
1024+
convertible_csname = d.has_key
1025+
conversion = d.get
1026+
del d, name
1027+
10161028
##
10171029
## \begin{ {func,data,exc}desc }{name}...
10181030
## the resulting texi-code is dependent on the contents of indexsubitem
@@ -1391,6 +1403,8 @@ def changeit(buf, pp):
13911403
if pp[i].chtype != chunk_type[PLAIN]:
13921404
raise error, 'Sorry, expected plain text argument'
13931405
hist.itemargmacro = s(buf, pp[i].data)
1406+
if convertible_csname(hist.itemargmacro):
1407+
hist.itemargmacro = conversion(hist.itemargmacro)
13941408
del pp[i:newi]
13951409
length = length - (newi-i)
13961410

@@ -1593,9 +1607,6 @@ def changeit(buf, pp):
15931607
ch.chtype = chunk_type[PLAIN]
15941608
ch.data = release_version
15951609

1596-
elif s_buf_data == 'program':
1597-
ch.data = "strong"
1598-
15991610
elif s_buf_data == 'item':
16001611
ch.chtype = chunk_type[CSLINE]
16011612
length, newi = getoptarg(length, buf, pp, i)
@@ -1641,10 +1652,10 @@ def changeit(buf, pp):
16411652
if command in regindices:
16421653

16431654
arg = [chunk(CSNAME, ch.where, 't'),
1644-
chunk(GROUP, ch.where, arg)]
1655+
chunk(GROUP, ch.where, arg)]
16451656
else:
16461657
cat_arg = [chunk(CSNAME, ch.where, 'r'),
1647-
chunk(GROUP, ch.where, cat_arg)]
1658+
chunk(GROUP, ch.where, cat_arg)]
16481659

16491660
ingroupch = arg + \
16501661
[chunk(PLAIN, ch.where, ' ')] + \
@@ -1868,9 +1879,6 @@ def changeit(buf, pp):
18681879
pp.insert(i, chunk(GROUP, ch.where, ingroupch))
18691880
length, i = length+1, i+1
18701881

1871-
elif s_buf_data == 'sectcode':
1872-
ch.data = 'code'
1873-
18741882
elif s_buf_data in ('stmodindex', 'refstmodindex'):
18751883
ch.chtype = chunk_type[CSLINE]
18761884
# use the program index as module index
@@ -2086,10 +2094,8 @@ def changeit(buf, pp):
20862094
elif s_buf_data in ('noindent', 'indexsubitem', 'footnote'):
20872095
pass
20882096

2089-
elif s_buf_data in ('url', 'module', 'function', 'cfunction',
2090-
'keyword', 'method', 'exception', 'constant',
2091-
'email', 'class', 'member', 'cdata', 'ctype'):
2092-
ch.data = "code"
2097+
elif convertible_csname(s_buf_data):
2098+
ch.data = conversion(s_buf_data)
20932099

20942100
elif s_buf_data == 'label':
20952101
name = s(buf, pp[i].data[0].data)

0 commit comments

Comments
 (0)