Skip to content

Commit ac56297

Browse files
committed
overlaycheck: Follow "See: <overlay>" redirections
To reduce the need for documentation duplication, teach overlaycheck to follow references within the README. Signed-off-by: Phil Elwell <[email protected]>
1 parent c21d0a7 commit ac56297

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

overlaycheck/overlaycheck

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,19 @@ sub parse_readme
394394
if ($blank_count == 2)
395395
{
396396
error("Missing params for overlay $overlay ($linenum)") if (!$params);
397-
$overlays->{ $overlay } = [ sort(@{$params || []}) ];
397+
if (ref $params)
398+
{
399+
$overlays->{ $overlay } = [ sort(@{$params}) ];
400+
}
401+
elsif ($params)
402+
{
403+
$overlays->{ $overlay } = $params;
404+
}
405+
else
406+
{
407+
$overlays->{ $overlay } = [ ];
408+
}
409+
398410
$overlay = undef;
399411
$params = undef;
400412
$in_params = 0;
@@ -429,6 +441,11 @@ sub parse_readme
429441
{
430442
error("Bad formatting in README ($linenum)") if ($1 ne ' ');
431443
error("Info label with no Name? ($linenum)") if (!$overlay);
444+
my $info = $2;
445+
if ($2 =~ /^See ($word_pattern)(?:\s+\(.*)?$/)
446+
{
447+
$params = $1;
448+
}
432449
}
433450
elsif ($line =~ /^Load:(\s*)(.*)\s*$/)
434451
{
@@ -518,6 +535,25 @@ sub parse_readme
518535
}
519536
}
520537

538+
# Resolve inter-overlay ("See") references
539+
540+
foreach my $overlay (keys(%$overlays))
541+
{
542+
my $src = $overlays->{$overlay};
543+
if (!ref $src)
544+
{
545+
$src = $overlays->{$src};
546+
if (ref $src)
547+
{
548+
$overlays->{$overlay} = $src;
549+
}
550+
else
551+
{
552+
error("Chained 'See' link from $overlay to $src") if (!ref $src)
553+
}
554+
}
555+
}
556+
521557
return $overlays;
522558
}
523559

0 commit comments

Comments
 (0)