Skip to content

Commit 88ec659

Browse files
JasperB-TeamBluedupondje
authored andcommitted
ci: updated build to work with most recent pdoc version
Documentation updated so that it builds properly with most recent pdoc version. Alterations made: - Links now work - codeblocks updated - full documentation now renders Signed-off-by: Jasper Berton <[email protected]>
1 parent 925f92b commit 88ec659

File tree

9 files changed

+9049
-5146
lines changed

9 files changed

+9049
-5146
lines changed

Diff for: .github/workflows/build.yaml

+13-20
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
- name: centos-stream-9
2222
shortcut: c9s
2323
container-name: el9stream
24+
pip-command: pip3
2425

2526
name: ${{ matrix.name }}
2627

@@ -86,15 +87,15 @@ jobs:
8687
ref: 'gh-pages'
8788

8889
generate_documentation:
89-
runs-on: ubuntu-20.04
90+
runs-on: ubuntu-latest
9091
steps:
9192
- name: Install Dependencies
9293
# This step installs dependencies for python-sdk and pdoc
9394
run: |
9495
sudo apt update &&
9596
sudo apt install -y git \
96-
python2 \
97-
python2-dev \
97+
python3 \
98+
python3-dev \
9899
curl \
99100
asciidoctor \
100101
gcc \
@@ -109,34 +110,26 @@ jobs:
109110
- name: Checkout sources
110111
uses: actions/checkout@v4
111112

112-
- name: Install pip2.7
113-
# This step installs pip2.7, which will be needed later
114-
run: |
115-
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
116-
python2 get-pip.py
117-
118-
- name: Install Python-SDK with Python 2.7
113+
- name: Install Python-SDK with Python 3
119114
# This step installs the python-sdk with python2.7, as the extension of pdoc,
120115
# which is subsequently installed, doesn't have python3 support.
121116
run: |
122-
pip2.7 install setuptools
117+
pip install setuptools
123118
bash .automation/generate-setup-files.sh
124-
python2.7 setup.py install --user --prefix=
119+
python3 setup.py install --user --prefix=
125120
shell: bash
126121

127122
- name: Install Pdoc
128123
# This steps installs an extension of pdoc which supports asciidoc
129124
# (this extension runs on python2).
130125
run: |
131-
git clone https://github.com/machacekondra/pdoc
132-
cd pdoc
133-
pip2.7 install -U .
126+
pip install pdoc
134127
135128
- name: Install pygments
136-
run: pip2.7 install pygments
129+
run: pip install pygments
137130

138131
- name: Generate documentation
139-
run: pdoc ovirtsdk4 --html --html-dir=html
132+
run: pdoc ovirtsdk4 -o ./${{ env.GEN_DOC_DIR }} -t pdoc
140133

141134
- name: Upload generated documentation artifacts
142135
uses: actions/upload-artifact@v4
@@ -157,7 +150,7 @@ jobs:
157150
uses: actions/download-artifact@v4
158151
with:
159152
name: generated-documentation
160-
path: ${{ env.GEN_DOC_DIR }}
153+
path: ${{ env.GEN_DOC_DIR }}/
161154

162155
- name: Install package dependencies
163156
run: |
@@ -197,8 +190,8 @@ jobs:
197190
198191
- name: Move created documentation to gh-pages
199192
run: |
200-
mkdir -p ./ovirt-engine-sdk/${{env.FOLDER}}/
201-
cp ./html/ovirtsdk4/* ./ovirt-engine-sdk/${{env.FOLDER}}/
193+
mkdir -p ./ovirt-engine-sdk/${{ env.FOLDER }}/
194+
cp -r ./${{ env.GEN_DOC_DIR }}/* ./ovirt-engine-sdk/${{ env.FOLDER }}/
202195
203196
- name: Push changes to gh-pages
204197
run: |

Diff for: lib/ovirtsdk4/__init__.py

+69-48
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@
3131
from urllib import urlencode
3232
from urlparse import urlparse
3333

34-
from ovirtsdk4 import version
3534
from ovirtsdk4.http import Response
3635

36+
def get_version():
37+
from ovirtsdk4 import version
38+
return version.VERSION
3739

3840
class Error(Exception):
3941
"""
@@ -44,20 +46,22 @@ class Error(Exception):
4446
def __init__(self, message, code=None, fault=None):
4547
"""
4648
Creates an instance of Error class.
47-
48-
`message`:: The exception message.
49-
50-
`code`:: An error code associated to the error. For HTTP related
51-
errors, this will be the HTTP response code returned by the server.
52-
For example, if retrieving of a virtual machine fails because it
53-
doesn't exist this attribute will contain the integer value 404. Note
54-
that this may be `nil` if the error is not HTTP related.
55-
56-
`fault`:: The `Fault` object associated to the error.
5749
"""
5850
super(Error, self).__init__(message)
51+
"""
52+
Creates an instance of Error class.
53+
"""
5954
self.code = code
55+
"""
56+
An error code associated to the error. For HTTP related
57+
errors, this will be the HTTP response code returned by the server.
58+
For example, if retrieving of a virtual machine fails because it
59+
doesn't exist this attribute will contain the integer value 404. Note
60+
that this may be `nil` if the error is not HTTP related."""
6061
self.fault = fault
62+
"""
63+
The `Fault` object associated to the error.
64+
"""
6165

6266

6367
class AuthError(Error):
@@ -230,70 +234,87 @@ def __init__(
230234
231235
This method supports the following parameters:
232236
233-
`url`:: A string containing the base URL of the server, usually
237+
`url` \n
238+
A string containing the base URL of the server, usually
234239
something like `https://server.example.com/ovirt-engine/api`.
235240
236-
`username`:: The name of the user, something like `admin@internal`.
241+
`username` \n
242+
The name of the user, something like `admin@internal`.
237243
238-
`password`:: The name password of the user.
244+
`password` \n
245+
The name password of the user.
239246
240-
`token`:: : The token to be used to access API. Optionally, user can
247+
`token` \n
248+
The token to be used to access API. Optionally, user can
241249
use token, instead of username and password to access API. If user
242250
don't specify `token` parameter, SDK will automatically create one.
243251
244-
`insecure`:: A boolean flag that indicates if the server TLS
252+
`insecure` \n
253+
A boolean flag that indicates if the server TLS
245254
certificate and host name should be checked.
246255
247-
`ca_file`:: A PEM file containing the trusted CA certificates. The
256+
`ca_file` \n
257+
A PEM file containing the trusted CA certificates. The
248258
certificate presented by the server will be verified using these CA
249259
certificates. If `ca_file` parameter is not set, system wide
250260
CA certificate store is used.
251261
252-
`debug`:: A boolean flag indicating if debug output should be
262+
`debug` \n
263+
A boolean flag indicating if debug output should be
253264
generated. If the value is `True` and the `log` parameter isn't
254265
`None` then the data sent to and received from the server will
255266
be written to the log. Be aware that user names and passwords will
256267
also be written, so handle it with care.
257268
258-
`log`:: The logger where the log messages will be written.
269+
`log` \n
270+
The logger where the log messages will be written.
259271
260-
`kerberos`:: A boolean flag indicating if Kerberos
272+
`kerberos` \n
273+
A boolean flag indicating if Kerberos
261274
authentication should be used instead of the default basic
262275
authentication.
263276
264-
`timeout`:: The maximum total time to wait for the response, in
277+
`timeout` \n
278+
The maximum total time to wait for the response, in
265279
seconds. A value of zero (the default) means wait for ever. If
266280
the timeout expires before the response is received an exception
267281
will be raised.
268282
269-
`compress`:: A boolean flag indicating if the SDK should ask
283+
`compress` \n
284+
A boolean flag indicating if the SDK should ask
270285
the server to send compressed responses. The default is `True`.
271286
Note that this is a hint for the server, and that it may return
272287
uncompressed data even when this parameter is set to `True`.
273288
Note that compression will be disabled if user pass `debug`
274289
parameter set to `true`, so the debug messages are in plain text.
275290
276-
`sso_url`:: A string containing the base SSO URL of the serve.
291+
`sso_url` \n
292+
A string containing the base SSO URL of the serve.
277293
Default SSO url is computed from the `url` if no `sso_url` is provided.
278294
279-
`sso_revoke_url`:: A string containing the base URL of the SSO
295+
`sso_revoke_url` \n
296+
A string containing the base URL of the SSO
280297
revoke service. This needs to be specified only when using
281298
an external authentication service. By default this URL
282299
is automatically calculated from the value of the `url` parameter,
283300
so that SSO token revoke will be performed using the SSO service
284301
that is part of the engine.
285302
286-
`sso_token_name`:: The token name in the JSON SSO response returned
303+
`sso_token_name` \n
304+
The token name in the JSON SSO response returned
287305
from the SSO server. Default value is `access_token`.
288306
289-
`headers`:: A dictionary with headers which should be send with every
307+
`headers` \n
308+
A dictionary with headers which should be send with every
290309
request.
291310
292-
`connections`:: The maximum number of connections to open to the host.
311+
`connections` \n
312+
The maximum number of connections to open to the host.
293313
If the value is `0` (the default) then the number of connections will
294314
be unlimited.
295315
296-
`pipeline`:: The maximum number of request to put in an HTTP pipeline
316+
`pipeline` \n
317+
The maximum number of request to put in an HTTP pipeline
297318
without waiting for the response. If the value is `0` (the default)
298319
then pipelining is disabled.
299320
"""
@@ -360,7 +381,8 @@ def send(self, request):
360381
361382
This method supports the following parameters.
362383
363-
`request`:: The Request object containing the details of the HTTP
384+
`request` \n
385+
The Request object containing the details of the HTTP
364386
request to send.
365387
366388
The returned value is a Request object containing the details of the
@@ -445,7 +467,7 @@ def __send(self, request):
445467
for header_name, header_value in headers_dict.items():
446468
header_lines.append('%s: %s' % (header_name, header_value))
447469

448-
header_lines.append('User-Agent: PythonSDK/%s' % version.VERSION)
470+
header_lines.append('User-Agent: PythonSDK/%s' % get_version())
449471
header_lines.append('Version: 4')
450472
header_lines.append('Content-Type: application/xml')
451473
header_lines.append('Accept: application/xml')
@@ -796,7 +818,7 @@ def close(self, logout=True):
796818
"""
797819
Releases the resources used by this connection.
798820
799-
`logout`:: A boolean, which specify if token should be revoked,
821+
`logout` A boolean, which specify if token should be revoked,
800822
and so user should be logged out.
801823
"""
802824

@@ -818,10 +840,10 @@ def _build_url(self, path='', query=None):
818840
819841
This method supports the following parameters:
820842
821-
`path`:: The path that will be added to the base URL. The default is an
843+
`path` The path that will be added to the base URL. The default is an
822844
empty string.
823845
824-
`query`:: A dictionary containing the query parameters to add to the
846+
`query` A dictionary containing the query parameters to add to the
825847
URL. The keys of the dictionary should be strings containing the names
826848
of the parameters, and the values should be strings containing the
827849
values.
@@ -841,7 +863,7 @@ def check_xml_content_type(self, response):
841863
XML then it does nothing. If it isn't XML then it raises an
842864
exception.
843865
844-
`response`:: The HTTP response to check.
866+
`response` The HTTP response to check.
845867
"""
846868
return self._check_content_type(
847869
self.__XML_CONTENT_TYPE_RE,
@@ -855,7 +877,7 @@ def check_json_content_type(self, response):
855877
JSON then it does nothing. If it isn't JSON then it raises an
856878
exception.
857879
858-
`response`:: The HTTP response to check.
880+
`response` The HTTP response to check.
859881
"""
860882
return self._check_content_type(
861883
self.__JSON_CONTENT_TYPE_RE,
@@ -868,10 +890,10 @@ def _check_content_type(self, expected_re, expected_name, headers):
868890
Checks the given content type and raises an exception if it isn't the
869891
expected one.
870892
871-
`expected_re`:: The regular expression used to check the expected
893+
`expected_re` The regular expression used to check the expected
872894
content type.
873-
`expected_name`:: The name of the expected content type.
874-
`headers`:: The HTTP headers to check.
895+
`expected_name` The name of the expected content type.
896+
`headers` The HTTP headers to check.
875897
"""
876898
content_type = self._get_header_value(headers, 'content-type')
877899
if expected_re.match(content_type) is None:
@@ -892,7 +914,7 @@ def _read_reponse(self, context):
892914
"""
893915
Read the response.
894916
895-
`context`:: tuple which contains cur easy, response body,
917+
`context` tuple which contains cur easy, response body,
896918
response headers, original request
897919
"""
898920
# Extract the response code and body:
@@ -935,8 +957,8 @@ def _get_header_value(self, headers, name):
935957
"""
936958
Return header value by its name.
937959
938-
`headers`:: list of headers
939-
`name`:: name of the header
960+
`headers` list of headers
961+
`name` name of the header
940962
"""
941963
return next(
942964
(h.split(':')[1].strip() for h in headers if h.lower().startswith(name)),
@@ -984,8 +1006,7 @@ class ConnectionBuilder(object):
9841006
equivalent to calling the constructor of the `Connection`
9851007
class. Typical use will be like this:
9861008
987-
[source,python]
988-
----
1009+
```python
9891010
# Create the builder once:
9901011
builder = ConnectionBuilder(
9911012
url='https://enginer40.example.com/ovirt-engine/api',
@@ -1001,7 +1022,7 @@ class ConnectionBuilder(object):
10011022
# Create and use a second connection:
10021023
with builder.build() as connection:
10031024
...
1004-
----
1025+
```
10051026
"""
10061027

10071028
def __init__(self, **kwargs):
@@ -1029,7 +1050,7 @@ def build(self):
10291050
# import ovirtsdk4 as sdk
10301051
# vm = sdk.types.Vm()
10311052
#
1032-
from ovirtsdk4 import readers # noqa: F401
1033-
from ovirtsdk4 import services # noqa: F401
1034-
from ovirtsdk4 import types # noqa: F401
1035-
from ovirtsdk4 import writers # noqa: F401
1053+
import ovirtsdk4.readers as readers # noqa: F401
1054+
import ovirtsdk4.writers as writers # noqa: F401
1055+
import ovirtsdk4.types as types # noqa: F401
1056+
import ovirtsdk4.services as services # noqa: F401

0 commit comments

Comments
 (0)