summaryrefslogtreecommitdiff
path: root/Documentation/lint-documentation-style.perl
blob: d7ab7322939ebdcc0cf9be58248d930f07935022 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/perl

use strict;
use warnings;

my $exit_code = 0;
sub report {
	my ($line, $msg) = @_;
	chomp $line;
	print STDERR "$ARGV:$.: '$line' $msg\n";
	$exit_code = 1;
}

my $synopsis_style = 0;

while (my $line = <>) {
	if ($line =~ /^[ \t]*`?[-a-z0-9.]+`?(, `?[-a-z0-9.]+`?)+(::|;;)$/) {

		report($line, "multiple parameters in a definition list item");
	}
	if ($line =~ /^`?--\[no-\][a-z0-9-]+.*(::|;;)$/) {
		report($line, "definition list item with a `--[no-]` parameter");
	}
	if ($line =~ /^\[synopsis\]$/) {
		$synopsis_style = 1;
	}
	if (($line =~ /^(-[-a-z].*|<[-a-z0-9]+>(\.{3})?)(::|;;)$/) && ($synopsis_style)) {
			report($line, "synopsis style and definition list item not backquoted");
	}
}


exit $exit_code;