Skip to content

Commit

Permalink
Added yamllint
Browse files Browse the repository at this point in the history
  • Loading branch information
MartenBE committed Jun 17, 2024
1 parent a271982 commit ae85323
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 120 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ charset = utf-8
indent_size = 4
indent_style = space
insert_final_newline = true

[*.{yml,yaml}]
indent_size = 2
69 changes: 35 additions & 34 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions .markdownlint-cli2.yaml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 0 additions & 15 deletions .markdownlint.jsonc

This file was deleted.

19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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]
5 changes: 0 additions & 5 deletions .prettierrc.json5

This file was deleted.

12 changes: 12 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -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
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand All @@ -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
```
Expand Down Expand Up @@ -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.
16 changes: 8 additions & 8 deletions docs/examples/h1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
104 changes: 52 additions & 52 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,59 @@ copyright: Copyright &copy; HOGENT (<a href="https://hogent.be">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

0 comments on commit ae85323

Please sign in to comment.