Skip to content

Commit 042f4eb

Browse files
committed
Documentation is unavailable on the internet
Problem: Documentation is auto-generated but is unavailable on the internet. Solution: Add action to publishing step that pushes the docs to a gh-pages branch. On release the docs are published. Signed-off-by: Paul Hewlett <phewlett76@gmail.com>
1 parent 7559b07 commit 042f4eb

30 files changed

Lines changed: 215 additions & 202 deletions

.github/workflows/python-docs.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
# only used for testing publication step...
5+
#name: Test docs publishing
6+
#
7+
#on: push
8+
#
9+
#jobs:
10+
# deploy:
11+
#
12+
# runs-on: ubuntu-latest
13+
#
14+
# steps:
15+
# - uses: actions/checkout@v2
16+
# - name: Set up Python
17+
# uses: actions/setup-python@v2
18+
# with:
19+
# python-version: '3.x'
20+
# - name: Install dependencies
21+
# run: |
22+
# python -m pip install --upgrade pip
23+
# pip install setuptools wheel
24+
# ./scripts/version.sh
25+
# - name: Build docs
26+
# uses: ammaraskar/sphinx-action@master
27+
# with:
28+
# docs-folder: "docs/"
29+
# - name: Publish docs
30+
# uses: peaceiris/actions-gh-pages@v3
31+
# with:
32+
# github_token: ${{ secrets.GITHUB_TOKEN }}
33+
# publish_dir: "./docs/_build/html"

.github/workflows/python-publish.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,12 @@ jobs:
3030
./scripts/version.sh
3131
python setup.py sdist bdist_wheel
3232
twine upload dist/*
33+
- name: Build docs
34+
uses: ammaraskar/sphinx-action@master
35+
with:
36+
docs-folder: "docs/"
37+
- name: Publish docs
38+
uses: peaceiris/actions-gh-pages@v3
39+
with:
40+
github_token: ${{ secrets.GITHUB_TOKEN }}
41+
publish_dir: "./docs/_build/html"

README.md renamed to DEVELOPMENT.md

Lines changed: 1 addition & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,3 @@
1-
# Jitsuin Archivist Client
2-
3-
The standard Jitsuin Archivist python client.
4-
5-
Please note that the canonical API for Jitsuin Archivist is always the REST API
6-
documented at https://docs.jitsuin.com
7-
8-
# Installation
9-
10-
Use standard python pip utility:
11-
12-
```bash
13-
python3 -m pip install jitsuin-archivist
14-
```
15-
16-
One can then use the examples code to create assets (see examples directory):
17-
18-
```python
19-
from archivist.archivist import Archivist
20-
from archivist.errors import ArchivistError
21-
22-
# Oauth2 token that grants access
23-
with open(".auth_token", mode='r') as tokenfile:
24-
authtoken = tokenfile.read().strip()
25-
26-
# Initialize connection to Archivist - the URL for production will be different to this URL
27-
arch = Archivist(
28-
"https://rkvst.poc.jitsuin.io",
29-
auth=authtoken,
30-
)
31-
32-
# Create a new asset
33-
attrs = {
34-
"arc_display_name": "display_name", # Asset's display name in the user interface
35-
"arc_description": "display_description", # Asset's description in the user interface
36-
"arc_display_type": "desplay_type", # Arc_display_type is a free text field
37-
# allowing the creator of
38-
# an asset to specify the asset
39-
# type or class. Be careful when setting this:
40-
# assets are grouped by type and
41-
# sharing policies can be
42-
# configured to share assets based on
43-
# their arc_display_type.
44-
# So a mistake here can result in asset data being
45-
# under- or over-shared.
46-
"some_custom_attribute": "value" # You can add any custom value as long as
47-
# it does not start with arc_
48-
}
49-
behaviours = ["Attachments", "RecordEvidence"]
50-
51-
# The first argument is the behaviours of the asset
52-
# The second argument is the attributes of the asset
53-
# The third argument is wait for confirmation:
54-
# If @confirm@ is True then this function will not
55-
# return until the asset is confirmed on the blockchain and ready
56-
# to accept events (or an error occurs)
57-
# After an asset is submitted to the blockchain (submitted),
58-
# it will be in the "Pending" status.
59-
# Once it is added to the blockchain, the status will be changed to "Confirmed"
60-
try:
61-
asset = arch.assets.create(behaviours, attrs=attrs, confirm=True)
62-
except Archivisterror as ex:
63-
print("error", ex)
64-
else:
65-
print("asset", asset)
66-
67-
```
68-
69-
## Logging
70-
71-
Follows the Django model as described here: https://docs.djangoproject.com/en/3.2/topics/logging/
72-
73-
The base logger for this pacakage is rooted at "archivist" with subloggers for each endpoint:
74-
75-
- "archivist.archivist"
76-
- "archivist.assets"
77-
- ...
78-
79-
etc. etc.
80-
81-
Logging is configured by either defining a root logger with suitable handlers, formatters etc. or
82-
by using dictionary configuration as described here: https://docs.python.org/3/library/logging.config.html#logging-config-dictschema
83-
84-
A recommended minimum configuration would be:
85-
86-
```python
87-
import logging
88-
89-
logging.dictConfig({
90-
"version": 1,
91-
"disable_existing_loggers": False,
92-
"handlers": {
93-
"console": {
94-
"class": "logging.StreamHandler",
95-
},
96-
},
97-
"root": {
98-
"handlers": ["console"],
99-
"level": "INFO",
100-
},
101-
})
102-
```
103-
1041
# Development
1052

1063
## Pre-requisites
@@ -221,7 +118,7 @@ they be run in a production environment.
221118
Set 2 environment variables and execute:
222119

223120
```bash
224-
export TEST_ARCHIVIST="https://rkvst.poc.jitsuin.io"
121+
export TEST_ARCHIVIST="https://app.rkvst.io"
225122
export TEST_AUTHTOKEN_FILENAME=credentials/authtoken
226123
task functests
227124
```

README.rst

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
.. _readme:
2+
3+
Jitsuin Archivist Client
4+
=========================
5+
6+
The standard Jitsuin Archivist python client.
7+
8+
Please note that the canonical API for Jitsuin Archivist is always the REST API
9+
documented at https://docs.rkvst.com
10+
11+
Installation
12+
=============
13+
14+
Use standard python pip utility:
15+
16+
.. code-block:: bash
17+
18+
python3 -m pip install jitsuin-archivist
19+
20+
Example
21+
=============
22+
23+
One can then use the examples code to create assets (see examples directory):
24+
25+
.. code-block:: python
26+
27+
from archivist.archivist import Archivist
28+
from archivist.errors import ArchivistError
29+
30+
# Oauth2 token that grants access
31+
with open(".auth_token", mode='r') as tokenfile:
32+
authtoken = tokenfile.read().strip()
33+
34+
# Initialize connection to Archivist - the URL for production will be different to this URL
35+
arch = Archivist(
36+
"https://app.rkvst.io",
37+
auth=authtoken,
38+
)
39+
40+
# Create a new asset
41+
attrs = {
42+
"arc_display_name": "display_name", # Asset's display name in the user interface
43+
"arc_description": "display_description", # Asset's description in the user interface
44+
"arc_display_type": "desplay_type", # Arc_display_type is a free text field
45+
# allowing the creator of
46+
# an asset to specify the asset
47+
# type or class. Be careful when setting this:
48+
# assets are grouped by type and
49+
# sharing policies can be
50+
# configured to share assets based on
51+
# their arc_display_type.
52+
# So a mistake here can result in asset data being
53+
# under- or over-shared.
54+
"some_custom_attribute": "value" # You can add any custom value as long as
55+
# it does not start with arc_
56+
}
57+
behaviours = ["Attachments", "RecordEvidence"]
58+
59+
# The first argument is the behaviours of the asset
60+
# The second argument is the attributes of the asset
61+
# The third argument is wait for confirmation:
62+
# If @confirm@ is True then this function will not
63+
# return until the asset is confirmed on the blockchain and ready
64+
# to accept events (or an error occurs)
65+
# After an asset is submitted to the blockchain (submitted),
66+
# it will be in the "Pending" status.
67+
# Once it is added to the blockchain, the status will be changed to "Confirmed"
68+
try:
69+
asset = arch.assets.create(behaviours, attrs=attrs, confirm=True)
70+
except Archivisterror as ex:
71+
print("error", ex)
72+
else:
73+
print("asset", asset)
74+
75+
76+
Logging
77+
========
78+
79+
Follows the Django model as described here: https://docs.djangoproject.com/en/3.2/topics/logging/
80+
81+
The base logger for this package is rooted at "archivist" with subloggers for each endpoint:
82+
83+
.. note::
84+
archivist.archivist
85+
sublogger for archivist submodule
86+
87+
archivist.assets
88+
sublogger for assets submodule
89+
90+
and for other endpoints.
91+
92+
Logging is configured by either defining a root logger with suitable handlers, formatters etc. or
93+
by using dictionary configuration as described here: https://docs.python.org/3/library/logging.config.html#logging-config-dictschema
94+
95+
A recommended minimum configuration would be:
96+
97+
.. code-block:: python
98+
99+
import logging
100+
101+
logging.dictConfig({
102+
"version": 1,
103+
"disable_existing_loggers": False,
104+
"handlers": {
105+
"console": {
106+
"class": "logging.StreamHandler",
107+
},
108+
},
109+
"root": {
110+
"handlers": ["console"],
111+
"level": "INFO",
112+
},
113+
})
114+

Taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ tasks:
4747
desc: Create sphinx documentation
4848
deps: [about]
4949
cmds:
50-
- ./scripts/builder.sh /bin/bash -c "cd docs && make html"
50+
- ./scripts/builder.sh /bin/bash -c "cd docs && make clean && make html"
5151

5252
format:
5353
desc: Format code using black

archivist/access_policies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515
# Initialize connection to Archivist
1616
arch = Archivist(
17-
"https://rkvst.poc.jitsuin.io",
17+
"https://app.rkvst.io",
1818
auth=authtoken,
1919
)
2020
access_policy = arch.access_policies.create(...)

archivist/archivist.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
IAM subjects and IAM access policies.
1212
1313
Instantiation of this class encapsulates the URL and authentication
14-
parameters:
14+
parameters (the max_time paramater is optional):
1515
1616
.. code-block:: python
1717
@@ -20,8 +20,9 @@
2020
2121
# Initialize connection to Archivist
2222
arch = Archivist(
23-
"https://rkvst.poc.jitsuin.io",
23+
"https://app.rkvst.io",
2424
auth=authtoken,
25+
max_time=1200,
2526
)
2627
2728
The arch variable now has additional endpoints assets,events,locations,
@@ -415,8 +416,13 @@ def __list(self, path, args, *, headers=None) -> Response:
415416

416417
def last_response(self, *, responses: int = 1) -> List[Response]:
417418
"""Returns the requested number of response objects from the response ring buffer
418-
args:
419+
420+
Args:
419421
responses (int): Number of responses to be returned in a list
422+
423+
Returns:
424+
list of responses.
425+
420426
"""
421427

422428
return list(self._response_ring_buffer)[:responses]

archivist/assets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515
# Initialize connection to Archivist
1616
arch = Archivist(
17-
"https://rkvst.poc.jitsuin.io",
17+
"https://app.rkvst.io",
1818
auth=authtoken,
1919
)
2020
asset = arch.assets.create(...)

archivist/attachments.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515
# Initialize connection to Archivist
1616
arch = Archivist(
17-
"https://rkvst.poc.jitsuin.io",
17+
"https://app.rkvst.io",
1818
auth=authtoken,
1919
)
2020
with open("something.jpg") as fd:

archivist/events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515
# Initialize connection to Archivist
1616
arch = Archivist(
17-
"https://rkvst.poc.jitsuin.io",
17+
"https://app.rkvst.io",
1818
auth=authtoken,
1919
)
2020
asset = arch.assets.create(...)

0 commit comments

Comments
 (0)