Received: from eggs.gnu.org ([2001:4830:134:3::10]:33858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjrLs-0000Fy-PY for qemu-devel@nongnu.org; Tue, 13 Sep 2016 13:18:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjrLr-0006I4-ID for qemu-devel@nongnu.org; Tue, 13 Sep 2016 13:18:32 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:35019) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjrLr-0006Hj-CE for qemu-devel@nongnu.org; Tue, 13 Sep 2016 13:18:31 -0400 Received: by mail-wm0-f66.google.com with SMTP id c131so3943614wmh.2 for ; Tue, 13 Sep 2016 10:18:31 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 13 Sep 2016 19:16:17 +0200 Message-Id: <1473786989-54823-47-git-send-email-pbonzini@redhat.com> In-Reply-To: <1473786989-54823-1-git-send-email-pbonzini@redhat.com> References: <1473786989-54823-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PULL 46/58] checkpatch: Fix whitespace checks for documentation code blocks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Llu=C3=ADs=20Vilanova?= From: Lluís Vilanova Prevent blank lines in documentation code blocks to be signalled as incorrect trailing whitespace. Code blocks in documentation are 4-column aligned, and blank lines in them should have exactly 4 columns of trailing whitespace to prevent QEMU's wiki to render them as separate code blocks. Signed-off-by: Lluís Vilanova Message-Id: <147325254382.22644.5531276787733455773.stgit@fimbulvetr.bsc.es> Signed-off-by: Paolo Bonzini Signed-off-by: Lluís Vilanova --- scripts/checkpatch.pl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index b0096a4..dde3f5f 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1320,6 +1320,16 @@ sub process { my $herevet = "$here\n" . cat_vet($rawline) . "\n"; ERROR("DOS line endings\n" . $herevet); + } elsif ($realfile =~ /^docs\/.+\.txt/ || + $realfile =~ /^docs\/.+\.md/) { + if ($rawline =~ /^\+\s+$/ && $rawline !~ /^\+ {4}$/) { + # TODO: properly check we're in a code block + # (surrounding text is 4-column aligned) + my $herevet = "$here\n" . cat_vet($rawline) . "\n"; + ERROR("code blocks in documentation should have " . + "empty lines with exactly 4 columns of " . + "whitespace\n" . $herevet); + } } elsif ($rawline =~ /^\+.*\S\s+$/ || $rawline =~ /^\+\s+$/) { my $herevet = "$here\n" . cat_vet($rawline) . "\n"; ERROR("trailing whitespace\n" . $herevet); -- 1.8.3.1