Skip to content

Commit 4ce0aca

Browse files
author
Bernhard Kaindl
committed
settings/match.py: Fix warning from sphinx due to "|" in docstring
Update tools/generate-settings-dataclasses.py to escape any '|' in docstrings with '\|', fixes this warning from sphinx: docstring of sdbus_async.networkmanager.settings.MatchSettings.interface_name:1: WARNING: Inline substitution_reference start-string without end-string.
1 parent 6d3c8d8 commit 4ce0aca

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

sdbus_async/networkmanager/settings/match.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,21 @@ class MatchSettings(NetworkManagerSettingsMixin):
1616
default=None,
1717
)
1818
"""A list of driver names to match. Each element is a shell wildcard pattern.
19-
See NMSettingMatch:interface-name for how special characters '|', '&', '!' and
20-
'\\' are used for optional and mandatory matches and inverting the pattern."""
19+
See NMSettingMatch:interface-name for how special characters '\|', '&', '!'
20+
and '\\' are used for optional and mandatory matches and inverting the
21+
pattern."""
2122
interface_name: Optional[List[str]] = field(
2223
metadata={'dbus_name': 'interface-name', 'dbus_type': 'as'},
2324
default=None,
2425
)
2526
"""A list of interface names to match. Each element is a shell wildcard
26-
pattern. An element can be prefixed with a pipe symbol (|) or an ampersand
27+
pattern. An element can be prefixed with a pipe symbol (\|) or an ampersand
2728
(&). The former means that the element is optional and the latter means that
2829
it is mandatory. If there are any optional elements, than the match evaluates
2930
to true if at least one of the optional element matches (logical OR). If there
3031
are any mandatory elements, then they all must match (logical AND). By
3132
default, an element is optional. This means that an element "foo" behaves the
32-
same as "|foo". An element can also be inverted with exclamation mark (!)
33+
same as "\|foo". An element can also be inverted with exclamation mark (!)
3334
between the pipe symbol (or the ampersand) and before the pattern. Note that
3435
"!foo" is a shortcut for the mandatory match "&!foo". Finally, a backslash can
3536
be used at the beginning of the element (after the optional special
@@ -46,7 +47,7 @@ class MatchSettings(NetworkManagerSettingsMixin):
4647
command line is searched for the word appearing as is, or as left hand side of
4748
an assignment. In the latter case, the exact assignment is looked for with
4849
right and left hand side matching. Wildcard patterns are not supported. See
49-
NMSettingMatch:interface-name for how special characters '|', '&', '!' and
50+
NMSettingMatch:interface-name for how special characters '\|', '&', '!' and
5051
'\\' are used for optional and mandatory matches and inverting the match."""
5152
path: Optional[List[str]] = field(
5253
metadata={'dbus_name': 'path', 'dbus_type': 'as'},
@@ -58,8 +59,8 @@ class MatchSettings(NetworkManagerSettingsMixin):
5859
specific identifier. For PCI devices the path has the form
5960
"pci-$domain:$bus:$device.$function", where each variable is an hexadecimal
6061
value; for example "pci-0000:0a:00.0". The path of a device can be obtained
61-
with "udevadm info /sys/class/net/$dev | grep ID_PATH=" or by looking at the
62+
with "udevadm info /sys/class/net/$dev \| grep ID_PATH=" or by looking at the
6263
"path" property exported by NetworkManager ("nmcli -f general.path device show
6364
$dev"). Each element of the list is a shell wildcard pattern. See
64-
NMSettingMatch:interface-name for how special characters '|', '&', '!' and
65+
NMSettingMatch:interface-name for how special characters '\|', '&', '!' and
6566
'\\' are used for optional and mandatory matches and inverting the pattern."""

tools/generate-settings-dataclasses.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,6 @@
1010
from pathlib import Path
1111
from typing import Any, Dict, List, Optional, OrderedDict, Tuple
1212

13-
14-
def dbg(msg: Any) -> None:
15-
print(f"{msg}")
16-
17-
18-
def write(msg: Any) -> None:
19-
print(f"{msg}")
20-
21-
2213
dbus_type_name_map = {
2314
"b": "bool",
2415
"s": "str",
@@ -391,13 +382,16 @@ def main(settings_xml_path: Path) -> None:
391382
# developers when they lookup the attribute declaration:
392383
generate_descriptions_for_attributes = True
393384
if generate_descriptions_for_attributes:
394-
desc = node_get_attr(properties_attrs, "description")
385+
attr_description = node_get_attr(properties_attrs, "description")
386+
# Fix warning from sphinx: WARNING:
387+
# Inline substitution_reference start-string without end-string
388+
attr_docstring = attr_description.replace("|", "\|")
395389
wrapper = textwrap.TextWrapper(
396390
width=82,
397391
initial_indent=" ",
398392
subsequent_indent=" ",
399393
)
400-
lines = wrapper.wrap(text=f'"""{desc}"""')
394+
lines = wrapper.wrap(text=f'"""{attr_docstring}"""')
401395
if len(lines) == 1:
402396
print(lines[0] + '"""')
403397
else:

0 commit comments

Comments
 (0)