Skip to content

Commit 444d7f6

Browse files
committed
Fixes up some docstrings.
1 parent a029e52 commit 444d7f6

File tree

4 files changed

+1898
-1846
lines changed

4 files changed

+1898
-1846
lines changed

scripts/generate_module_hints.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ def replace(match: re.Match[str]) -> str:
222222

223223
if mode == 'M':
224224
# module -> method link
225+
value = value.rsplit('.', 1)[-1]
225226
value = value.replace(' ', '\u00a0')
226227
return f':meth:`{value}`'
227228
elif mode == 'P':
@@ -231,7 +232,7 @@ def replace(match: re.Match[str]) -> str:
231232
value = value[:type_idx]
232233

233234
value = value.replace(' ', '\u00a0')
234-
return f'`{value}`'
235+
return f'``{value}``'
235236
# be generous about accepting either as either
236237
elif mode in 'UL':
237238
if ',' in value:
@@ -259,15 +260,15 @@ def replace(match: re.Match[str]) -> str:
259260
# sphinx reference
260261
name, _ = value.split(',')
261262
name = name.replace(' ', '\u00a0')
262-
return f'`{name}`'
263+
return f'``{name}``'
263264
elif mode in ('O', 'C', 'V', 'RV', 'E'):
264265
if isinstance(value, str):
265266
# NOTE: Values are already escaped, so we need to unescape
266267
# so we don't double escape.
267268
# We also replace spaces with non-breaking spaces
268269
# so our line-splitter can't split there.
269270
value = value.replace('\\\\', '\\').replace(' ', '\u00a0')
270-
return f'`{value}`'
271+
return f'``{value}``'
271272
else:
272273
raise ValueError(f'Unknown reference mode {mode}')
273274

src/suitable/_module_types.py

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,15 @@ def ansible_job_id(self, server: str | None = None) -> str:
257257

258258
def finished(self, server: str | None = None) -> int:
259259
"""
260-
Whether the asynchronous job has finished (`1`) or not (`0`).
260+
Whether the asynchronous job has finished (``1``) or not (``0``).
261261
262262
Returned when: always
263263
"""
264264
return self.acquire(server, 'finished')
265265

266266
def started(self, server: str | None = None) -> int:
267267
"""
268-
Whether the asynchronous job has started (`1`) or not (`0`).
268+
Whether the asynchronous job has started (``1``) or not (``0``).
269269
270270
Returned when: always
271271
"""
@@ -780,17 +780,17 @@ class FileResults(RunnerResults):
780780

781781
def dest(self, server: str | None = None) -> str:
782782
"""
783-
Destination file/path, equal to the value passed to `path`.
783+
Destination file/path, equal to the value passed to ``path``.
784784
785-
Returned when: `state=touch`, `state=hard`, `state=link`
785+
Returned when: ``state=touch``, ``state=hard``, ``state=link``
786786
"""
787787
return self.acquire(server, 'dest')
788788

789789
def path(self, server: str | None = None) -> str:
790790
"""
791-
Destination file/path, equal to the value passed to `path`.
791+
Destination file/path, equal to the value passed to ``path``.
792792
793-
Returned when: `state=absent`, `state=directory`, `state=file`
793+
Returned when: ``state=absent``, ``state=directory``, ``state=file``
794794
"""
795795
return self.acquire(server, 'path')
796796

@@ -1138,7 +1138,7 @@ def gid(self, server: str | None = None) -> int:
11381138
"""
11391139
Group ID of the group.
11401140
1141-
Returned when: `state` is `present`
1141+
Returned when: ``state`` is ``present``
11421142
"""
11431143
return self.acquire(server, 'gid')
11441144

@@ -1162,7 +1162,7 @@ def system(self, server: str | None = None) -> bool:
11621162
"""
11631163
Whether the group is a system group or not.
11641164
1165-
Returned when: `state` is `present`
1165+
Returned when: ``state`` is ``present``
11661166
"""
11671167
return self.acquire(server, 'system')
11681168

@@ -1557,7 +1557,7 @@ class PingResults(RunnerResults):
15571557

15581558
def ping(self, server: str | None = None) -> str:
15591559
"""
1560-
Value provided with the `data` parameter.
1560+
Value provided with the ``data`` parameter.
15611561
15621562
Returned when: success
15631563
"""
@@ -2026,7 +2026,7 @@ class SystemdResults(RunnerResults):
20262026

20272027
def status(self, server: str | None = None) -> dict[str, Incomplete]:
20282028
"""
2029-
A dictionary with the key=value pairs returned from `systemctl show`.
2029+
A dictionary with the key=value pairs returned from ``systemctl show``.
20302030
20312031
Returned when: success
20322032
"""
@@ -2050,7 +2050,7 @@ class SystemdServiceResults(RunnerResults):
20502050

20512051
def status(self, server: str | None = None) -> dict[str, Incomplete]:
20522052
"""
2053-
A dictionary with the key=value pairs returned from `systemctl show`.
2053+
A dictionary with the key=value pairs returned from ``systemctl show``.
20542054
20552055
Returned when: success
20562056
"""
@@ -2228,7 +2228,7 @@ def files(self, server: str | None = None) -> list[Incomplete]:
22282228
"""
22292229
List of all the files in the archive.
22302230
2231-
Returned when: `list_files` is `True`
2231+
Returned when: ``list_files`` is ``True``
22322232
"""
22332233
return self.acquire(server, 'files')
22342234

@@ -2286,7 +2286,7 @@ def src(self, server: str | None = None) -> str:
22862286
"""
22872287
The source archive's path.
22882288
2289-
If `src` was a remote web URL, or from the local ansible controller,
2289+
If ``src`` was a remote web URL, or from the local ansible controller,
22902290
this shows the temporary location where the download was stored.
22912291
22922292
Returned when: always
@@ -2417,7 +2417,7 @@ def append(self, server: str | None = None) -> bool:
24172417
"""
24182418
Whether or not to append the user to groups.
24192419
2420-
Returned when: `state` is `present` and the user exists
2420+
Returned when: ``state`` is ``present`` and the user exists
24212421
"""
24222422
return self.acquire(server, 'append')
24232423

@@ -2441,7 +2441,7 @@ def force(self, server: str | None = None) -> bool:
24412441
"""
24422442
Whether or not a user account was forcibly deleted.
24432443
2444-
Returned when: `state` is `absent` and user exists
2444+
Returned when: ``state`` is ``absent`` and user exists
24452445
"""
24462446
return self.acquire(server, 'force')
24472447

@@ -2457,23 +2457,23 @@ def groups(self, server: str | None = None) -> str:
24572457
"""
24582458
List of groups of which the user is a member.
24592459
2460-
Returned when: `groups` is not empty and `state` is `present`
2460+
Returned when: ``groups`` is not empty and ``state`` is ``present``
24612461
"""
24622462
return self.acquire(server, 'groups')
24632463

24642464
def home(self, server: str | None = None) -> str:
24652465
"""
24662466
Path to user's home directory.
24672467
2468-
Returned when: `state` is `present`
2468+
Returned when: ``state`` is ``present``
24692469
"""
24702470
return self.acquire(server, 'home')
24712471

24722472
def move_home(self, server: str | None = None) -> bool:
24732473
"""
24742474
Whether or not to move an existing home directory.
24752475
2476-
Returned when: `state` is `present` and user exists
2476+
Returned when: ``state`` is ``present`` and user exists
24772477
"""
24782478
return self.acquire(server, 'move_home')
24792479

@@ -2489,47 +2489,47 @@ def password(self, server: str | None = None) -> str:
24892489
"""
24902490
Masked value of the password.
24912491
2492-
Returned when: `state` is `present` and `password` is not empty
2492+
Returned when: ``state`` is ``present`` and ``password`` is not empty
24932493
"""
24942494
return self.acquire(server, 'password')
24952495

24962496
def remove(self, server: str | None = None) -> bool:
24972497
"""
24982498
Whether or not to remove the user account.
24992499
2500-
Returned when: `state` is `absent` and user exists
2500+
Returned when: ``state`` is ``absent`` and user exists
25012501
"""
25022502
return self.acquire(server, 'remove')
25032503

25042504
def shell(self, server: str | None = None) -> str:
25052505
"""
25062506
User login shell.
25072507
2508-
Returned when: `state` is `present`
2508+
Returned when: ``state`` is ``present``
25092509
"""
25102510
return self.acquire(server, 'shell')
25112511

25122512
def ssh_fingerprint(self, server: str | None = None) -> str:
25132513
"""
25142514
Fingerprint of generated SSH key.
25152515
2516-
Returned when: `generate_ssh_key` is `True`
2516+
Returned when: ``generate_ssh_key`` is ``True``
25172517
"""
25182518
return self.acquire(server, 'ssh_fingerprint')
25192519

25202520
def ssh_key_file(self, server: str | None = None) -> str:
25212521
"""
25222522
Path to generated SSH private key file.
25232523
2524-
Returned when: `generate_ssh_key` is `True`
2524+
Returned when: ``generate_ssh_key`` is ``True``
25252525
"""
25262526
return self.acquire(server, 'ssh_key_file')
25272527

25282528
def ssh_public_key(self, server: str | None = None) -> str:
25292529
"""
25302530
Generated SSH public key file.
25312531
2532-
Returned when: `generate_ssh_key` is `True`
2532+
Returned when: ``generate_ssh_key`` is ``True``
25332533
"""
25342534
return self.acquire(server, 'ssh_public_key')
25352535

@@ -2553,7 +2553,7 @@ def system(self, server: str | None = None) -> bool:
25532553
"""
25542554
Whether or not the account is a system account.
25552555
2556-
Returned when: `system` is passed to the module and the account does
2556+
Returned when: ``system`` is passed to the module and the account does
25572557
not exist
25582558
"""
25592559
return self.acquire(server, 'system')
@@ -2562,7 +2562,7 @@ def uid(self, server: str | None = None) -> int:
25622562
"""
25632563
User ID of the user account.
25642564
2565-
Returned when: `uid` is passed to the module
2565+
Returned when: ``uid`` is passed to the module
25662566
"""
25672567
return self.acquire(server, 'uid')
25682568

@@ -3461,7 +3461,7 @@ def user(self, server: str | None = None) -> str:
34613461
def validate_certs(self, server: str | None = None) -> bool:
34623462
"""
34633463
This only applies if using a https url as the source of the keys. If
3464-
set to `false`, the SSL certificates will not be validated.
3464+
set to ``false``, the SSL certificates will not be validated.
34653465
34663466
Returned when: success
34673467
"""
@@ -3504,7 +3504,7 @@ class FirewalldInfoResults(RunnerResults):
35043504

35053505
def active_zones(self, server: str | None = None) -> bool:
35063506
"""
3507-
Gather active zones only if turn it `true`.
3507+
Gather active zones only if turn it ``true``.
35083508
35093509
Returned when: success
35103510
"""
@@ -3520,9 +3520,9 @@ def collected_zones(self, server: str | None = None) -> list[Incomplete]:
35203520

35213521
def undefined_zones(self, server: str | None = None) -> list[Incomplete]:
35223522
"""
3523-
A list of undefined zones in `zones` option.
3523+
A list of undefined zones in ``zones`` option.
35243524
3525-
`undefined_zones` will be ignored for gathering process.
3525+
``undefined_zones`` will be ignored for gathering process.
35263526
35273527
Returned when: success
35283528
"""
@@ -4309,7 +4309,8 @@ def values( # type:ignore[override]
43094309
) -> dict[str, Incomplete]:
43104310
"""
43114311
dictionary of before and after values; each key is a variable name,
4312-
each value is another dict with `before`, `after`, and `changed` keys.
4312+
each value is another dict with ``before``, ``after``, and ``changed``
4313+
keys.
43134314
43144315
Returned when: always
43154316
"""
@@ -4547,19 +4548,19 @@ def name(self, server: str | None = None) -> str:
45474548

45484549
def added(self, server: str | None = None) -> list[Incomplete]:
45494550
"""
4550-
A list of members added when `state` is `present` or `pure`; this is
4551-
empty if no members are added.
4551+
A list of members added when ``state`` is ``present`` or ``pure``;
4552+
this is empty if no members are added.
45524553
4553-
Returned when: success and `state` is `present`
4554+
Returned when: success and ``state`` is ``present``
45544555
"""
45554556
return self.acquire(server, 'added')
45564557

45574558
def removed(self, server: str | None = None) -> list[Incomplete]:
45584559
"""
4559-
A list of members removed when `state` is `absent` or `pure`; this is
4560-
empty if no members are removed.
4560+
A list of members removed when ``state`` is ``absent`` or ``pure``;
4561+
this is empty if no members are removed.
45614562
4562-
Returned when: success and `state` is `absent`
4563+
Returned when: success and ``state`` is ``absent``
45634564
"""
45644565
return self.acquire(server, 'removed')
45654566

@@ -4766,7 +4767,7 @@ class WinPowershellResults(RunnerResults):
47664767

47674768
def result(self, server: str | None = None) -> Incomplete:
47684769
"""
4769-
The values that were set by `$Ansible.Result` in the script.
4770+
The values that were set by ``$Ansible.Result`` in the script.
47704771
47714772
Defaults to an empty dict but can be set to anything by the script.
47724773
@@ -4817,7 +4818,7 @@ def warning(self, server: str | None = None) -> list[Incomplete]:
48174818
"""
48184819
A list of warning messages created by the script.
48194820
4820-
Warning messages only appear when `$WarningPreference = 'Continue'`.
4821+
Warning messages only appear when ``$WarningPreference = 'Continue'``.
48214822
48224823
Returned when: always
48234824
"""
@@ -4827,7 +4828,7 @@ def verbose(self, server: str | None = None) -> list[Incomplete]:
48274828
"""
48284829
A list of warning messages created by the script.
48294830
4830-
Verbose messages only appear when `$VerbosePreference = 'Continue'`.
4831+
Verbose messages only appear when ``$VerbosePreference = 'Continue'``.
48314832
48324833
Returned when: always
48334834
"""
@@ -4837,7 +4838,7 @@ def debug(self, server: str | None = None) -> list[Incomplete]:
48374838
"""
48384839
A list of warning messages created by the script.
48394840
4840-
Debug messages only appear when `$DebugPreference = 'Continue'`.
4841+
Debug messages only appear when ``$DebugPreference = 'Continue'``.
48414842
48424843
Returned when: always
48434844
"""
@@ -5359,8 +5360,8 @@ def reboot_required(self, server: str | None = None) -> bool:
53595360

53605361
def rebooted(self, server: str | None = None) -> bool:
53615362
"""
5362-
Set to `true` when the target Windows host has been rebooted by
5363-
`win_updates`.
5363+
Set to ``true`` when the target Windows host has been rebooted by
5364+
``win_updates``.
53645365
53655366
Returned when: success
53665367
"""
@@ -5370,7 +5371,7 @@ def updates(self, server: str | None = None) -> dict[str, Incomplete]:
53705371
"""
53715372
Updates that were found/installed.
53725373
5373-
The key for each update is the `id` of the update.
5374+
The key for each update is the ``id`` of the update.
53745375
53755376
Returned when: success
53765377
"""
@@ -5726,8 +5727,8 @@ def label(self, server: str | None = None) -> Incomplete:
57265727

57275728
def impersonation_level(self, server: str | None = None) -> str:
57285729
"""
5729-
The impersonation level of the token, only valid if `token_type` is
5730-
`TokenImpersonation`, see
5730+
The impersonation level of the token, only valid if ``token_type`` is
5731+
``TokenImpersonation``, see
57315732
`reference <https://msdn.microsoft.com/en-us/library/windows/desktop/aa379572.aspx>`__.
57325733
57335734
Returned when: success

0 commit comments

Comments
 (0)