Skip to content

Commit a645bb2

Browse files
[DOCUMENTATION] Improved Documentation hopefully (- WIP #104 & #110 -)
Changes in file docs/CI.md: - Moved CI section to its own document Changes in file docs/FAQ.md: - Moved FAQ to its own document Changes in file docs/USAGE.md: - Moved CLI usage to a combined usage document - Moved alpha api usage examples to combined usage document Changes in file docs/requirements.txt: - documentation generator related dependencies Changes in file docs/toc.md: - improved TOC page a bit
1 parent 8242763 commit a645bb2

File tree

5 files changed

+190
-26
lines changed

5 files changed

+190
-26
lines changed

docs/CI.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# CI:
2+
3+
## Service providers
4+
***
5+
6+
Continuous integration testing is handled by github actions and the generous Circle-CI Service.
7+
8+
9+
## MATs
10+
***
11+
12+
Minimal acceptance testing is run across multiple versions of python to ensure stable behavior
13+
accross a wide range of environments. Feature development and non-security related bug fixes are
14+
done on development branches and then merged into the
15+
[default branch (master)](https://github.com/reactive-firewall/multicast/blob/master/) for further
16+
integration testing. This ensures the [stable](https://github.com/reactive-firewall/multicast/blob/stable/)
17+
branch remains acceptable for production use.
18+
19+
20+
## Testing
21+
***
22+
23+
You can find all of the testing code in the aptly named `tests/` directory.
24+
* Unit-testing is primarally done with the `unittest` framework.
25+
* Functional testing is done via additional checks, including an end-to-end check invoking an
26+
actual pair of processes to test that `SAY` and `RECV` indeed work together.
27+
28+
29+
## Dev dependancy Testing:
30+
***
31+
32+
### In a rush to get this module working? Then try using this with your own test:
33+
34+
```bash
35+
#cd /MY-AWSOME-DEV-PATH/multicast
36+
make clean ; # cleans up from any previous tests hopefully
37+
make test ; # runs the tests
38+
make clean ; # cleans up for next test
39+
```
40+
41+
#### Use PEP8 to check python code style? Great! Try this:
42+
43+
```bash
44+
make clean ; # cleans up from any previous tests hopefully
45+
make test-style ; # runs the tests
46+
make clean ; # cleans up for next test
47+
```
48+
49+
_draft_
50+
51+
---
52+
#### Copyright (c) 2021-2024, Mr. Walls
53+
[License - MIT](https://github.com/reactive-firewall/multicast/blob/stable/LICENSE.md)

docs/FAQ.md

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

33
## Frequently Asked Questions
44

5+
```{toctree}
6+
:maxdepth: 3
7+
8+
https://github.com/reactive-firewall/multicast/.github/CODE_OF_CONDUCT.md
9+
https://github.com/reactive-firewall/multicast/.github/CONTRIBUTING.md
10+
```
11+
512
### How do I get this running?
613

714
(assuming python3 is setup and installed)
@@ -55,7 +62,7 @@ python3 -m multicast SAY --mcast-group 224.1.1.2 --port 59595 --message "Hello W
5562
[Here is how it is tested right now](https://github.com/reactive-firewall/multicast/blob/cdd577549c0bf7c2bcf85d1b857c86135778a9ed/tests/test_usage.py#L251-L554)
5663

5764
```python3
58-
import mulicast as mulicast
65+
import multicast as multicast
5966
from multiprocessing import Process as Process
6067

6168
# setup some stuff
@@ -90,7 +97,7 @@ p.start()
9097
and elsewhere (like another function or even module) for the sender:
9198
```python3
9299

93-
# assuming already did 'import mulicast as mulicast'
100+
# assuming already did 'import multicast as multicast'
94101

95102
_fixture_SAY_args = [
96103
"""--port""", _fixture_PORT_arg,

docs/USAGE.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Usage
2+
3+
4+
## Basic library usage
5+
***
6+
7+
The API is in late alpha testing, and has not yet reached a beta (pre-release) stage.
8+
9+
Here is an example of usage (circa v1.4)
10+
11+
```python3
12+
import multicast as multicast
13+
from multiprocessing import Process as Process
14+
15+
# setup some stuff
16+
_fixture_PORT_arg = int(59595)
17+
_fixture_mcast_GRP_arg = """224.0.0.1""" # only use dotted notation for multicast group addresses
18+
_fixture_host_BIND_arg
19+
_fixture_HEAR_args = [
20+
"""--port""", _fixture_PORT_arg,
21+
"""--join-mcast-groups""", _fixture_mcast_GRP_arg,
22+
"""--bind-group""", _fixture_mcast_GRP_arg"
23+
]
24+
25+
# spwan a listening proc
26+
27+
def inputHandle()
28+
buffer_string = str("""""")
29+
buffer_string += multicast.recv.hearstep([_fixture_mcast_GRP_arg], _fixture_PORT_arg, _fixture_host_BIND_arg, _fixture_mcast_GRP_arg)
30+
return buffer_string
31+
32+
def printLoopStub(func):
33+
for i in range( 0, 5 ):
34+
print( str( func() ) )
35+
36+
p = Process(
37+
target=multicast.__main__.McastDispatch().doStep,
38+
name="HEAR", args=("HEAR", _fixture_HEAR_args,)
39+
)
40+
p.start()
41+
42+
# ... probably will return with nothing outside a handler function in a loop
43+
```
44+
and elsewhere (like another function or even module) for the sender:
45+
```python3
46+
47+
# assuming already did 'import multicast as multicast'
48+
49+
_fixture_SAY_args = [
50+
"""--port""", _fixture_PORT_arg,
51+
"""--mcast-group""", _fixture_mcast_GRP_arg,
52+
"""--message""", """'test message'"""
53+
]
54+
try:
55+
multicast.__main__.McastDispatch().doStep("SAY", _fixture_SAY_args)
56+
# Hint: use a loop to repeat or different arguments to varry message.
57+
except Exception:
58+
p.join()
59+
raise RuntimeException("multicast seems to have failed, blah, blah")
60+
61+
# clean up some stuff
62+
p.join() # if not already handled don't forget to join the process and other overhead
63+
didWork = (int(p.exitcode) <= int(0)) # if you use a loop and need to know the exit code
64+
65+
```
66+
#### Caveat: the above examples assume the reader is knowledgeable about general `IPC` theory and the standard python `multiprocessing` module and its use.
67+
68+
69+
70+
## CLI Usage
71+
***
72+
73+
The CLI is actually not the best way to use this kind of library so it should not be considered the full implementation. For testing/prototyping though it is quite convenient, thus I begin with it.
74+
75+
CLI should work like so:
76+
77+
```plain
78+
multicast (SAY|RECV|HEAR) [-h|--help] [--use-std] [--daemon] [--port PORT] [--iface IFACE] [--pipe|-m MESSAGE|--message MESSAGE] [--group BIND_GROUP] [--groups [JOIN_MCAST_GROUPS ...]]
79+
```
80+
81+
The commands are `SAY`, `RECV`, and `HEAR` for the CLI and are analogus to `send` listen/accept and echo functions of a 1-to-1 connection.
82+
83+
### `SAY`
84+
85+
The `SAY` command is used to send data messages via multicast datagrams.
86+
* Note: the `--daemon` flag has no effect on the `SAY` command.
87+
88+
### `RECV`
89+
90+
The `RECV` command is used to receive multicast datagrams by listening or "joining" a multicast group.
91+
* If the `--use-std` flag is set the output is printed to the standard-output
92+
* This command is purely for testing or interfacing with external components and not intended as a first-class API
93+
* Note: If the `--daemon` flag is used the process will loop after reporting each datagrams until canceled, it has no effect on the `RECV` command.
94+
95+
### `HEAR`
96+
97+
The `HEAR` command is used to send data acknowledged messages via "HEAR" messages echoing select received multicast datagrams.
98+
* While mostly a testing function it is possible to use `HEAR` as a proxy for other send/recv instances by using the `--daemon` flag
99+
* Note: this will use the same port for sends and receives and can lead to data loss if less than two groups are used.
100+
* If more than one group is used via the `--groups` flag then all but the bind group (via `--group`) will be echoed to the bind group.

docs/requirements.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@
1717
# time - builtin - PSF license
1818
# re - builtin - PSF license?
1919
# subprocess - PSF license
20-
# sphinx - BSD license
21-
sphinx>=5.2
22-
# sphinx - BSD license
23-
sphinx-autodoc2>=0.5
24-
# sphinx - BSD license
25-
myst-parser[linkify]>=4.0
26-
# sphinx - BSD license
27-
sphinxawesome-theme>=0.5.0
2820
# argparse - builtin - PSF license
2921
# socket - builtin - PSF license
3022
# struct - builtin - PSF license
@@ -45,3 +37,11 @@ wheel>=0.37.0
4537
pip>=19.0
4638
# build - MIT license
4739
# build>=0.5.1, !=1.0.3, !=0.6, !=0.6.1 !=1.1.0 !=1.2.0
40+
# sphinx - BSD license
41+
sphinx>=5.2
42+
# sphinx-autodoc2 - MIT license
43+
sphinx-autodoc2>=0.5.0
44+
# myst-parser - MIT license
45+
myst-parser[linkify]>=4.0.0
46+
# sphinxawesome-theme - MIT license
47+
sphinxawesome-theme>=0.5.0

docs/toc.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
11
# Welcome to Multicast' documentation!
22

3-
## Contents:
4-
5-
```{toctree}
6-
:maxdepth: 2
7-
apidocs/index
8-
/README.md
9-
/LICENSE.md
10-
:Name: Documentation
11-
/
12-
```
13-
14-
## Overview
15-
16-
```{autosummary}
17-
```
18-
193
## Quickstart:
204
**Welcome to the Multicast Python Library! Let's get you started quickly.**
215

@@ -55,6 +39,26 @@ apidocs/index
5539
**You're all set! Enjoy using Multicast for your projects.**
5640

5741

42+
43+
## Contents:
44+
45+
```{toctree}
46+
:maxdepth: 2
47+
:Name: Documentation
48+
apidocs/index
49+
/README.md
50+
/FAQ.md
51+
/CI.md
52+
/USAGE.md
53+
:Name: License
54+
/LICENSE.md
55+
```
56+
57+
## Overview
58+
59+
```{autosummary}
60+
```
61+
5862
---
5963
### Copyright (c) 2021-2024, Mr. Walls
6064

0 commit comments

Comments
 (0)