doc: test linkgit macros for well-formedness

Some readers of man pages have reported that they found
malformed linkgit macros in the documentation (absence or bad
spelling).

Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jean-Noël Avila
2025-08-11 20:53:15 +00:00
committed by Junio C Hamano
parent 721c9e5ce7
commit f81a574f59
2 changed files with 8 additions and 1 deletions

View File

@@ -178,7 +178,7 @@ $export_ok::
Show repository only if this file exists (in repository). Only Show repository only if this file exists (in repository). Only
effective if this variable evaluates to true. Can be set when effective if this variable evaluates to true. Can be set when
building gitweb by setting `GITWEB_EXPORT_OK`. This path is building gitweb by setting `GITWEB_EXPORT_OK`. This path is
relative to `GIT_DIR`. git-daemon[1] uses 'git-daemon-export-ok', relative to `GIT_DIR`. linkgit:git-daemon[1] uses 'git-daemon-export-ok',
unless started with `--export-all`. By default this variable is unless started with `--export-all`. By default this variable is
not set, which means that this feature is turned off. not set, which means that this feature is turned off.

View File

@@ -41,6 +41,13 @@ die "BUG: No list of valid linkgit:* files given" unless @ARGV;
@ARGV = $to_check; @ARGV = $to_check;
while (<>) { while (<>) {
my $line = $_; my $line = $_;
while ($line =~ m/(.{,8})((git[-a-z]+|scalar)\[(\d)*\])/g) {
my $pos = pos $line;
my ($macro, $target, $page, $section) = ($1, $2, $3, $4);
if ( $macro ne "linkgit:" && $macro !~ "ifn?def::" && $macro ne "endif::" ) {
report($pos, $line, $target, "linkgit: macro expected");
}
}
while ($line =~ m/linkgit:((.*?)\[(\d)\])/g) { while ($line =~ m/linkgit:((.*?)\[(\d)\])/g) {
my $pos = pos $line; my $pos = pos $line;
my ($target, $page, $section) = ($1, $2, $3); my ($target, $page, $section) = ($1, $2, $3);