Skip to content

Commit d7973e4

Browse files
committed
Document sdbus.utils.inspect using autodoc
Will make it easier to add typing overloads in the future.
1 parent 12c41ca commit d7973e4

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

docs/utils.rst

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,5 @@ Inspect D-Bus objects and retrieve their D-Bus related attributes
1717
such as D-Bus object paths and etc...
1818
Available under ``sdbus.utils.inspect`` subpackage.
1919

20-
.. py:currentmodule:: sdbus.utils.inspect
21-
22-
.. py:function:: inspect_dbus_path(obj, bus=None)
23-
24-
Returns the D-Bus path of an object.
25-
26-
If called on a D-Bus proxy returns path of the proxied object.
27-
28-
If called on a local D-Bus object returns the exported D-Bus path.
29-
If object is not exported raises ``LookupError``.
30-
31-
If called on an object that is unrelated to D-Bus raises ``TypeError``.
32-
33-
The object's path is inspected in the context of the given bus and if the
34-
object is attached to a different bus the ``LookupError`` will be raised.
35-
If the bus argument is not given or is ``None`` the default bus will be
36-
checked against.
37-
38-
:param object obj: Object to inspect.
39-
:param SdBus bus:
40-
Bus to inspect against.
41-
If not given or ``None`` the default bus will be used.
42-
:rtype: str
43-
:returns: D-Bus path of the object.
44-
45-
*New in version 0.13.0.*
20+
.. automodule:: sdbus.utils.inspect
21+
:members:

src/sdbus/utils/inspect.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,30 @@ def inspect_dbus_path(
7171
obj: Union[DbusInterfaceBase, DbusInterfaceBaseAsync],
7272
bus: Optional[SdBus] = None,
7373
) -> str:
74+
"""Return the D-Bus path of an object.
75+
76+
If called on a D-Bus proxy returns path of the proxied object.
77+
78+
If called on a local D-Bus object returns the exported D-Bus path.
79+
If object is not exported raises ``LookupError``.
80+
81+
If called on an object that is unrelated to D-Bus raises ``TypeError``.
82+
83+
The object's path is inspected in the context of the given bus and if the
84+
object is attached to a different bus the ``LookupError`` will be raised.
85+
If the bus argument is not given or is ``None`` the default bus will be
86+
checked against.
87+
88+
:param obj:
89+
Object to inspect.
90+
:param bus:
91+
Bus to inspect against.
92+
If not given or is ``None`` the default bus will be used.
93+
:returns:
94+
D-Bus path of the object.
95+
96+
*New in version 0.13.0.*
97+
"""
7498
if bus is None:
7599
bus = get_default_bus()
76100

0 commit comments

Comments
 (0)