summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/conf.py8
-rw-r--r--docs/disable_with_comments.rst18
-rw-r--r--docs/integration.rst102
-rw-r--r--docs/requirements.txt1
4 files changed, 86 insertions, 43 deletions
diff --git a/docs/conf.py b/docs/conf.py
index 2c40177..8a03b2f 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -1,17 +1,17 @@
# yamllint documentation build configuration file, created by
# sphinx-quickstart on Thu Jan 21 21:18:52 2016.
-import sys
import os
+import sys
from unittest.mock import MagicMock
sys.path.insert(0, os.path.abspath('..'))
-
-from yamllint import __copyright__, APP_NAME, APP_VERSION # noqa
+from yamllint import __copyright__, APP_NAME, APP_VERSION # noqa: I001, E402
# -- General configuration ------------------------------------------------
extensions = [
+ 'sphinx_rtd_theme',
'sphinx.ext.autodoc',
]
@@ -29,7 +29,7 @@ pygments_style = 'sphinx'
# -- Options for HTML output ----------------------------------------------
-html_theme = 'default'
+html_theme = 'sphinx_rtd_theme'
htmlhelp_basename = 'yamllintdoc'
diff --git a/docs/disable_with_comments.rst b/docs/disable_with_comments.rst
index a973da6..6fcd221 100644
--- a/docs/disable_with_comments.rst
+++ b/docs/disable_with_comments.rst
@@ -12,11 +12,11 @@ line above. For instance:
# The following mapping contains the same key twice,
# but I know what I'm doing:
- key: value 1
- key: value 2 # yamllint disable-line rule:key-duplicates
+ - key: value 1
+ key: value 2 # yamllint disable-line rule:key-duplicates
- This line is waaaaaaaaaay too long but yamllint will not report anything about it. # yamllint disable-line rule:line-length
- This line will be checked by yamllint.
+ - This line will be checked by yamllint.
or:
@@ -24,13 +24,13 @@ or:
# The following mapping contains the same key twice,
# but I know what I'm doing:
- key: value 1
- # yamllint disable-line rule:key-duplicates
- key: value 2
+ - key: value 1
+ # yamllint disable-line rule:key-duplicates
+ key: value 2
# yamllint disable-line rule:line-length
- This line is waaaaaaaaaay too long but yamllint will not report anything about it.
- This line will be checked by yamllint.
+ - This line will be checked by yamllint.
It is possible, although not recommend, to disabled **all** rules for a
specific line:
@@ -90,8 +90,8 @@ For instance:
# yamllint disable-file
# The following mapping contains the same key twice, but I know what I'm doing:
- key: value 1
- key: value 2
+ - key: value 1
+ key: value 2
- This line is waaaaaaaaaay too long but yamllint will not report anything about it.
diff --git a/docs/integration.rst b/docs/integration.rst
index 9a6a935..e805667 100644
--- a/docs/integration.rst
+++ b/docs/integration.rst
@@ -9,15 +9,15 @@ Here is an example, to add in your .pre-commit-config.yaml
.. code:: yaml
- ---
- # Update the rev variable with the release version that you want, from the yamllint repo
- # You can pass your custom .yamllint with args attribute.
- repos:
- - repo: https://github.com/adrienverge/yamllint.git
- rev: v1.29.0
- hooks:
- - id: yamllint
- args: [--strict, -c=/path/to/.yamllint]
+ ---
+ # Update the rev variable with the release version that you want, from the yamllint repo
+ # You can pass your custom .yamllint with args attribute.
+ repos:
+ - repo: https://github.com/adrienverge/yamllint.git
+ rev: v1.29.0
+ hooks:
+ - id: yamllint
+ args: [--strict, -c=/path/to/.yamllint]
Integration with GitHub Actions
@@ -32,20 +32,62 @@ A minimal example workflow using GitHub Actions:
.. code:: yaml
- ---
- on: push # yamllint disable-line rule:truthy
+ ---
+ on: push # yamllint disable-line rule:truthy
- jobs:
- lint:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
+ jobs:
+ lint:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
- - name: Install yamllint
- run: pip install yamllint
+ - name: Install yamllint
+ run: pip install yamllint
- - name: Lint YAML files
- run: yamllint .
+ - name: Lint YAML files
+ run: yamllint .
+
+Integration with GitLab
+-----------------------
+
+You can use the following GitLab CI/CD stage to run yamllint and get the
+results as a `Code quality (Code Climate)
+<https://docs.gitlab.com/ee/ci/testing/code_quality.html>` report.
+
+.. code:: yaml
+
+ ---
+ lint:
+ stage: lint
+ script:
+ - pip install yamllint
+ - mkdir reports
+ - >
+ yamllint -f parsable . | tee >(awk '
+ BEGIN {FS = ":"; ORS="\n"; first=1}
+ {
+ gsub(/^[ \t]+|[ \t]+$|"/, "", $4);
+ match($4, /^\[(warning|error)\](.*)\((.*)\)$/, a);
+ sev = (a[1] == "error" ? "major" : "minor");
+ if (first) {
+ first=0;
+ printf("[");
+ } else {
+ printf(",");
+ }
+ printf("{\"location\":{\"path\":\"%s\",\"lines\":{\"begin\":%s",\
+ "\"end\":%s}},\"severity\":\"%s\",\"check_name\":\"%s\","\
+ "\"categories\":[\"Style\"],\"type\":\"issue\","\
+ "\"description\":\"%s\"}", $1, $2, $3, sev, a[3], a[2]);
+ }
+ END { if (!first) printf("]\n"); }' > reports/codequality.json)
+ artifacts:
+ when: always
+ paths:
+ - reports
+ expire_in: 1 week
+ reports:
+ codequality: reports/codequality.json
Integration with Arcanist
-------------------------
@@ -55,13 +97,13 @@ You can configure yamllint to run on ``arc lint``. Here is an example
.. code:: json
- {
- "linters": {
- "yamllint": {
- "type": "script-and-regex",
- "script-and-regex.script": "yamllint",
- "script-and-regex.regex": "/^(?P<line>\\d+):(?P<offset>\\d+) +(?P<severity>warning|error) +(?P<message>.*) +\\((?P<name>.*)\\)$/m",
- "include": "(\\.(yml|yaml)$)"
- }
- }
- }
+ {
+ "linters": {
+ "yamllint": {
+ "type": "script-and-regex",
+ "script-and-regex.script": "yamllint",
+ "script-and-regex.regex": "/^(?P<line>\\d+):(?P<offset>\\d+) +(?P<severity>warning|error) +(?P<message>.*) +\\((?P<name>.*)\\)$/m",
+ "include": "(\\.(yml|yaml)$)"
+ }
+ }
+ }
diff --git a/docs/requirements.txt b/docs/requirements.txt
new file mode 100644
index 0000000..f5a3564
--- /dev/null
+++ b/docs/requirements.txt
@@ -0,0 +1 @@
+sphinx-rtd-theme >=2.0.0