Class ListBuilder
This holds information about the counters and nesting level of a (sub)list.
Declaration
class ListBuilder
source linkDocumentation
Do not create instances of this class directly, instead use the `unordered_list` and
`ordered_list` functions.
Methods
▷ def __exit__(self, exc_type, exc_val, exc_tb) ▶ def __init__(self, parent: Box, label: LabelType, default_indent: float, ...) def __init__(
self,
parent: Box,
label: LabelType,
default_indent: float,
label_padding: float,
level: List[int] = None,
start=1,
total_indent=0,
**box_args,
)
▶ def item(self, label: LabelType = None, label_padding: float = None, **box_args) Create a new item in the list.
Parameters
- label : LabelType
Either a string or a function.
If `label` is a string, it will be used as a label for each list item in the sublist.
If `label` is a function, it will be called for each label. It will be passed a Box and
a list of counter values for each nesting level and it should fill the box with the
contents of the label.
- label_padding : float
Horizontal gap between the label and the item.
If `None`, the padding will be taken from `label_padding` of the current list.
- box_args : kwargs
Additional arguments that will be passed to the box of the list item.
These arguments will be combined with the `box_args` of the current list.
▶ def ol(self, level: List[int] = None, *, start=1, indent: float = None, ...) Create a new ordered sublist.
def ol(
self,
level: List[int] = None,
*,
start=1,
indent: float = None,
label: LabelType = None,
**box_args,
)
Parameters
- level : List[int]
Override the parent counter values of the sublist.
For example:
lst.ol(level=(1, 3), start=5)
would be rendered as "1.3.5" with the default label renderer.
- start : int
The counter value at which will the new sublist start.
- indent : float
The sublist will be indented by the specified amount of pixels from the left.
If `None`, the indent will be taken from the default indent of the current list.
- label : LabelType
Either a string or a function.
If `label` is a string, it will be used as a label for each list item in the sublist.
If `label` is a function, it will be called for each label. It will be passed a Box and
a list of counter values for each nesting level and it should fill the box with the
contents of the label.
- box_args : kwargs
Additional arguments that will be passed to the box of each list item in the sublist.
These arguments will be combined with the `box_args` of the current list.
▶ def ul(self, indent: float = None, label: LabelType = None, **box_args) -> ListBuilder Create a new unordered sublist.
Parameters
- indent : float
The sublist will be indented by the specified amount of pixels from the left.
If `None`, the indent will be taken from the default indent of the current list.
- label : LabelType
Either a string or a function.
If `label` is a string, it will be used as a label for each list item in the sublist.
If `label` is a function, it will be called for each label. It will be passed a Box and
a list of counter values for each nesting level and it should fill the box with the
contents of the label.
- box_args : kwargs
Additional arguments that will be passed to the box of each list item in the sublist.
These arguments will be combined with the `box_args` of the current list.