Skip to content

Commit 069471d

Browse files
authored
Merge pull request #49 from nitrictech/fix/autogen-docs
fix docs generation
2 parents 0b00b91 + 52152ce commit 069471d

34 files changed

Lines changed: 4989 additions & 12055 deletions
Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
66
<meta name="generator" content="pdoc 0.9.2" />
7-
<title>nitric.proto API documentation</title>
7+
<title>nitric.api.const API documentation</title>
88
<meta name="description" content="" />
99
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
1010
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
@@ -19,7 +19,7 @@
1919
<main>
2020
<article id="content">
2121
<header>
22-
<h1 class="title">Module <code>nitric.proto</code></h1>
22+
<h1 class="title">Module <code>nitric.api.const</code></h1>
2323
</header>
2424
<section id="section-intro">
2525
<details class="source">
@@ -43,17 +43,14 @@ <h1 class="title">Module <code>nitric.proto</code></h1>
4343
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4444
# See the License for the specific language governing permissions and
4545
# limitations under the License.
46-
#</code></pre>
46+
#
47+
48+
# The maximum number of parent collections a sub-collection can have.
49+
# This is implemented in the Membrane, but reinforced here for immediate exceptions without a server connection.
50+
MAX_SUB_COLLECTION_DEPTH = 1</code></pre>
4751
</details>
4852
</section>
4953
<section>
50-
<h2 class="section-title" id="header-submodules">Sub-modules</h2>
51-
<dl>
52-
<dt><code class="name"><a title="nitric.proto.nitric" href="nitric/index.html">nitric.proto.nitric</a></code></dt>
53-
<dd>
54-
<div class="desc"></div>
55-
</dd>
56-
</dl>
5754
</section>
5855
<section>
5956
</section>
@@ -70,12 +67,7 @@ <h1>Index</h1>
7067
<ul id="index">
7168
<li><h3>Super-module</h3>
7269
<ul>
73-
<li><code><a title="nitric" href="../index.html">nitric</a></code></li>
74-
</ul>
75-
</li>
76-
<li><h3><a href="#header-submodules">Sub-modules</a></h3>
77-
<ul>
78-
<li><code><a title="nitric.proto.nitric" href="nitric/index.html">nitric.proto.nitric</a></code></li>
70+
<li><code><a title="nitric.api" href="index.html">nitric.api</a></code></li>
7971
</ul>
8072
</li>
8173
</ul>

docs/nitric/api/documents.html

Lines changed: 1961 additions & 0 deletions
Large diffs are not rendered by default.

docs/nitric/api/event.html

Lines changed: 0 additions & 355 deletions
This file was deleted.

docs/nitric/api/events.html

Lines changed: 75 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,21 @@ <h1 class="title">Module <code>nitric.api.events</code></h1>
4444
# See the License for the specific language governing permissions and
4545
# limitations under the License.
4646
#
47+
from __future__ import annotations
48+
4749
from typing import List, Union
50+
51+
from grpclib import GRPCError
52+
53+
from nitric.api.exception import exception_from_grpc_error
4854
from nitric.utils import new_default_channel, _struct_from_dict
49-
from nitric.proto.nitric.event.v1 import EventStub, NitricEvent, TopicStub
55+
from nitricapi.nitric.event.v1 import EventServiceStub, NitricEvent, TopicServiceStub
5056
from dataclasses import dataclass, field
5157

5258

5359
@dataclass(frozen=True, order=True)
5460
class Event(object):
55-
&#34;&#34;&#34;Represents a NitricEvent.&#34;&#34;&#34;
61+
&#34;&#34;&#34;Eventing client, providing access to Topic and Event references and operations on those entities.&#34;&#34;&#34;
5662

5763
payload: dict = field(default_factory=dict)
5864
id: str = field(default=None)
@@ -71,7 +77,7 @@ <h1 class="title">Module <code>nitric.api.events</code></h1>
7177
class Topic(object):
7278
&#34;&#34;&#34;A reference to a topic on an event service, used to perform operations on that topic.&#34;&#34;&#34;
7379

74-
_stub: EventStub
80+
_events: Events
7581
name: str
7682

7783
async def publish(
@@ -91,11 +97,14 @@ <h1 class="title">Module <code>nitric.api.events</code></h1>
9197
# TODO: handle events that are just a payload
9298
event = Event(**event)
9399

94-
response = await self._stub.publish(topic=self.name, event=_event_to_wire(event))
95-
return Event(**{**event.__dict__.copy(), **{&#34;id&#34;: response.id}})
100+
try:
101+
response = await self._events._stub.publish(topic=self.name, event=_event_to_wire(event))
102+
return Event(**{**event.__dict__.copy(), **{&#34;id&#34;: response.id}})
103+
except GRPCError as grpc_err:
104+
raise exception_from_grpc_error(grpc_err)
96105

97106

98-
class EventClient(object):
107+
class Events(object):
99108
&#34;&#34;&#34;
100109
Nitric generic publish/subscribe event client.
101110

@@ -104,18 +113,26 @@ <h1 class="title">Module <code>nitric.api.events</code></h1>
104113

105114
def __init__(self):
106115
&#34;&#34;&#34;Construct a Nitric Event Client.&#34;&#34;&#34;
107-
channel = new_default_channel()
108-
self._stub = EventStub(channel=channel)
109-
self._topic_stub = TopicStub(channel=channel)
116+
self.channel = new_default_channel()
117+
self._stub = EventServiceStub(channel=self.channel)
118+
self._topic_stub = TopicServiceStub(channel=self.channel)
119+
120+
def __del__(self):
121+
# close the channel when this client is destroyed
122+
if self.channel is not None:
123+
self.channel.close()
110124

111125
async def topics(self) -&gt; List[Topic]:
112126
&#34;&#34;&#34;Get a list of topics available for publishing or subscription.&#34;&#34;&#34;
113-
response = await self._topic_stub.list()
114-
return [self.topic(topic.name) for topic in response.topics]
127+
try:
128+
response = await self._topic_stub.list()
129+
return [self.topic(topic.name) for topic in response.topics]
130+
except GRPCError as grpc_err:
131+
raise exception_from_grpc_error(grpc_err)
115132

116133
def topic(self, name: str) -&gt; Topic:
117-
&#34;&#34;&#34;Return a reference a topic from the connected event service.&#34;&#34;&#34;
118-
return Topic(_stub=self._stub, name=name)</code></pre>
134+
&#34;&#34;&#34;Return a reference to a topic.&#34;&#34;&#34;
135+
return Topic(_events=self, name=name)</code></pre>
119136
</details>
120137
</section>
121138
<section>
@@ -132,13 +149,13 @@ <h2 class="section-title" id="header-classes">Classes</h2>
132149
<span>(</span><span>payload: dict = &lt;factory&gt;, id: str = None, payload_type: str = None)</span>
133150
</code></dt>
134151
<dd>
135-
<div class="desc"><p>Represents a NitricEvent.</p></div>
152+
<div class="desc"><p>Eventing client, providing access to Topic and Event references and operations on those entities.</p></div>
136153
<details class="source">
137154
<summary>
138155
<span>Expand source code</span>
139156
</summary>
140157
<pre><code class="python">class Event(object):
141-
&#34;&#34;&#34;Represents a NitricEvent.&#34;&#34;&#34;
158+
&#34;&#34;&#34;Eventing client, providing access to Topic and Event references and operations on those entities.&#34;&#34;&#34;
142159

143160
payload: dict = field(default_factory=dict)
144161
id: str = field(default=None)
@@ -160,8 +177,8 @@ <h3>Class variables</h3>
160177
</dd>
161178
</dl>
162179
</dd>
163-
<dt id="nitric.api.events.EventClient"><code class="flex name class">
164-
<span>class <span class="ident">EventClient</span></span>
180+
<dt id="nitric.api.events.Events"><code class="flex name class">
181+
<span>class <span class="ident">Events</span></span>
165182
</code></dt>
166183
<dd>
167184
<div class="desc"><p>Nitric generic publish/subscribe event client.</p>
@@ -171,11 +188,7 @@ <h3>Class variables</h3>
171188
<summary>
172189
<span>Expand source code</span>
173190
</summary>
174-
<<<<<<< refs/remotes/origin/main:docs/nitric/api/models.html
175-
<pre><code class="python">class FailedTask(Task):
176-
&#34;&#34;&#34;Represents a failed queue publish for an event.&#34;&#34;&#34;
177-
=======
178-
<pre><code class="python">class EventClient(object):
191+
<pre><code class="python">class Events(object):
179192
&#34;&#34;&#34;
180193
Nitric generic publish/subscribe event client.
181194

@@ -184,37 +197,44 @@ <h3>Class variables</h3>
184197

185198
def __init__(self):
186199
&#34;&#34;&#34;Construct a Nitric Event Client.&#34;&#34;&#34;
187-
channel = new_default_channel()
188-
self._stub = EventStub(channel=channel)
189-
self._topic_stub = TopicStub(channel=channel)
190-
>>>>>>> feat: port faas.start to bi-di streaming with membrane:docs/nitric/api/events.html
200+
self.channel = new_default_channel()
201+
self._stub = EventServiceStub(channel=self.channel)
202+
self._topic_stub = TopicServiceStub(channel=self.channel)
203+
204+
def __del__(self):
205+
# close the channel when this client is destroyed
206+
if self.channel is not None:
207+
self.channel.close()
191208

192209
async def topics(self) -&gt; List[Topic]:
193210
&#34;&#34;&#34;Get a list of topics available for publishing or subscription.&#34;&#34;&#34;
194-
response = await self._topic_stub.list()
195-
return [self.topic(topic.name) for topic in response.topics]
211+
try:
212+
response = await self._topic_stub.list()
213+
return [self.topic(topic.name) for topic in response.topics]
214+
except GRPCError as grpc_err:
215+
raise exception_from_grpc_error(grpc_err)
196216

197217
def topic(self, name: str) -&gt; Topic:
198-
&#34;&#34;&#34;Return a reference a topic from the connected event service.&#34;&#34;&#34;
199-
return Topic(_stub=self._stub, name=name)</code></pre>
218+
&#34;&#34;&#34;Return a reference to a topic.&#34;&#34;&#34;
219+
return Topic(_events=self, name=name)</code></pre>
200220
</details>
201221
<h3>Methods</h3>
202222
<dl>
203-
<dt id="nitric.api.events.EventClient.topic"><code class="name flex">
223+
<dt id="nitric.api.events.Events.topic"><code class="name flex">
204224
<span>def <span class="ident">topic</span></span>(<span>self, name: str) ‑> <a title="nitric.api.events.Topic" href="#nitric.api.events.Topic">Topic</a></span>
205225
</code></dt>
206226
<dd>
207-
<div class="desc"><p>Return a reference a topic from the connected event service.</p></div>
227+
<div class="desc"><p>Return a reference to a topic.</p></div>
208228
<details class="source">
209229
<summary>
210230
<span>Expand source code</span>
211231
</summary>
212232
<pre><code class="python">def topic(self, name: str) -&gt; Topic:
213-
&#34;&#34;&#34;Return a reference a topic from the connected event service.&#34;&#34;&#34;
214-
return Topic(_stub=self._stub, name=name)</code></pre>
233+
&#34;&#34;&#34;Return a reference to a topic.&#34;&#34;&#34;
234+
return Topic(_events=self, name=name)</code></pre>
215235
</details>
216236
</dd>
217-
<dt id="nitric.api.events.EventClient.topics"><code class="name flex">
237+
<dt id="nitric.api.events.Events.topics"><code class="name flex">
218238
<span>async def <span class="ident">topics</span></span>(<span>self) ‑> List[<a title="nitric.api.events.Topic" href="#nitric.api.events.Topic">Topic</a>]</span>
219239
</code></dt>
220240
<dd>
@@ -225,30 +245,29 @@ <h3>Methods</h3>
225245
</summary>
226246
<pre><code class="python">async def topics(self) -&gt; List[Topic]:
227247
&#34;&#34;&#34;Get a list of topics available for publishing or subscription.&#34;&#34;&#34;
228-
response = await self._topic_stub.list()
229-
return [self.topic(topic.name) for topic in response.topics]</code></pre>
248+
try:
249+
response = await self._topic_stub.list()
250+
return [self.topic(topic.name) for topic in response.topics]
251+
except GRPCError as grpc_err:
252+
raise exception_from_grpc_error(grpc_err)</code></pre>
230253
</details>
231254
</dd>
232255
</dl>
233256
</dd>
234257
<dt id="nitric.api.events.Topic"><code class="flex name class">
235258
<span>class <span class="ident">Topic</span></span>
236-
<span>(</span><span>_stub<a title="nitric.proto.nitric.event.v1.EventStub" href="../proto/nitric/event/v1/index.html#nitric.proto.nitric.event.v1.EventStub">EventStub</a>, name: str)</span>
259+
<span>(</span><span>_events<a title="nitric.api.events.Events" href="#nitric.api.events.Events">Events</a>, name: str)</span>
237260
</code></dt>
238261
<dd>
239262
<div class="desc"><p>A reference to a topic on an event service, used to perform operations on that topic.</p></div>
240263
<details class="source">
241264
<summary>
242265
<span>Expand source code</span>
243266
</summary>
244-
<<<<<<< refs/remotes/origin/main:docs/nitric/api/models.html
245-
<pre><code class="python">class Task(object):
246-
&#34;&#34;&#34;Represents a NitricTask.&#34;&#34;&#34;
247-
=======
248267
<pre><code class="python">class Topic(object):
249268
&#34;&#34;&#34;A reference to a topic on an event service, used to perform operations on that topic.&#34;&#34;&#34;
250269

251-
_stub: EventStub
270+
_events: Events
252271
name: str
253272

254273
async def publish(
@@ -267,10 +286,12 @@ <h3>Methods</h3>
267286
if isinstance(event, dict):
268287
# TODO: handle events that are just a payload
269288
event = Event(**event)
270-
>>>>>>> feat: port faas.start to bi-di streaming with membrane:docs/nitric/api/events.html
271289

272-
response = await self._stub.publish(topic=self.name, event=_event_to_wire(event))
273-
return Event(**{**event.__dict__.copy(), **{&#34;id&#34;: response.id}})</code></pre>
290+
try:
291+
response = await self._events._stub.publish(topic=self.name, event=_event_to_wire(event))
292+
return Event(**{**event.__dict__.copy(), **{&#34;id&#34;: response.id}})
293+
except GRPCError as grpc_err:
294+
raise exception_from_grpc_error(grpc_err)</code></pre>
274295
</details>
275296
<h3>Class variables</h3>
276297
<dl>
@@ -292,10 +313,6 @@ <h3>Methods</h3>
292313
<summary>
293314
<span>Expand source code</span>
294315
</summary>
295-
<<<<<<< refs/remotes/origin/main:docs/nitric/api/models.html
296-
<pre><code class="python">class Topic(object):
297-
&#34;&#34;&#34;Represents event topic metadata.&#34;&#34;&#34;
298-
=======
299316
<pre><code class="python">async def publish(
300317
self,
301318
event: Union[Event, dict] = None,
@@ -312,10 +329,12 @@ <h3>Methods</h3>
312329
if isinstance(event, dict):
313330
# TODO: handle events that are just a payload
314331
event = Event(**event)
315-
>>>>>>> feat: port faas.start to bi-di streaming with membrane:docs/nitric/api/events.html
316332

317-
response = await self._stub.publish(topic=self.name, event=_event_to_wire(event))
318-
return Event(**{**event.__dict__.copy(), **{&#34;id&#34;: response.id}})</code></pre>
333+
try:
334+
response = await self._events._stub.publish(topic=self.name, event=_event_to_wire(event))
335+
return Event(**{**event.__dict__.copy(), **{&#34;id&#34;: response.id}})
336+
except GRPCError as grpc_err:
337+
raise exception_from_grpc_error(grpc_err)</code></pre>
319338
</details>
320339
</dd>
321340
</dl>
@@ -345,10 +364,10 @@ <h4><code><a title="nitric.api.events.Event" href="#nitric.api.events.Event">Eve
345364
</ul>
346365
</li>
347366
<li>
348-
<h4><code><a title="nitric.api.events.EventClient" href="#nitric.api.events.EventClient">EventClient</a></code></h4>
367+
<h4><code><a title="nitric.api.events.Events" href="#nitric.api.events.Events">Events</a></code></h4>
349368
<ul class="">
350-
<li><code><a title="nitric.api.events.EventClient.topic" href="#nitric.api.events.EventClient.topic">topic</a></code></li>
351-
<li><code><a title="nitric.api.events.EventClient.topics" href="#nitric.api.events.EventClient.topics">topics</a></code></li>
369+
<li><code><a title="nitric.api.events.Events.topic" href="#nitric.api.events.Events.topic">topic</a></code></li>
370+
<li><code><a title="nitric.api.events.Events.topics" href="#nitric.api.events.Events.topics">topics</a></code></li>
352371
</ul>
353372
</li>
354373
<li>

0 commit comments

Comments
 (0)