Skip to content

Commit c7c3eea

Browse files
felixfonteinoraNod
andauthored
Add yamllint check for RST code listings (#2385)
* Add yamllint check for RST code listings. * Address review comments. * Sort languages and remove no longer needed duplicates. * Enable warnings, but disable all failing rules. * Improve formulation. Co-authored-by: Don Naro <[email protected]> * Show allowed languages when no or invalid language is supplied. Improve line lengths. * Make sure that 'yamllint .' passes. * Fix indentation issues introduced in #2095. --------- Co-authored-by: Don Naro <[email protected]>
1 parent f88750f commit c7c3eea

File tree

15 files changed

+447
-25
lines changed

15 files changed

+447
-25
lines changed

.github/workflows/build-package-docs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: Build and deploy docs
3-
on:
3+
"on":
44
schedule:
55
# Run at 05:17 on Tuesday and Thursday
66
- cron: '17 5 * * 2,4'

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: Ansible Docsite CI
22

3-
on:
3+
"on":
44
schedule:
5-
# Daily
5+
# Daily
66
- cron: "23 7 * * *"
77
push:
88
branches-ignore:

.github/workflows/reusable-nox.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
python-versions: "3.11"
2626
- session: "checkers(rstcheck)"
2727
python-versions: "3.11"
28+
- session: "checkers(rst-yamllint)"
29+
python-versions: "3.11"
2830
- session: "checkers(docs-build)"
2931
python-versions: "3.11"
3032
- session: "actionlint"

.mypy.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ check_untyped_defs = True
33

44
[mypy-ansible.*]
55
ignore_missing_imports = True
6+
7+
[mypy-yamllint.*]
8+
ignore_missing_imports = True

.yamllint

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
extends: default
3+
4+
ignore:
5+
- /lib/ansible/
6+
7+
rules:
8+
line-length: disable
9+
# max: 160
10+
# level: warning
11+
document-start: disable
12+
document-end: disable
13+
truthy:
14+
level: warning
15+
allowed-values:
16+
- 'true'
17+
- 'false'
18+
- 'True'
19+
- 'False'
20+
- 'TRUE'
21+
- 'FALSE'
22+
- 'yes'
23+
- 'no'
24+
- 'Yes'
25+
- 'No'
26+
- 'YES'
27+
- 'NO'
28+
indentation: disable
29+
# level: warning
30+
# spaces: 2
31+
# indent-sequences: consistent
32+
key-duplicates: disable
33+
# level: warning
34+
# forbid-duplicated-merge-keys: true
35+
trailing-spaces: enable
36+
hyphens: disable
37+
# max-spaces-after: 1
38+
# level: warning
39+
empty-lines:
40+
max: 2
41+
max-start: 0
42+
max-end: 0
43+
level: warning
44+
commas: disable
45+
# max-spaces-before: 0
46+
# min-spaces-after: 1
47+
# max-spaces-after: 1
48+
# level: warning
49+
colons: disable
50+
# max-spaces-before: 0
51+
# max-spaces-after: 1
52+
# level: warning
53+
brackets: disable
54+
# min-spaces-inside: 0
55+
# max-spaces-inside: 0
56+
# level: warning
57+
braces:
58+
min-spaces-inside: 0
59+
max-spaces-inside: 1
60+
level: warning
61+
octal-values: disable
62+
# forbid-implicit-octal: true
63+
# forbid-explicit-octal: true
64+
# level: warning
65+
comments: disable
66+
# min-spaces-from-content: 1
67+
# level: warning
68+
comments-indentation: disable
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
all:
22
hosts:
3-
192.168.0.2 # Replace with the IP of your target host
3+
192.168.0.2 # Replace with the IP of your target host

docs/docsite/rst/playbook_guide/playbooks_error_handling.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,16 @@ You can reference simple variables in conditionals to avoid repeating certain te
179179
- name: Example playbook
180180
hosts: myHosts
181181
vars:
182-
log_path: /home/ansible/logfolder/
183-
log_file: log.log
182+
log_path: /home/ansible/logfolder/
183+
log_file: log.log
184184
185-
tasks:
185+
tasks:
186186
- name: Create empty log file
187-
ansible.builtin.shell: mkdir {{ log_path }} || touch {{log_path }}{{ log_file }}
188-
register: tmp
189-
changed_when:
190-
- tmp.rc == 0
191-
- 'tmp.stderr != "mkdir: cannot create directory ‘" ~ log_path ~ "’: File exists"'
187+
ansible.builtin.shell: mkdir {{ log_path }} || touch {{log_path }}{{ log_file }}
188+
register: tmp
189+
changed_when:
190+
- tmp.rc == 0
191+
- 'tmp.stderr != "mkdir: cannot create directory ‘" ~ log_path ~ "’: File exists"'
192192
193193
.. note::
194194
Notice the missing double curly braces ``{{ }}`` around the ``log_path`` variable in the ``changed_when`` statement.

examples/DOCUMENTATION.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ options:
2222
default: a string or the word null
2323
choices:
2424
- enable
25-
- disable
25+
- disable
2626
aliases:
2727
- repo_name
2828
version_added: "1.X"
2929
requirements:
3030
- list of required things
3131
- like the factor package
32-
- zypper >= 1.0
33-
seealso:
32+
- zypper >= 1.0
33+
seealso:
3434
- specify references to other modules, useful guides, and so on
3535
notes:
3636
- other things consumers of your module should know

noxfile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"hacking/tagger/tag.py",
1616
"noxfile.py",
1717
*iglob("docs/bin/*.py"),
18+
*iglob("tests/checkers/rst-yamllint*.py"), # TODO: also lint others
1819
)
1920
PINNED = os.environ.get("PINNED", "true").lower() in {"1", "true"}
2021
nox.options.sessions = ("clone-core", "lint", "checkers", "make")

tests/checkers/rst-yamllint.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extensions": [
3+
".rst",
4+
".txt"
5+
],
6+
"ignore_regexs": [
7+
"^docs/docsite/rst/porting_guides/porting_guide_[0-9]+\\.rst$"
8+
]
9+
}

0 commit comments

Comments
 (0)