Skip to content

Commit dedebb9

Browse files
author
Joel Collins
committed
Switched all docstrings to common format
1 parent 278b9ff commit dedebb9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1154
-389
lines changed

docs/api_reference/index.rst

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
API Reference
22
=============
33

4-
LabThing
5-
--------
6-
7-
.. autoclass:: labthings.LabThing
8-
:members:
9-
10-
Module
11-
------
12-
134
.. automodule:: labthings
145
:members:

src/labthings/apispec/apispec.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
def rule_to_apispec_path(rule: Rule, view, apispec: APISpec):
1313
"""Generate APISpec Path arguments from a flask Rule and View
1414
15-
Args:
16-
rule (Rule): Flask Rule for path
17-
view: View class
18-
apispec (APISpec): APISpec object to generate arguments for
15+
:param rule: Flask Rule for path
16+
:type rule: Rule
17+
:param view: View class
18+
:param apispec: APISpec object to generate arguments for
19+
:type apispec: APISpec
20+
:param rule: Rule:
21+
:param apispec: APISpec:
22+
:returns: APISpec `path` funtion argument dictionary
23+
:rtype: dict
1924
20-
Returns:
21-
dict: APISpec `path` funtion argument dictionary
2225
"""
2326

2427
params = {

src/labthings/apispec/converter.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,26 @@
22

33

44
class ExtendedOpenAPIConverter(OpenAPIConverter):
5+
""" """
56
field_mapping = OpenAPIConverter.field_mapping
67

78
def init_attribute_functions(self, *args, **kwargs):
9+
"""
10+
11+
:param *args:
12+
:param **kwargs:
13+
14+
"""
815
OpenAPIConverter.init_attribute_functions(self, *args, **kwargs)
916
self.attribute_functions.append(self.jsonschema_type_mapping)
1017

1118
def jsonschema_type_mapping(self, field, **kwargs):
19+
"""
20+
21+
:param field:
22+
:param **kwargs:
23+
24+
"""
1225
ret = {}
1326
if hasattr(field, "_jsonschema_type_mapping"):
1427
schema = field._jsonschema_type_mapping()

src/labthings/apispec/plugins.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33

44

55
class MarshmallowPlugin(_MarshmallowPlugin):
6+
""" """
67
Converter = ExtendedOpenAPIConverter

src/labthings/apispec/utilities.py

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88

99

1010
def convert_to_schema_or_json(schema, spec: APISpec):
11-
"""
12-
Ensure that a given schema is either a real Marshmallow schema,
11+
"""Ensure that a given schema is either a real Marshmallow schema,
1312
or is a dictionary describing the schema inline.
14-
13+
1514
Marshmallow schemas are left as they are so that the APISpec module
1615
can add them to the "schemas" list in our APISpec documentation.
16+
17+
:param schema:
18+
:param spec: APISpec:
19+
1720
"""
1821
# Don't process Nones
1922
if not schema:
@@ -35,9 +38,12 @@ def convert_to_schema_or_json(schema, spec: APISpec):
3538

3639

3740
def map_to_properties(schema, spec: APISpec):
38-
"""
39-
Recursively convert any dictionary-like map of Marshmallow fields
41+
"""Recursively convert any dictionary-like map of Marshmallow fields
4042
into a dictionary describing it's JSON schema
43+
44+
:param schema:
45+
:param spec: APISpec:
46+
4147
"""
4248

4349
d = {}
@@ -53,7 +59,12 @@ def map_to_properties(schema, spec: APISpec):
5359

5460

5561
def field_to_property(field, spec: APISpec):
56-
"""Convert a single Marshmallow field into a JSON schema of that field"""
62+
"""Convert a single Marshmallow field into a JSON schema of that field
63+
64+
:param field:
65+
:param spec: APISpec:
66+
67+
"""
5768
marshmallow_plugin = next(
5869
plugin for plugin in spec.plugins if isinstance(plugin, MarshmallowPlugin)
5970
)
@@ -68,11 +79,14 @@ def field_to_property(field, spec: APISpec):
6879

6980

7081
def schema_to_json(schema, spec: APISpec):
71-
"""
72-
Convert any Marshmallow schema stright to a fully expanded JSON schema.
82+
"""Convert any Marshmallow schema stright to a fully expanded JSON schema.
7383
This should not be used when generating APISpec documentation,
7484
otherwise schemas wont be listed in the "schemas" list.
7585
This is used, for example, in the Thing Description.
86+
87+
:param schema:
88+
:param spec: APISpec:
89+
7690
"""
7791

7892
if isinstance(schema, Schema):
@@ -89,10 +103,13 @@ def schema_to_json(schema, spec: APISpec):
89103

90104

91105
def recursive_expand_refs(schema_dict, spec: APISpec):
92-
"""
93-
Traverse `schema_dict` expanding out all schema $ref values where possible.
94-
106+
"""Traverse `schema_dict` expanding out all schema $ref values where possible.
107+
95108
Used when generating Thing Descriptions, so each attribute contains full schemas.
109+
110+
:param schema_dict:
111+
:param spec: APISpec:
112+
96113
"""
97114
if isinstance(schema_dict, Mapping):
98115
if "$ref" in schema_dict:
@@ -106,10 +123,13 @@ def recursive_expand_refs(schema_dict, spec: APISpec):
106123

107124

108125
def expand_refs(schema_dict, spec: APISpec):
109-
"""
110-
Expand out all schema $ref values where possible.
111-
126+
"""Expand out all schema $ref values where possible.
127+
112128
Uses the $ref value to look up a particular schema in spec schemas
129+
130+
:param schema_dict:
131+
:param spec: APISpec:
132+
113133
"""
114134
if "$ref" not in schema_dict:
115135
return schema_dict

src/labthings/default_views/actions.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,29 @@
99

1010

1111
class ActionQueue(View):
12-
"""
13-
List of all actions from the session
14-
"""
12+
"""List of all actions from the session"""
1513

1614
def get(self):
15+
""" """
1716
return ActionSchema(many=True).dump(current_labthing().actions.threads)
1817

1918

2019
class ActionView(View):
21-
"""
22-
Manage a particular action.
23-
20+
"""Manage a particular action.
21+
2422
GET will safely return the current action progress.
2523
DELETE will cancel the action, if pending or running.
24+
25+
2626
"""
2727

2828
def get(self, task_id):
29-
"""
30-
Show status of a session task
31-
29+
"""Show status of a session task
30+
3231
Includes progress and intermediate data.
32+
33+
:param task_id:
34+
3335
"""
3436
task_dict = current_labthing().actions.to_dict()
3537

@@ -42,10 +44,13 @@ def get(self, task_id):
4244

4345
@use_args({"timeout": fields.Int(missing=5)})
4446
def delete(self, args, task_id):
45-
"""
46-
Terminate a running task.
47-
47+
"""Terminate a running task.
48+
4849
If the task is finished, deletes its entry.
50+
51+
:param args:
52+
:param task_id:
53+
4954
"""
5055
timeout = args.get("timeout", 5)
5156
task_dict = current_labthing().actions.to_dict()

src/labthings/default_views/docs/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class SwaggerUIView(View):
1616
"""Swagger UI documentation"""
1717

1818
def get(self):
19+
""" """
1920
return make_response(render_template("swagger-ui.html"))
2021

2122

src/labthings/default_views/extensions.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ class ExtensionList(View):
1010
tags = ["extensions"]
1111

1212
def get(self):
13-
"""
14-
List enabled extensions.
15-
13+
"""List enabled extensions.
14+
1615
Returns a list of Extension representations, including basic documentation.
1716
Describes server methods, web views, and other relevant Lab Things metadata.
17+
18+
1819
"""
1920
return ExtensionSchema(many=True).dump(registered_extensions().values() or [])

src/labthings/default_views/root.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ class RootView(View):
66
"""W3C Thing Description"""
77

88
def get(self):
9+
""" """
910
return current_labthing().thing_description.to_dict()

src/labthings/default_views/sockets.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99

1010
def socket_handler(ws):
11+
"""
12+
13+
:param ws:
14+
15+
"""
1116
# Create a socket subscriber
1217
wssub = SocketSubscriber(ws)
1318
current_labthing().subscribers.add(wssub)
@@ -26,6 +31,11 @@ def socket_handler(ws):
2631

2732

2833
def process_socket_message(message: str):
34+
"""
35+
36+
:param message: str:
37+
38+
"""
2939
if message:
3040
if message in STATIC_SOCKET_RESPONSES:
3141
return STATIC_SOCKET_RESPONSES.get(message)

0 commit comments

Comments
 (0)