Skip to content

Commit

Permalink
Update verify script to support explicit section ID links
Browse files Browse the repository at this point in the history
  • Loading branch information
sluicing authored and bagder committed Dec 28, 2023
1 parent 34f936e commit 8eb1bf3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
27 changes: 21 additions & 6 deletions .github/scripts/verify-titles.pl
Original file line number Diff line number Diff line change
@@ -1,27 +1,42 @@
#!/usr/bin/perl
#!/usr/bin/perl -w

my $sum = shift @ARGV;

# Figure out all files in right order
open(F, "<$sum");
while(<F>) {
if($_ =~ /\[(.*)\]\(([^\)]*)\)/) {
if ($_ =~ /\[(.*)\]\(([^\)\#]*)\#([^\)]+)\)/) {
my ($title, $file, $section_id) = ($1, $2, $3);
push @files, $file;
$title{$file} = $title;
$sections{$file} = $section_id;
}
elsif($_ =~ /\[(.*)\]\(([^\)]*)\)/) {
my ($title, $file) = ($1, $2);
push @files, $file;
$title{$file} = $title;
}
}
close(F);

my $errors = 0;

sub check {
my ($f) = @_;
open(F, "<$f");
open(F, "<$f") || die("ouch $f");
while(<F>) {
if(/^# (.*)/) {
# verify
if($1 ne $title{$f}) {
my $expected;
if(exists $sections{$f}) {
# This file was linked from SUMMARY.md with a section header
$expected = "$title{$f} {#$sections{$f}}";
} else {
# This file was linked with no section header
$expected = $title{$f};
}
if ($1 ne $expected) {
printf STDERR "$f says '%s', not '%s' like SUMMARY.md\n",
$1, $title{$f};
$1, $expected;
$errors++;
}
last;
Expand Down
2 changes: 1 addition & 1 deletion SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,4 @@
* [Continuous Integration](internals/tests/ci.md)
* [Autobuilds](internals/tests/autobuilds.md)
* [Torture](internals/tests/torture.md)
* [Index](bookindex.md)
* [Index](bookindex.md#everything-curl-index)

0 comments on commit 8eb1bf3

Please sign in to comment.