|
From: openocd-gerrit <ope...@us...> - 2026-03-08 10:21:49
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main OpenOCD repository".
The branch, master has been updated
via 092282c7d27141df23a6055f9ee216da32494401 (commit)
from c3b4bcc6e62e2bb8b09835c27f7dc34aa1c73be3 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 092282c7d27141df23a6055f9ee216da32494401
Author: Marc Schink <de...@za...>
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 <de...@za...>
Reviewed-on: https://review.openocd.org/c/openocd/+/9474
Tested-by: jenkins
Reviewed-by: Antonio Borneo <bor...@gm...>
diff --git a/README.md b/README.md
index c8806e06c..bf26d5903 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 9232c83a3..6235fc7eb 100755
--- a/tools/scripts/checkpatch.pl
+++ b/tools/scripts/checkpatch.pl
@@ -92,6 +92,12 @@ my $git_command ='export LANGUAGE=en_US.UTF-8; git';
my $tabsize = 8;
my ${CONFIG_} = "CONFIG_";
+# OpenOCD specific: Begin: check markdown with pymarkdownlnt
+# Remember which Markdown (*.md) files were already linted.
+my %md_checked;
+my $md_linter_not_found;
+# OpenOCD specific: End
+
sub help {
my ($exitcode) = @_;
@@ -2435,6 +2441,44 @@ sub report_dump {
our @report;
}
+# OpenOCD specific: Begin: check markdown with pymarkdownlnt
+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 = (which($md_linter) eq "");
+ }
+
+ if ($md_linter_not_found) {
+ 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");
+ }
+}
+# OpenOCD specific: End
+
sub fixup_current_range {
my ($lineRef, $offset, $length) = @_;
@@ -2965,6 +3009,15 @@ sub process {
}
}
+ # OpenOCD specific: Begin: check markdown with pymarkdownlnt
+ # Lint Markdown files.
+ if ($realfile =~ /\.md$/ && !$md_checked{$realfile}) {
+ my $fullpath = $root ? "$root/$realfile" : $realfile;
+ run_md_linter($fullpath);
+ $md_checked{$realfile} = 1;
+ }
+ # OpenOCD specific: End
+
next;
}
-----------------------------------------------------------------------
Summary of changes:
README.md | 1 +
tools/scripts/checkpatch.pl | 53 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+)
hooks/post-receive
--
Main OpenOCD repository
|