Skip to content

Cleanup some dviread docstrings. #20972

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 30 additions & 36 deletions lib/matplotlib/dviread.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ def _arg(nbytes, signed, dvi, _):

def _arg_slen(dvi, delta):
"""
Signed, length *delta*

Read *delta* bytes, returning None if *delta* is zero, and the bytes
interpreted as a signed integer otherwise.
"""
Expand All @@ -96,26 +94,20 @@ def _arg_slen(dvi, delta):

def _arg_slen1(dvi, delta):
"""
Signed, length *delta*+1

Read *delta*+1 bytes, returning the bytes interpreted as signed.
"""
return dvi._arg(delta+1, True)
return dvi._arg(delta + 1, True)


def _arg_ulen1(dvi, delta):
"""
Unsigned length *delta*+1

Read *delta*+1 bytes, returning the bytes interpreted as unsigned.
"""
return dvi._arg(delta+1, False)
return dvi._arg(delta + 1, False)


def _arg_olen1(dvi, delta):
"""
Optionally signed, length *delta*+1

Read *delta*+1 bytes, returning the bytes interpreted as
unsigned integer for 0<=*delta*<3 and signed if *delta*==3.
"""
Expand All @@ -139,30 +131,30 @@ def _dispatch(table, min, max=None, state=None, args=('raw',)):
matches *state* if not None, reads arguments from the file according
to *args*.

*table*
the dispatch table to be filled in

*min*
minimum opcode for calling this function

*max*
maximum opcode for calling this function, None if only *min* is allowed

*state*
state of the Dvi object in which these opcodes are allowed

*args*
sequence of argument specifications:

``'raw'``: opcode minus minimum
``'u1'``: read one unsigned byte
``'u4'``: read four bytes, treat as an unsigned number
``'s4'``: read four bytes, treat as a signed number
``'slen'``: read (opcode - minimum) bytes, treat as signed
``'slen1'``: read (opcode - minimum + 1) bytes, treat as signed
``'ulen1'``: read (opcode - minimum + 1) bytes, treat as unsigned
``'olen1'``: read (opcode - minimum + 1) bytes, treat as unsigned
if under four bytes, signed if four bytes
Parameters
----------
table : dict[int, callable]
The dispatch table to be filled in.

min, max : int
Range of opcodes that calls the registered function; *max* defaults to
*min*.

state : _dvistate, optional
State of the Dvi object in which these opcodes are allowed.

args : list[str], default: ['raw']
Sequence of argument specifications:

- 'raw': opcode minus minimum
- 'u1': read one unsigned byte
- 'u4': read four bytes, treat as an unsigned number
- 's4': read four bytes, treat as a signed number
- 'slen': read (opcode - minimum) bytes, treat as signed
- 'slen1': read (opcode - minimum + 1) bytes, treat as signed
- 'ulen1': read (opcode - minimum + 1) bytes, treat as unsigned
- 'olen1': read (opcode - minimum + 1) bytes, treat as unsigned
if under four bytes, signed if four bytes
"""
def decorate(method):
get_args = [_arg_mapping[x] for x in args]
Expand All @@ -185,6 +177,7 @@ def wrapper(self, byte):
class Dvi:
"""
A reader for a dvi ("device-independent") file, as produced by TeX.

The current implementation can only iterate through pages in order,
and does not even attempt to verify the postamble.

Expand Down Expand Up @@ -956,8 +949,9 @@ def _parse_and_cache_line(self, line):

def _parse_enc(path):
r"""
Parses a \*.enc file referenced from a psfonts.map style file.
The format this class understands is a very limited subset of PostScript.
Parse a \*.enc file referenced from a psfonts.map style file.

The format supported by this function is a tiny subset of PostScript.

Parameters
----------
Expand Down