File: rebuildPtreeRst.py

package info (click to toggle)
python-pyqtgraph 0.13.7-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,068 kB
  • sloc: python: 54,043; makefile: 129; ansic: 40; sh: 2
file content (48 lines) | stat: -rw-r--r-- 1,221 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os.path
import textwrap

from pyqtgraph.parametertree.Parameter import PARAM_TYPES, _PARAM_ITEM_TYPES


def mkDocs(typeList):
    typeNames = sorted([typ.__name__ for typ in typeList])
    typDocs = [
    f"""\
    .. autoclass:: {name}
       :members:
    """
    for name in typeNames]
    indented = '\n'.join(typDocs)
    # There will be two newlines at the end, so remove one
    return textwrap.dedent(indented)[:-1]

types = set(PARAM_TYPES.values())
items = [typ.itemClass for typ in PARAM_TYPES.values() if typ.itemClass is not None] \
            + [item for item in _PARAM_ITEM_TYPES.values()]
items = set(items)

doc = f"""\
..
  This file is auto-generated from pyqtgraph/tools/rebuildPtreeRst.py. Do not modify by hand! Instead, rerun the
  generation script with `python pyqtgraph/tools/rebuildPtreeRst.py`.

Built-in Parameter Types
========================

.. currentmodule:: pyqtgraph.parametertree.parameterTypes

Parameters
----------

{mkDocs(types)}

ParameterItems
--------------

{mkDocs(items)}
"""

here = os.path.dirname(__file__)
rstFilename = os.path.join(here, '..', 'doc', 'source', 'parametertree', 'parametertypes.rst')
with open(rstFilename, 'w') as ofile:
    ofile.write(doc)