This is an automated email from Gerrit. "Marc Schink <[email protected]>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9474
-- gerrit commit 575dd89e05210e86f532e741e89fd34ad626189f Author: Marc Schink <[email protected]> Date: Tue Feb 17 11:21:34 2026 +0100 tools/checkpatch: Add Markdown linter support Use 'pymarkdownlnt' to lint Markdown files and enforce a strict style. If the linter is not found, a single error message is printed and the Markdown checks are skipped. Example checkpatch output (line breaks added for commit message only): ERROR:MARKDOWN_LINT: ./README.md:1:1: MD041: First line in file should be a top level heading (first-line-heading,first-line-h1) ERROR:MARKDOWN_LINT: ./README.md:272:1: MD012: Multiple consecutive blank lines [Expected: 1, Actual: 4] (no-multiple-blanks) ERROR:MARKDOWN_LINT: ./README.md:273:35: MD026: Trailing punctuation present in heading text. (no-trailing-punctuation) Change-Id: I460ef881b83eb0a2eb46ee62d520b514785ad4e1 Signed-off-by: Marc Schink <[email protected]> diff --git a/README.md b/README.md index c8806e06cf..bf26d59038 100644 --- a/README.md +++ b/README.md @@ -262,6 +262,7 @@ Optional development script checkpatch needs: - perl - python - python-ply +- pymarkdownlnt ### Compiling OpenOCD diff --git a/tools/scripts/checkpatch.pl b/tools/scripts/checkpatch.pl index 9232c83a37..c45973686c 100755 --- a/tools/scripts/checkpatch.pl +++ b/tools/scripts/checkpatch.pl @@ -92,6 +92,10 @@ my $git_command ='export LANGUAGE=en_US.UTF-8; git'; my $tabsize = 8; my ${CONFIG_} = "CONFIG_"; +# Remember which Markdown (*.md) files were already linted. +my %md_checked; +my $md_linter_not_found; + sub help { my ($exitcode) = @_; @@ -2435,6 +2439,43 @@ sub report_dump { our @report; } +sub run_md_linter { + my ($file) = @_; + my $md_linter = "pymarkdownlnt"; + + return if !$file || !-f $file; + + if (!defined($md_linter_not_found)) { + $md_linter_not_found = (system("command -v $md_linter >/dev/null 2>&1") != 0); + } + + if ($md_linter_not_found) { + ERROR("MARKDOWN_LINT", "Markdown linter '$md_linter' could not be found\n"); + return; + } + + my @cmd = ($md_linter, "scan", $file); + + my @out = qx{@cmd 2>&1}; + my $rc = $? >> 8; + + foreach my $line (@out) { + chomp $line; + next if $line eq ""; + + if ($line =~ m/^(.*?):(\d+):(\d+):\s*([A-Z0-9]+):\s*(.*)$/) { + my ($path, $ln, $col, $code, $msg) = ($1, $2, $3, $4, $5); + WARN("MARKDOWN_LINT", "$file:$ln:$col: $code: $msg\n"); + } else { + WARN("MARKDOWN_LINT: Failed to parse output: $line\n"); + } + } + + if ($rc != 0 && !@out) { + WARN("MARKDOWN_LINT", "Markdown linter exited with status $rc for $file\n"); + } +} + sub fixup_current_range { my ($lineRef, $offset, $length) = @_; @@ -2965,6 +3006,13 @@ sub process { } } + # Lint Markdown files. + if ($realfile =~ /\.md$/ && !$md_checked{$realfile}) { + my $fullpath = $root ? "$root/$realfile" : $realfile; + run_md_linter($fullpath); + $md_checked{$realfile} = 1; + } + next; } --
