Skip to content

Commit 99498f6

Browse files
SorinOlarikr-t
authored andcommitted
scripts: add linter for markdown files
Signed-off-by: SorinO <sorin.olari2@gmail.com>
1 parent f6cbccf commit 99498f6

3 files changed

Lines changed: 41 additions & 1 deletion

File tree

scripts/check_license_banner_conf_files.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ check_license_banner() {
4343
echo "Checking license banners."
4444
ERROR_FOUND=0
4545
for file in $(find . -type f \( -name 'CMakeLists.txt' -o -name '*.yaml' \
46-
-o -name '*.yml' -o -name '*.awk' -o -name '*.conf' -o -name 'Kconfig*' \
46+
-o -name '*.yml' -o -name '*.awk' -o -name '*.conf' -o -name 'Kconfig*' -o -name '*.mdlrc' \
4747
-o -name '.gitignore' -o -name '.gitmodules' -o -name '*.sh' -o -name '*.cmake' -o -name '*.py' \) \
4848
! -path './tests/Unity/*' \
4949
! -path './build/*' \

scripts/md_linter.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
# @copyright Copyright (c) contributors to Project Ocre,
3+
# which has been established as Project Ocre a Series of LF Projects, LLC
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
# Simple linter checker for markdown files
8+
# Checks all markdown files with markdownlint
9+
10+
set -e
11+
12+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
13+
ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
14+
15+
echo "Checking markdown files."
16+
17+
cd "$ROOT_DIR"
18+
19+
find . -type f -name '*.md' \
20+
! -path '*/build/*' \
21+
! -path './ocre-sdk/*' \
22+
! -path './wasm-micro-runtime/*' \
23+
! -path './tests/*' \
24+
-print0 | \
25+
xargs -0 mdl -s ./scripts/md_linter_rules.mdlrc

scripts/md_linter_rules.mdlrc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# @copyright Copyright (c) contributors to Project Ocre,
2+
# which has been established as Project Ocre a Series of LF Projects, LLC
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
all
7+
exclude_rule 'MD002' # First header should be a top level header
8+
exclude_rule 'MD010' # Hard tabs
9+
exclude_rule 'MD013' # Line length
10+
exclude_rule 'MD029' # Ordered list item prefix
11+
exclude_rule 'MD041' # First line in file should be a top level header
12+
exclude_rule 'MD040' # Fenced code blocks should have a language specified
13+
rule 'MD024', :allow_different_nesting => 'true' # Multiple headers with the same content
14+
rule 'MD026', :punctuation => '.,;!' # Trailing punctuation in header
15+
rule 'MD007', :indent => 2 # Unordered list indentation

0 commit comments

Comments
 (0)