From ae853237b6a60aede04a74bf25ca55439d9d108c Mon Sep 17 00:00:00 2001 From: Martijn Saelens Date: Tue, 18 Jun 2024 00:39:58 +0200 Subject: [PATCH] Added yamllint --- .editorconfig | 3 + .github/workflows/publish.yml | 69 +++++++++++----------- .markdownlint-cli2.yaml | 13 +++++ .markdownlint.jsonc | 15 ----- .pre-commit-config.yaml | 19 +++++++ .prettierrc.json5 | 5 -- .yamllint.yaml | 12 ++++ README.md | 26 +++++++-- docs/examples/h1.md | 16 +++--- mkdocs.yml | 104 +++++++++++++++++----------------- 10 files changed, 162 insertions(+), 120 deletions(-) create mode 100644 .markdownlint-cli2.yaml delete mode 100644 .markdownlint.jsonc create mode 100644 .pre-commit-config.yaml delete mode 100644 .prettierrc.json5 create mode 100644 .yamllint.yaml diff --git a/.editorconfig b/.editorconfig index 176f55a..1a4a23a 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,3 +5,6 @@ charset = utf-8 indent_size = 4 indent_style = space insert_final_newline = true + +[*.{yml,yaml}] +indent_size = 2 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6a5c241..f1254d3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,41 +1,42 @@ on: - push: - pull_request: - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: + push: + pull_request: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: - contents: read - pages: write - id-token: write + contents: read + pages: write + id-token: write jobs: - lint: - runs-on: ubuntu-latest - steps: - - run: shopt -s globstar - - uses: actions/checkout@v4 - - uses: DavidAnson/markdownlint-cli2-action@v15 - with: - globs: "**/*.md" + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: DavidAnson/markdownlint-cli2-action@v15 + with: + globs: "**/*.md" + - run: pip install yamllint + - run: yamllint --strict . - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - needs: lint - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # https://github.com/timvink/mkdocs-git-revision-date-localized-plugin?tab=readme-ov-file#note-when-using-build-environments - - uses: actions/configure-pages@v4 - - uses: actions/setup-python@v5 - - run: pip install --requirement requirements.txt - - run: mkdocs build - - uses: actions/upload-pages-artifact@v3 - with: - path: ./site - - id: deployment - uses: actions/deploy-pages@v4 + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + needs: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # https://github.com/timvink/mkdocs-git-revision-date-localized-plugin?tab=readme-ov-file#note-when-using-build-environments + - uses: actions/configure-pages@v4 + - uses: actions/setup-python@v5 + - run: pip install --requirement requirements.txt + - run: mkdocs build + - uses: actions/upload-pages-artifact@v3 + with: + path: ./site + - id: deployment + uses: actions/deploy-pages@v4 diff --git a/.markdownlint-cli2.yaml b/.markdownlint-cli2.yaml new file mode 100644 index 0000000..4b01223 --- /dev/null +++ b/.markdownlint-cli2.yaml @@ -0,0 +1,13 @@ +# https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md + +config: + line-length: false + link-fragments: false + list-marker-space: false # https://github.com/prettier/prettier/issues/5019 + no-alt-text: false + no-bare-urls: false + no-inline-html: false + no-trailing-punctuation: false + ul-indent: + indent: 4 +gitignore: true diff --git a/.markdownlint.jsonc b/.markdownlint.jsonc deleted file mode 100644 index bbf05e2..0000000 --- a/.markdownlint.jsonc +++ /dev/null @@ -1,15 +0,0 @@ -{ - "line-length": false, - "link-fragments": false, - "list-marker-space": false, // https://github.com/prettier/prettier/issues/5019 - "no-alt-text": false, - "no-bare-urls": false, - "no-inline-html": false, - "no-trailing-punctuation": false, - "single-h1": { - "front_matter_title": "" - }, - "ul-indent": { - "indent": 4 - } -} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..5612d9b --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,19 @@ +# https://pre-commit.com/hooks.html + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-case-conflict + - id: end-of-file-fixer + - id: requirements-txt-fixer + - id: trailing-whitespace + - repo: https://github.com/DavidAnson/markdownlint-cli2 + rev: v0.13.0 + hooks: + - id: markdownlint-cli2 + - repo: https://github.com/adrienverge/yamllint.git + rev: v1.29.0 + hooks: + - id: yamllint + args: [--strict] diff --git a/.prettierrc.json5 b/.prettierrc.json5 deleted file mode 100644 index 1478222..0000000 --- a/.prettierrc.json5 +++ /dev/null @@ -1,5 +0,0 @@ -{ - printWidth: 120, - singleQuote: false, - tabWidth: 4, -} diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 0000000..32780d1 --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,12 @@ +# https://yamllint.readthedocs.io/en/stable/rules.html + +extends: default +ignore-from-file: .gitignore +rules: + comments: + min-spaces-from-content: 1 + document-start: + present: false + line-length: false + truthy: + check-keys: false diff --git a/README.md b/README.md index e4d641e..89b148a 100644 --- a/README.md +++ b/README.md @@ -26,14 +26,14 @@ You can see the slides of this repository at https://hogenttin.github.io/hogent- 1. Install [python](https://www.python.org/downloads/) . 2. (optional) Create a [python environment](https://docs.python.org/3/library/venv.html). E.g. for Linux: - ```console + ```bash python -m venv venv source ./venv/bin/activate ``` 3. Install the dependencies: - ```console + ```bash pip install --requirement requirements.txt ``` @@ -47,7 +47,7 @@ If you want to edit the sidebar, then just edit the `nav` entry in [mkdocs.yml]( MkDocs allows you to start up a live preview, so you can instantly see how your content looks like whilst editing the markdown files. -```console +```bash mkdocs serve ``` @@ -75,12 +75,26 @@ This repo automatically builds the website and pushes them to https://hogenttin. ### Formatting -An [editorconfig](https://editorconfig.org/) config has been added in [.editorconfig](./.editorconfig) . +An [editorconfig](https://editorconfig.org/) config has been added in [.editorconfig](./.editorconfig), which works nicely together with [prettier](https://prettier.io/docs/en/): -A [prettier](https://prettier.io/docs/en/) config has been added in [.prettierrc.json5](./.prettierrc.json5) . +```bash +prettier --write "**/*.{md,yml,yaml}" +``` :warning: Use 4 spaces for indentation of nested lists. Otherwise the nesting may not work. This is consistent with the [original MarkDown](https://daringfireball.net/projects/markdown/syntax#list) and the [CommonMark](https://spec.commonmark.org/0.31.2/#lists) specs. ### Linting -A [markdownlint](https://github.com/DavidAnson/markdownlint) config has been added in [.markdownlint.jsonc](./.markdownlint.jsonc) . +A [markdownlint](https://github.com/DavidAnson/markdownlint) config has been added in [.markdownlint-cli2.yaml](./.markdownlint-cli2.yaml): + +```bash +markdownlint-cli2 "**/*.md" +``` + +A [yamllint](https://yamllint.readthedocs.io/en/stable/index.html) config has been added in [.yamllint.yaml](./.yamllint.yaml): + +```bash +yamllint . +``` + +You can also use the [pre-commit](https://pre-commit.com/) hooks in [.pre-commit-config.yaml](./.pre-commit-config.yaml) to automatically check this at every local commit. diff --git a/docs/examples/h1.md b/docs/examples/h1.md index c734038..b7b7a4d 100644 --- a/docs/examples/h1.md +++ b/docs/examples/h1.md @@ -37,15 +37,15 @@ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu ## Mixed lists with different indentation -1. aaa - - bbb - 1. ccc - - ddd +1. aaa + - bbb + 1. ccc + - ddd 1. eee - - fff - 2. ggg - - hhh -2. iii + - fff + 2. ggg + - hhh +2. iii ## Ordered lists (the easy way) diff --git a/mkdocs.yml b/mkdocs.yml index 085d0e2..8d6b886 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -7,59 +7,59 @@ copyright: Copyright © HOGENT (https://hogent.b # Use `index.md` as the default file for the homepage. MkDocs will automatically pick this file up. # See https://www.mkdocs.org/user-guide/writing-your-docs/#index-pages for more information. nav: - - Home: ./index.md - - Basic examples: ./examples/h1.md - - Advanced examples: ./examples/h2.md - - Links: ./links.md + - Home: ./index.md + - Basic examples: ./examples/h1.md + - Advanced examples: ./examples/h2.md + - Links: ./links.md theme: - name: material # https://squidfunk.github.io/mkdocs-material/setup/ - favicon: https://hogent.be/themes/hogent/images/ico/favicon.ico - features: - - content.code.copy - - navigation.path - - navigation.top - - navigation.tracking - - toc.integrate - - toc.follow - font: - text: Montserrat - code: Inconsolata - logo: https://www.hogent.be/sites/hogent/assets/Image/logo-1.jpg + name: material # https://squidfunk.github.io/mkdocs-material/setup/ + favicon: https://hogent.be/themes/hogent/images/ico/favicon.ico + features: + - content.code.copy + - navigation.path + - navigation.top + - navigation.tracking + - toc.integrate + - toc.follow + font: + text: Montserrat + code: Inconsolata + logo: https://www.hogent.be/sites/hogent/assets/Image/logo-1.jpg markdown_extensions: - - footnotes - - pymdownx.arithmatex: - generic: true - - pymdownx.caret - - pymdownx.emoji - - pymdownx.highlight: - anchor_linenums: true - auto_title: true - linenums: true - line_spans: __span - pygments_lang_class: true - - pymdownx.magiclink - - pymdownx.mark - - pymdownx.saneheaders - - pymdownx.superfences: - custom_fences: - - name: mermaid - class: mermaid - format: !!python/name:pymdownx.superfences.fence_code_format - - pymdownx.tasklist - - pymdownx.tilde - - toc: - permalink: true + - footnotes + - pymdownx.arithmatex: + generic: true + - pymdownx.caret + - pymdownx.emoji + - pymdownx.highlight: + anchor_linenums: true + auto_title: true + linenums: true + line_spans: __span + pygments_lang_class: true + - pymdownx.magiclink + - pymdownx.mark + - pymdownx.saneheaders + - pymdownx.superfences: + custom_fences: + - name: mermaid + class: mermaid + format: !!python/name:pymdownx.superfences.fence_code_format + - pymdownx.tasklist + - pymdownx.tilde + - toc: + permalink: true plugins: - - git-authors: - show_email_address: false # Disabled to prevent spam when your non-HOGENT e-mail address is used. - - git-revision-date-localized: - enable_creation_date: true - type: datetime - # Don't forget to adjust your CI pipeline to get all the info necessary: - # https://github.com/timvink/mkdocs-git-revision-date-localized-plugin?tab=readme-ov-file#note-when-using-build-environments - - plantuml: - puml_url: https://www.plantuml.com/plantuml/ - num_workers: 8 - - search + - git-authors: + show_email_address: false # Disabled to prevent spam when your non-HOGENT e-mail address is used. + - git-revision-date-localized: + enable_creation_date: true + type: datetime + # Don't forget to adjust your CI pipeline to get all the info necessary: + # https://github.com/timvink/mkdocs-git-revision-date-localized-plugin?tab=readme-ov-file#note-when-using-build-environments + - plantuml: + puml_url: https://www.plantuml.com/plantuml/ + num_workers: 8 + - search extra_javascript: - - https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js + - https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js