From d274543b7250c4b44f23ed1737e1c214d26dce6d Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Tue, 25 Aug 2020 19:10:32 +0100 Subject: [PATCH] docs: Add Python API usage example Fixes: #297 --- docs/development.rst | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/development.rst b/docs/development.rst index 7d8907e..a706836 100644 --- a/docs/development.rst +++ b/docs/development.rst @@ -2,7 +2,17 @@ Development =========== yamllint provides both a script and a Python module. The latter can be used to -write your own linting tools: +write your own linting tools. + +Basic example of running the linter from Python: + +.. code-block:: python + + import yamllint + + yaml_config = yamllint.config.YamlLintConfig("extends: default") + for p in yamllint.linter.run("example.yaml", yaml_config): + print(p.desc, p.line, p.rule) .. automodule:: yamllint.linter :members: