Skip to content

Commit 3f83997

Browse files
elprans1st1
authored andcommitted
Add documentation.
1 parent 697e133 commit 3f83997

File tree

12 files changed

+750
-3
lines changed

12 files changed

+750
-3
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
ignore = E402,E731
33
exclude =
44
.git, __pycache__, build, dist, .eggs, .github, .local,
5-
Samples, azure/worker/protos/
5+
Samples, azure/worker/protos/, docs/
File renamed without changes.

azure/functions/_abc.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,62 +8,80 @@
88

99

1010
class Out(abc.ABC, typing.Generic[T]):
11+
"""An interface to set function output parameters."""
1112

1213
@abc.abstractmethod
1314
def set(self, val: T) -> None:
15+
"""Set the value of the output parameter."""
1416
pass
1517

1618
@abc.abstractmethod
1719
def get(self) -> T:
20+
"""Get the value of the output parameter."""
1821
pass
1922

2023

2124
class Context(abc.ABC):
25+
"""Function invocation context."""
2226

2327
@property
2428
@abc.abstractmethod
2529
def invocation_id(self) -> str:
30+
"""Function invocation ID."""
2631
pass
2732

2833
@property
2934
@abc.abstractmethod
3035
def function_name(self) -> str:
36+
"""Function name."""
3137
pass
3238

3339
@property
3440
@abc.abstractmethod
3541
def function_directory(self) -> str:
42+
"""Function directory."""
3643
pass
3744

3845

3946
class HttpRequest(abc.ABC):
47+
"""HTTP request object."""
4048

4149
@property
4250
@abc.abstractmethod
4351
def method(self) -> str:
52+
"""Request method."""
4453
pass
4554

4655
@property
4756
@abc.abstractmethod
4857
def url(self) -> str:
58+
"""Request URL."""
4959
pass
5060

5161
@property
5262
@abc.abstractmethod
5363
def headers(self) -> typing.Mapping[str, str]:
64+
"""A dictionary containing request headers."""
5465
pass
5566

5667
@property
5768
@abc.abstractmethod
5869
def params(self) -> typing.Mapping[str, str]:
70+
"""A dictionary containing request GET parameters."""
5971
pass
6072

6173
@abc.abstractmethod
6274
def get_body(self) -> bytes:
75+
"""Return request body as bytes."""
6376
pass
6477

6578
@abc.abstractmethod
6679
def get_json(self) -> typing.Any:
80+
"""Decode and return request body as JSON.
81+
82+
:raises ValueError:
83+
when the request does not contain valid JSON data.
84+
"""
6785
pass
6886

6987

@@ -95,17 +113,30 @@ def get_body(self) -> bytes:
95113

96114

97115
class TimerRequest(abc.ABC):
116+
"""Timer request object."""
98117

99118
@property
100119
@abc.abstractmethod
101120
def past_due(self) -> bool:
121+
"""Whether the timer is past due."""
102122
pass
103123

104124

105125
class InputStream(io.BufferedIOBase, abc.ABC):
126+
"""File-like object representing an input blob."""
106127

107128
@abc.abstractmethod
108129
def read(self, size=-1) -> bytes:
130+
"""Return and read up to *size* bytes.
131+
132+
:param int size:
133+
The number of bytes to read. If the argument is omitted,
134+
``None``, or negative, data is read and returned until
135+
EOF is reached.
136+
137+
:return:
138+
Bytes read from the input stream.
139+
"""
109140
pass
110141

111142

azure/functions/_http.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,25 @@ def __delitem__(self, key: str):
4040

4141

4242
class HttpResponse(_abc.HttpResponse):
43-
"""An HTTP response object."""
43+
"""An HTTP response object.
44+
45+
:param str/bytes body:
46+
Optional response body.
47+
48+
:param int status_code:
49+
Response status code. If not specified, defaults to 200.
50+
51+
:param dict headers:
52+
An optional mapping containing response HTTP headers.
53+
54+
:param str mimetype:
55+
An optional response MIME type. If not specified, defaults to
56+
``'text/plain'``.
57+
58+
:param str charset:
59+
Response content text encoding. If not specified, defaults to
60+
``'utf-8'``.
61+
"""
4462

4563
def __init__(self, body=None, *,
4664
status_code=None, headers=None, mimetype=None, charset=None):
@@ -67,18 +85,22 @@ def __init__(self, body=None, *,
6785

6886
@property
6987
def mimetype(self):
88+
"""Response MIME type."""
7089
return self.__mimetype
7190

7291
@property
7392
def charset(self):
93+
"""Response text encoding."""
7494
return self.__charset
7595

7696
@property
7797
def headers(self):
98+
"""A dictionary of response HTTP headers."""
7899
return self.__headers
79100

80101
@property
81102
def status_code(self):
103+
"""Response status code."""
82104
return self.__status_code
83105

84106
def __set_body(self, body):
@@ -93,4 +115,5 @@ def __set_body(self, body):
93115
self.__body = bytes(body)
94116

95117
def get_body(self) -> bytes:
118+
"""Response body as a bytes object."""
96119
return self.__body

azure/functions/_queue.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,17 @@
66

77

88
class QueueMessage(_abc.QueueMessage):
9-
"""An HTTP response object."""
9+
"""A Queue message object.
10+
11+
:param str id:
12+
An optional string specifying the ID of the message.
13+
14+
:param body:
15+
A string or bytes instance specifying the message body.
16+
17+
:param str pop_receipt:
18+
An optional string containing the pop receipt token.
19+
"""
1020

1121
def __init__(self, *,
1222
id: typing.Optional[str]=None,
@@ -21,26 +31,32 @@ def __init__(self, *,
2131

2232
@property
2333
def id(self) -> typing.Optional[str]:
34+
"""Message ID."""
2435
return self.__id
2536

2637
@property
2738
def dequeue_count(self) -> typing.Optional[int]:
39+
"""The number of times this message has been dequeued."""
2840
return None
2941

3042
@property
3143
def expiration_time(self) -> typing.Optional[datetime.datetime]:
44+
"""A datetime object with the message expiry time."""
3245
return None
3346

3447
@property
3548
def insertion_time(self) -> typing.Optional[datetime.datetime]:
49+
"""A datetime object with the message queue insertion time."""
3650
return None
3751

3852
@property
3953
def next_visible_time(self) -> typing.Optional[datetime.datetime]:
54+
"""A datetime object with the time the message will be visible next."""
4055
return None
4156

4257
@property
4358
def pop_receipt(self) -> typing.Optional[str]:
59+
"""The message pop receipt token as a string."""
4460
return self.__pop_receipt
4561

4662
def __set_body(self, body):
@@ -55,9 +71,18 @@ def __set_body(self, body):
5571
self.__body = bytes(body)
5672

5773
def get_body(self) -> bytes:
74+
"""Return message content as bytes."""
5875
return self.__body
5976

6077
def get_json(self) -> typing.Any:
78+
"""Decode and return message content as a JSON object.
79+
80+
:return:
81+
Decoded JSON data.
82+
83+
:raises ValueError:
84+
when the body of the message does not contain valid JSON data.
85+
"""
6186
return json.loads(self.__body)
6287

6388
def __repr__(self) -> str:

docs/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
_build
2+
_templates

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
SPHINXPROJ = AzureFunctionsforPython
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/api.rst

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
.. _azure-functions-reference:
2+
3+
=============
4+
API Reference
5+
=============
6+
7+
.. module:: azure.functions
8+
:synopsis: Azure Functions bindings.
9+
10+
.. currentmodule:: azure.functions
11+
12+
13+
.. _azure-functions-bindings-blob:
14+
15+
Blob Bindings
16+
=============
17+
18+
.. autoclass:: azure.functions.InputStream
19+
:members:
20+
21+
22+
.. _azure-functions-bindings-http:
23+
24+
HTTP Bindings
25+
=============
26+
27+
.. autoclass:: azure.functions.HttpRequest
28+
:members:
29+
30+
.. autoclass:: azure.functions.HttpResponse
31+
:members:
32+
33+
34+
.. _azure-functions-bindings-queue:
35+
36+
Queue Bindings
37+
==============
38+
39+
.. autoclass:: azure.functions.QueueMessage
40+
:members:
41+
42+
43+
.. _azure-functions-bindings-timer:
44+
45+
Timer Bindings
46+
==============
47+
48+
.. autoclass:: azure.functions.TimerRequest
49+
:members:
50+
51+
52+
.. _azure-functions-bindings-context:
53+
54+
Function Context
55+
================
56+
57+
.. autoclass:: azure.functions.Context
58+
:members:
59+
60+
61+
Out Parameters
62+
==============
63+
64+
.. autoclass:: azure.functions.Out
65+
:members:

0 commit comments

Comments
 (0)