Skip to content

Commit 2c1a30c

Browse files
authored
Merge pull request #20982 from meeseeksmachine/auto-backport-of-pr-20972-on-v3.5.x
Backport PR #20972 on branch v3.5.x (Cleanup some dviread docstrings.)
2 parents 3d18f5a + 8ddd9f0 commit 2c1a30c

File tree

1 file changed

+30
-36
lines changed

1 file changed

+30
-36
lines changed

lib/matplotlib/dviread.py

+30-36
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ def _arg(nbytes, signed, dvi, _):
8484

8585
def _arg_slen(dvi, delta):
8686
"""
87-
Signed, length *delta*
88-
8987
Read *delta* bytes, returning None if *delta* is zero, and the bytes
9088
interpreted as a signed integer otherwise.
9189
"""
@@ -96,26 +94,20 @@ def _arg_slen(dvi, delta):
9694

9795
def _arg_slen1(dvi, delta):
9896
"""
99-
Signed, length *delta*+1
100-
10197
Read *delta*+1 bytes, returning the bytes interpreted as signed.
10298
"""
103-
return dvi._arg(delta+1, True)
99+
return dvi._arg(delta + 1, True)
104100

105101

106102
def _arg_ulen1(dvi, delta):
107103
"""
108-
Unsigned length *delta*+1
109-
110104
Read *delta*+1 bytes, returning the bytes interpreted as unsigned.
111105
"""
112-
return dvi._arg(delta+1, False)
106+
return dvi._arg(delta + 1, False)
113107

114108

115109
def _arg_olen1(dvi, delta):
116110
"""
117-
Optionally signed, length *delta*+1
118-
119111
Read *delta*+1 bytes, returning the bytes interpreted as
120112
unsigned integer for 0<=*delta*<3 and signed if *delta*==3.
121113
"""
@@ -139,30 +131,30 @@ def _dispatch(table, min, max=None, state=None, args=('raw',)):
139131
matches *state* if not None, reads arguments from the file according
140132
to *args*.
141133
142-
*table*
143-
the dispatch table to be filled in
144-
145-
*min*
146-
minimum opcode for calling this function
147-
148-
*max*
149-
maximum opcode for calling this function, None if only *min* is allowed
150-
151-
*state*
152-
state of the Dvi object in which these opcodes are allowed
153-
154-
*args*
155-
sequence of argument specifications:
156-
157-
``'raw'``: opcode minus minimum
158-
``'u1'``: read one unsigned byte
159-
``'u4'``: read four bytes, treat as an unsigned number
160-
``'s4'``: read four bytes, treat as a signed number
161-
``'slen'``: read (opcode - minimum) bytes, treat as signed
162-
``'slen1'``: read (opcode - minimum + 1) bytes, treat as signed
163-
``'ulen1'``: read (opcode - minimum + 1) bytes, treat as unsigned
164-
``'olen1'``: read (opcode - minimum + 1) bytes, treat as unsigned
165-
if under four bytes, signed if four bytes
134+
Parameters
135+
----------
136+
table : dict[int, callable]
137+
The dispatch table to be filled in.
138+
139+
min, max : int
140+
Range of opcodes that calls the registered function; *max* defaults to
141+
*min*.
142+
143+
state : _dvistate, optional
144+
State of the Dvi object in which these opcodes are allowed.
145+
146+
args : list[str], default: ['raw']
147+
Sequence of argument specifications:
148+
149+
- 'raw': opcode minus minimum
150+
- 'u1': read one unsigned byte
151+
- 'u4': read four bytes, treat as an unsigned number
152+
- 's4': read four bytes, treat as a signed number
153+
- 'slen': read (opcode - minimum) bytes, treat as signed
154+
- 'slen1': read (opcode - minimum + 1) bytes, treat as signed
155+
- 'ulen1': read (opcode - minimum + 1) bytes, treat as unsigned
156+
- 'olen1': read (opcode - minimum + 1) bytes, treat as unsigned
157+
if under four bytes, signed if four bytes
166158
"""
167159
def decorate(method):
168160
get_args = [_arg_mapping[x] for x in args]
@@ -185,6 +177,7 @@ def wrapper(self, byte):
185177
class Dvi:
186178
"""
187179
A reader for a dvi ("device-independent") file, as produced by TeX.
180+
188181
The current implementation can only iterate through pages in order,
189182
and does not even attempt to verify the postamble.
190183
@@ -956,8 +949,9 @@ def _parse_and_cache_line(self, line):
956949

957950
def _parse_enc(path):
958951
r"""
959-
Parses a \*.enc file referenced from a psfonts.map style file.
960-
The format this class understands is a very limited subset of PostScript.
952+
Parse a \*.enc file referenced from a psfonts.map style file.
953+
954+
The format supported by this function is a tiny subset of PostScript.
961955
962956
Parameters
963957
----------

0 commit comments

Comments
 (0)