Skip to content

Commit 724cdb9

Browse files
bors[bot]jwhonce
andauthored
Merge #87
87: Cleanup docstrings and generated html pages for API r=ashley-cui a=jwhonce * Overused Notes in docstrings. * Change Literal import to not mask which Literal is being used * Reduced number of warnings from sphinx-build * Fixed type hints for @properties Signed-off-by: Jhon Honce <[email protected]> Co-authored-by: Jhon Honce <[email protected]>
2 parents 499e985 + 3f9955d commit 724cdb9

33 files changed

+223
-260
lines changed

docs/source/_static/about.html

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

docs/source/conf.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@
3636
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3737
# ones.
3838
# isort: unique-list
39-
extensions = [
40-
'sphinx.ext.autodoc',
41-
'sphinx.ext.napoleon',
42-
'sphinx.ext.viewcode',
43-
]
39+
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon', 'sphinx.ext.viewcode']
4440

4541
# Add any paths that contain templates here, relative to this directory.
4642
templates_path = ['_templates']
4743

4844
# List of patterns, relative to source directory, that match files and
4945
# directories to ignore when looking for source files.
5046
# This pattern also affects html_static_path and html_extra_path.
51-
exclude_patterns = ['**/api_connection.py']
47+
# isort: unique-list
48+
exclude_patterns = [
49+
'podman.api.*rst',
50+
'podman.rst',
51+
]
5252

5353

5454
# -- Options for HTML output -------------------------------------------------
@@ -103,7 +103,7 @@
103103
napoleon_include_init_with_doc = False
104104
napoleon_include_private_with_doc = False
105105
napoleon_include_special_with_doc = False
106-
napoleon_use_admonition_for_examples = False
106+
napoleon_use_admonition_for_examples = True
107107
napoleon_use_admonition_for_notes = True
108108
napoleon_use_admonition_for_references = False
109109
napoleon_use_ivar = False

podman/api/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
def _api_version(release: str, significant: int = 3) -> str:
2323
"""Return API version removing any additional identifiers from the release version.
2424
25-
Notes:
26-
This is a simple lexicographical parsing, no semantics are applied, e.g. semver checking.
25+
This is a simple lexicographical parsing, no semantics are applied, e.g. semver checking.
2726
"""
2827
items = re.split(r"\.|-|\+", release)
2928
parts = items[0:significant]

podman/api/adapter_utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ def _key_normalizer(key_class: NamedTuple, request_context: Mapping) -> Mapping:
1010
key for an HTTPS request. If you wish to change this behaviour, provide
1111
alternate callables to ``key_fn_by_scheme``.
1212
13+
Copied from urllib3.poolmanager._default_key_normalizer.
14+
1315
Args:
1416
key_class: The class to use when constructing the key. This should be a namedtuple
1517
with the scheme and host keys at a minimum.
1618
request_context: An object that contain the context for a request.
1719
1820
Returns:
1921
A namedtuple that can be used as a connection pool key.
20-
21-
Notes:
22-
Copied from urllib3.poolmanager._default_key_normalizer.
2322
"""
2423
# Since we mutate the dictionary, make a copy first
2524
context = request_context.copy()

podman/api/http_utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ def _format_string(filters, criteria):
5656
def prepare_body(body: Mapping[str, Any]) -> str:
5757
"""Returns JSON payload to be uploaded to server.
5858
59-
Notes:
60-
Values of None and empty Iterables are removed, False and zero-values are retained.
59+
Values of None and empty Iterables are removed, False and zero-values are retained.
6160
"""
6261
if body is None:
6362
return ""
@@ -69,8 +68,7 @@ def prepare_body(body: Mapping[str, Any]) -> str:
6968
def _filter_values(mapping: Mapping[str, Any]) -> Dict[str, Any]:
7069
"""Returns a canonical dictionary with values == None or empty Iterables removed.
7170
72-
Notes:
73-
Dictionary is walked using recursion.
71+
Dictionary is walked using recursion.
7472
"""
7573
canonical = dict()
7674
for key, value in mapping.items():

podman/api/parse_utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,15 @@ def prepare_timestamp(value: Union[datetime, int, None]) -> Optional[int]:
5757
def prepare_cidr(value: Union[ipaddress.IPv4Network, ipaddress.IPv6Network]) -> (str, str):
5858
"""Returns network address and Base64 encoded netmask from CIDR.
5959
60-
Notes:
61-
The return values are dictated by the Go JSON decoder.
60+
The return values are dictated by the Go JSON decoder.
6261
"""
6362
return str(value.network_address), base64.b64encode(value.netmask.packed).decode("utf-8")
6463

6564

6665
def frames(response: Response) -> Iterator[bytes]:
6766
"""Returns each frame from multiplexed payload, all results are expected in the payload.
6867
69-
Notes:
70-
The stdout and stderr frames are undifferentiated as they are returned.
68+
The stdout and stderr frames are undifferentiated as they are returned.
7169
"""
7270
length = len(response.content)
7371
index = 0

podman/api/ssh.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ def __init__(self, uri: str, identity: Optional[str] = None):
4040
4141
Examples:
4242
SSHSocket("http+ssh://[email protected]:2222/run/user/1000/podman/podman.sock",
43-
"~alice/.ssh/api_ed25519"
44-
)
43+
"~alice/.ssh/api_ed25519")
4544
"""
4645
super().__init__(socket.AF_UNIX, socket.SOCK_STREAM)
4746
self.uri = uri
@@ -130,8 +129,7 @@ def recv(self, buffersize, flags=None) -> bytes: # pylint: disable=unused-argum
130129
def close(self):
131130
"""Release resources held by SSHSocket.
132131
133-
Notes:
134-
- SSH client is first sent SIGTERM, then a SIGKILL 20 seconds later if needed.
132+
The SSH client is first sent SIGTERM, then a SIGKILL 20 seconds later if needed.
135133
"""
136134
if not self._proc or self._proc.stdin.closed:
137135
return

podman/api/tar_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
def prepare_containerignore(anchor: str) -> List[str]:
1414
"""Return the list of patterns for filenames to exclude.
1515
16-
Notes:
17-
.containerignore takes precedence over .dockerignore.
16+
.containerignore takes precedence over .dockerignore.
1817
"""
1918
for filename in (".containerignore", ".dockerignore"):
2019
ignore = pathlib.Path(anchor) / filename

podman/api/uds.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ def __init__(
155155
156156
Examples:
157157
requests.Session.mount(
158-
"http://", UDSAdapater("http+unix:///run/user/1000/podman/podman.sock")
159-
)
158+
"http://", UDSAdapater("http+unix:///run/user/1000/podman/podman.sock"))
160159
"""
161160
self.poolmanager: Optional[UDSPoolManager] = None
162161

podman/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ class PodmanClient(AbstractContextManager):
2929
Examples:
3030
3131
with PodmanClient("ssh://[email protected]:22/run/podman/podman.sock?secure=True",
32-
identity="~alice/.ssh/api_ed25519"
33-
)
32+
identity="~alice/.ssh/api_ed25519")
3433
"""
3534

3635
def __init__(self, *args, **kwargs) -> None:
@@ -53,6 +52,7 @@ def __init__(self, *args, **kwargs) -> None:
5352
5453
Examples:
5554
base_url:
55+
5656
- http+ssh://<user>@<host>[:port]</run/podman/podman.sock>[?secure=True]
5757
- http+unix://</run/podman/podman.sock>
5858
- tcp://<localhost>[:<port>]
@@ -210,7 +210,7 @@ def swarm(self):
210210
"""Swarm not supported.
211211
212212
Raises:
213-
NotImplemented: Always, swarm not supported by Podman service
213+
NotImplemented: Swarm not supported by Podman service
214214
"""
215215
raise NotImplementedError("Swarm operations are not supported by Podman service.")
216216

0 commit comments

Comments
 (0)