Skip to content

Commit 0ee7067

Browse files
committed
Update docs, format code etc.
1 parent 67d5664 commit 0ee7067

File tree

11 files changed

+106
-255
lines changed

11 files changed

+106
-255
lines changed

Makefile

+10-19
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,29 @@
1+
.PHONY: docs
2+
13
black:
24
black -l 90 mqtt_io
35

4-
packages: clean schema sdist wheel2 wheel3
5-
6-
sdist: schema
7-
python setup.py sdist
8-
9-
wheel3: schema
10-
python3 setup.py bdist_wheel
11-
126
clean:
13-
find pi_mqtt_gpio -type d -name __pycache__ -prune -exec rm -rf {} \;
7+
find mqtt_io -type d -name __pycache__ -prune -exec rm -rf {} \;
148
rm -rf dist .eggs .mypy_cache .pytest_cache *.egg-info
159

16-
upload: packages
17-
twine upload dist/*
18-
$(MAKE) clean
19-
2010
graphs:
2111
dot -Tsvg -O interrupt_handling.dot
2212
dot -Tsvg -O interrupt_callbacks.dot
2313

2414
coverage:
25-
coverage run --source "." --omit "mqtt_io/tests/*,mqtt_io/modules/*" -m behave mqtt_io/tests/features
15+
coverage run --source "." --omit "mqtt_io/tests/*,mqtt_io/modules/*" -m behave mqtt_io/tests/features -t ~skip
2616
coverage report -m
2717

28-
requirements:
29-
poetry export > requirements.txt
30-
echo "hbmqtt==0.9.6" >> requirements.txt
31-
3218
lint:
3319
pylint -d fixme mqtt_io
3420
mypy --show-error-codes --strict --no-warn-unused-ignores mqtt_io
3521

36-
publish:
22+
build:
3723
poetry build
24+
25+
publish: build
3826
poetry publish
27+
28+
docs:
29+
poetry run python docs/generate_docs.py

docs/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Unreleased
22
==========
3+
- Auto-reconnect to MQTT server on disconnection. #207 @fipwmaqzufheoxq92ebc
4+
5+
v2.1.8 - 2021-04-21
6+
===================
37
- Fix broken hcsr04 sensor that I (@flyte) broke when rewriting for v2.x. #211 @r00tat
48
- Fix inversion not taken into account when publishing initial digital output value. #203 @r00tat
59
- Fix #198 where Future wasn't created from the right thread. #205 @fipwmaqzufheoxq92ebc

docs/config/reference/mqtt/README.md

+28
Original file line numberDiff line numberDiff line change
@@ -415,3 +415,31 @@ Do not use this function in a real system. Setting value to true means there
415415
is no point using encryption.
416416

417417

418+
## reconnect_delay :id=mqtt-reconnect_delay
419+
420+
*mqtt*.**reconnect_delay**
421+
422+
Time in seconds to wait between reconnect attempts.
423+
424+
425+
```yaml
426+
Type: integer
427+
Required: False
428+
Default: 2
429+
```
430+
431+
## reconnect_count :id=mqtt-reconnect_count
432+
433+
*mqtt*.**reconnect_count**
434+
435+
Max number of retries of connections before giving up and exiting.
436+
-1 (the default) means infinite reconnects.
437+
The counter is reset when the connection is reestablished successfully.
438+
439+
440+
```yaml
441+
Type: integer
442+
Required: False
443+
Default: -1
444+
```
445+

docs/dev/modules/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def setup_module(self) -> None:
142142

143143
If a digital input is not configured as an [interrupt](config/interrupts.md) (or even [sometimes if it is](config/reference/digital_inputs/?id=digital_inputs-star-interrupt_for)), then a loop will be created which polls the pin's current value and publishes a `DigitalInputChangedEvent` event when it does. As part of the initialisation of each pin, a callback function to publish the new value on MQTT will be subscribed to this event.
144144

145-
[mqtt_io.server.MqttIo._init_digital_inputs](https://github.com/flyte/mqtt-io/blob/develop/mqtt_io/server.py#L343):
145+
[mqtt_io.server.MqttIo._init_digital_inputs](https://github.com/flyte/mqtt-io/blob/develop/mqtt_io/server.py#L344):
146146

147147
```python
148148
def _init_digital_inputs(self) -> None:

generate_docs.py renamed to docs/generate_docs.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515
from mqtt_io.types import ConfigType
1616

17-
THIS_DIR = pathlib.Path(__file__).parent.absolute()
18-
CONFIG_SCHEMA_PATH = join(THIS_DIR, "mqtt_io/config/config.schema.yml")
19-
README_TEMPLATE = join(THIS_DIR, "README.md.j2")
20-
MODULES_DIR = join(THIS_DIR, "mqtt_io/modules")
17+
WORKSPACE_DIR = pathlib.Path(__file__).parent.parent.absolute()
18+
CONFIG_SCHEMA_PATH = join(WORKSPACE_DIR, "mqtt_io/config/config.schema.yml")
19+
README_TEMPLATE = join(WORKSPACE_DIR, "README.md.j2")
20+
MODULES_DIR = join(WORKSPACE_DIR, "mqtt_io/modules")
2121

22-
DOCS_DIR = join(THIS_DIR, "docs")
22+
DOCS_DIR = join(WORKSPACE_DIR, "docs")
2323
SIDEBAR_TEMPLATE = join(DOCS_DIR, "_sidebar.md.j2")
2424
CONTENT_TEMPLATE = join(DOCS_DIR, "config/reference.md.j2")
2525
MODULES_DOC_TEMPLATE = join(DOCS_DIR, "dev/modules/README.md.j2")
@@ -138,7 +138,7 @@ def generate_readmes() -> None:
138138
with open(README_TEMPLATE) as readme_template_file:
139139
readme_template: Template = Template(readme_template_file.read())
140140

141-
with open(join(THIS_DIR, "README.md"), "w") as readme_file:
141+
with open(join(WORKSPACE_DIR, "README.md"), "w") as readme_file:
142142
readme_file.write(
143143
readme_template.render(dict(repo=True, supported_hardware=module_strings))
144144
)
@@ -151,7 +151,7 @@ def generate_readmes() -> None:
151151

152152
def generate_changelog() -> None:
153153
print("Copying changelog...")
154-
shutil.copyfile(join(THIS_DIR, "CHANGELOG.md"), join(DOCS_DIR, "CHANGELOG.md"))
154+
shutil.copyfile(join(WORKSPACE_DIR, "CHANGELOG.md"), join(DOCS_DIR, "CHANGELOG.md"))
155155

156156

157157
def document_gpio_module() -> None:
@@ -186,7 +186,7 @@ def get_source(module_path: str, xpath: str, title: str) -> str:
186186
module_filepath = pathlib.Path(module.__file__)
187187
src, attrib = module_source(module, xpath)[0]
188188
url = "https://github.com/flyte/mqtt-io/blob/develop/%s#L%s" % (
189-
module_filepath.relative_to(THIS_DIR),
189+
module_filepath.relative_to(WORKSPACE_DIR),
190190
attrib["lineno"],
191191
)
192192
return f"[{title}]({url}):\n\n```python\n{src.rstrip()}\n```"
@@ -197,7 +197,7 @@ def get_source_link(module_path: str, xpath: str, title: str) -> str:
197197
module_filepath = pathlib.Path(module.__file__)
198198
_, attrib = module_source(module, xpath)[0]
199199
url = "https://github.com/flyte/mqtt-io/blob/develop/%s#L%s" % (
200-
module_filepath.relative_to(THIS_DIR),
200+
module_filepath.relative_to(WORKSPACE_DIR),
201201
attrib["lineno"],
202202
)
203203
return f"[{title}]({url}):"

docs/schema.json

+20
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,26 @@
271271
"default": false
272272
}
273273
}
274+
},
275+
"reconnect_delay": {
276+
"meta": {
277+
"description": "Time in seconds to wait between reconnect attempts.\n",
278+
"title_id": "mqtt-reconnect_delay"
279+
},
280+
"type": "integer",
281+
"required": false,
282+
"default": 2,
283+
"min": 1
284+
},
285+
"reconnect_count": {
286+
"meta": {
287+
"description": "Max number of retries of connections before giving up and exiting.\n-1 (the default) means infinite reconnects.\nThe counter is reset when the connection is reestablished successfully.\n",
288+
"title_id": "mqtt-reconnect_count"
289+
},
290+
"type": "integer",
291+
"required": false,
292+
"default": -1,
293+
"min": -1
274294
}
275295
}
276296
},

mqtt_io/config/config.schema.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ mqtt:
261261
reconnect_count:
262262
meta:
263263
description: |
264-
Max number of retries of connections before giving up (and exiting).
264+
Max number of retries of connections before giving up and exiting.
265265
-1 (the default) means infinite reconnects.
266-
The counter is reset if a connection was established successfully.
266+
The counter is reset when the connection is reestablished successfully.
267267
type: integer
268268
required: no
269269
default: -1

mqtt_io/config/generate_docs.py

-194
This file was deleted.

0 commit comments

Comments
 (0)