[docs] [issue37134] Use PEP570 syntax in the documentation

STINNER Victor report at bugs.python.org
Thu Jun 6 19:24:18 EDT 2019


STINNER Victor <vstinner at redhat.com> added the comment:

It seems like the translate() method of bytes and bytearray also needs a "/" in their doc.

I wrote a quick & dirty script to parse C files:
---
import glob

def parse(filename):
    clinic_input = False
    args = False
    positional = False
    func = None
    for line_number, line in enumerate(open(filename)):
        line = line.rstrip()
        if line.startswith("/*[clinic input]"):
            clinic_input = True
            args = False
            positional = False
            func = None
        elif clinic_input and func is None:
            func = line
        elif clinic_input and not args and not line:
            args = True
        elif args and line == "    /":
            positional = True
        elif positional and (line == "    *" or line.startswith("[clinic start generated code]")):
            clinic_input = False
            args = False
            positional = False
            func = None
        elif positional and line:
            print("!!!", filename, line_number, func, repr(line))
        elif not line:
            clinic_input = False
            args = False
            positional = False
            func = None

for filename in glob.glob("*/**.c"):
    parse(filename)
---

Output on the master branch:
---
!!! Modules/_struct.c 2224 unpack_from '    buffer: Py_buffer'
!!! Modules/_struct.c 2225 unpack_from '    offset: Py_ssize_t = 0'
!!! Modules/zlibmodule.c 195 zlib.compress '    level: int(c_default="Z_DEFAULT_COMPRESSION") = Z_DEFAULT_COMPRESSION'
!!! Modules/zlibmodule.c 196 zlib.compress '        Compression level, in 0-9 or -1.'
!!! Modules/zlibmodule.c 314 zlib.decompress '    wbits: int(c_default="MAX_WBITS") = MAX_WBITS'
!!! Modules/zlibmodule.c 315 zlib.decompress '        The window buffer size and container format.'
!!! Modules/zlibmodule.c 316 zlib.decompress '    bufsize: ssize_t(c_default="DEF_BUF_SIZE") = DEF_BUF_SIZE'
!!! Modules/zlibmodule.c 317 zlib.decompress '        The initial output buffer size.'
!!! Modules/zlibmodule.c 744 zlib.Decompress.decompress '    max_length: ssize_t = 0'
!!! Modules/zlibmodule.c 745 zlib.Decompress.decompress '        The maximum allowable length of the decompressed data.'
!!! Modules/zlibmodule.c 746 zlib.Decompress.decompress '        Unconsumed input data will be stored in'
!!! Modules/zlibmodule.c 747 zlib.Decompress.decompress '        the unconsumed_tail attribute.'
!!! Objects/bytearrayobject.c 1197 bytearray.translate '    delete as deletechars: object(c_default="NULL") = b\'\''
!!! Objects/bytesobject.c 2080 bytes.translate '    delete as deletechars: object(c_default="NULL") = b\'\''
!!! Python/bltinmodule.c 2282 sum as builtin_sum '    start: object(c_default="NULL") = 0'
---

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue37134>
_______________________________________


More information about the docs mailing list