Browse Source

rST docstrings

Clara Hobbs 7 years ago
parent
commit
64ed72e4e0
1 changed files with 19 additions and 24 deletions
  1. 19
    24
      pdbuddy/__init__.py

+ 19
- 24
pdbuddy/__init__.py View File

@@ -12,22 +12,21 @@ class Sink:
12 12
     pid = 0x0001
13 13
 
14 14
     def __init__(self, sp):
15
-        """Open the serial port to communicate with the PD Buddy Sink
15
+        """Open a serial port to communicate with the PD Buddy Sink
16 16
         
17
-        Parameters:
18
-            sp: A serial.tools.list_ports.ListPortInfo object
17
+        :param sp: the serial port of the device
18
+        :type sp: str or `serial.tools.list_ports.ListPortInfo`
19 19
         """
20 20
         self.port = serial.Serial(sp.device, baudrate=115200)
21 21
 
22 22
     def send_command(self, cmd):
23 23
         """Send a command to the PD Buddy Sink, returning the result
24 24
         
25
-        Parameters:
26
-            cmd: A string containing the text to send to the Sink
25
+        :param cmd: the text to send to the Sink
26
+        :type sp: str
27 27
         
28
-        Returns:
29
-            A list of zero or more bytes objects, each being one line printed
30
-            as a response to the command.
28
+        :returns: a list of zero or more bytes objects, each being one line
29
+            printed as a response to the command.
31 30
         """
32 31
         # Send the command
33 32
         self.port.write(bytes(cmd, "utf-8") + b"\r\n")
@@ -62,7 +61,7 @@ class Sink:
62 61
     def load(self):
63 62
         """Loads the current configuration from flash into the buffer
64 63
         
65
-        Raises KeyError if there is no configuration in flash.
64
+        :raises: KeyError
66 65
         """
67 66
         text = self.send_command("load")
68 67
         if len(text) > 0 and text[0].startswith(b"No configuration"):
@@ -71,11 +70,9 @@ class Sink:
71 70
     def get_cfg(self, index=None):
72 71
         """Reads configuration from flash
73 72
          
74
-        Parameters:
75
-            index: Optional index of configuration object in flash to read
73
+        :param index: optional index of configuration object in flash to read
76 74
 
77
-        Returns:
78
-            A SinkConfig object
75
+        :returns: a `SinkConfig` object
79 76
         """
80 77
         if index is None:
81 78
             cfg = self.send_command("get_cfg")
@@ -87,8 +84,7 @@ class Sink:
87 84
     def get_tmpcfg(self):
88 85
         """Reads the contents of the configuration buffer
89 86
 
90
-        Returns:
91
-            A SinkConfig object
87
+        :returns: a `SinkConfig` object
92 88
         """
93 89
         cfg = self.send_command("get_tmpcfg")
94 90
 
@@ -118,7 +114,7 @@ class Sink:
118 114
         """Writes a SinkConfig object to the device's configuration buffer
119 115
         
120 116
         Note: the value of the status field is ignored; it will always be
121
-        SinkStatus.VALID.
117
+        `SinkStatus.VALID`.
122 118
         """
123 119
         # Set flags
124 120
         self.clear_flags()
@@ -135,7 +131,7 @@ class Sink:
135 131
     def get_devices(cls):
136 132
         """Get an iterable of PD Buddy Sink devices
137 133
         
138
-        Returns an iterable of serial.tools.list_ports.ListPortInfo objects.
134
+        :returns: an iterable of `serial.tools.list_ports.ListPortInfo` objects
139 135
         """
140 136
         return serial.tools.list_ports.grep("{:04X}:{:04X}".format(cls.vid,
141 137
             cls.pid))
@@ -147,11 +143,10 @@ class SinkConfig:
147 143
     def __init__(self, status=None, flags=None, v=None, i=None):
148 144
         """Create a SinkConfig object
149 145
         
150
-        Parameters:
151
-            status: A SinkStatus value
152
-            flags: Zero or more SinkFlags values
153
-            v: Voltage in millivolts
154
-            i: Current in milliamperes
146
+        :param status: A `SinkStatus` value
147
+        :param flags: Zero or more `SinkFlags` values
148
+        :param v: Voltage in millivolts
149
+        :param i: Current in milliamperes
155 150
         """
156 151
         self.status = status
157 152
         self.flags = flags
@@ -240,9 +235,9 @@ class SinkConfig:
240 235
     def from_text(cls, text):
241 236
         """Creates a SinkConfig from text returned by Sink.send_command
242 237
         
243
-        Returns a new SinkConfig object.
238
+        :returns: a new `SinkConfig` object.
244 239
 
245
-        Raises IndexError if the configuration reads "Invalid index".
240
+        :raises: IndexError
246 241
         """
247 242
         # Assume the parameters will all be None
248 243
         status = None

Loading…
Cancel
Save