From 8322b7bdf805c21fdf6e39d0b241b6a7e0cf74f0 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 15 Jun 2020 16:23:02 +0200 Subject: util/doc-install.pl: Update for Doxygen >= 1.8.16 Doxygen 1.8.16 and later does not store tag file names in the html files. * skeletonmm/doc/reference/meson.build: * util/doc-install.pl: Modify so that references to other modules are still updated in the html files when they are installed. --- util/doc-install.pl | 91 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 78 insertions(+), 13 deletions(-) mode change 100644 => 100755 util/doc-install.pl (limited to 'util') diff --git a/util/doc-install.pl b/util/doc-install.pl old mode 100644 new mode 100755 index 91d3bdc..4068002 --- a/util/doc-install.pl +++ b/util/doc-install.pl @@ -27,6 +27,7 @@ use Getopt::Long qw(:config no_getopt_compat no_ignore_case require_order bundli # Globals my $message_prefix; my %tags_hash; +my %subst_hash; my $book_base; my $perm_mode; my $target_dir; @@ -57,7 +58,8 @@ external documentation. Mandatory arguments to long options are mandatory for short options, too. --book-base=BASEPATH use reference BASEPATH for Devhelp book - -l, --tag-base=TAGFILE\@BASEPATH use BASEPATH for references from TAGFILE + -l, --tag-base=TAGFILE\@BASEPATH use BASEPATH for references from TAGFILE (Doxygen <= 1.8.15) + -l, --tag-base=s\@BASEPUB\@BASEPATH substitute BASEPATH for BASEPUB (Doxygen >= 1.8.16) -m, --mode=MODE override file permission MODE (octal) -t, --target-directory=DIRECTORY copy all SOURCE arguments into DIRECTORY -T, --no-target-directory treat DEST as normal file @@ -84,6 +86,23 @@ sub error (@) exit 1; } +sub substitute_pub($$) +{ + my ($pubpath, $ref_count) = @_; + foreach my $key (keys %subst_hash) + { + # Don't use m// or s/// here. $key may contain characters + # that are special in regular expressions. + if (substr($pubpath, 0, length($key)) eq $key) + { + substr($pubpath, 0, length($key)) = $subst_hash{$key}; + $$ref_count++; + last; + } + } + return $pubpath; +} + # Copy file to destination while translating references on the fly. # Sniff the content for the file type, as it is always read in anyway. sub install_file ($$$) @@ -97,16 +116,27 @@ sub install_file ($$$) or error('Failed to read ', $basename, ': ', $!); } - if (%tags_hash and $buf =~ m/\A(?> \s*)(?> (?> <[?!][^<]+ )* )\s]/sx) + if ((%tags_hash or %subst_hash) and $buf =~ m/\A(?> \s*)(?> (?> <[?!][^<]+ )* )\s]/sx) { + # Doxygen 1.8.15 and earlier stores the tag file name and BASEPATH in the html files. my $count = 0; my $total = $buf =~ s!(?<= \s) doxygen="((?> [^:"]+)):((?> [^"]*))" # doxygen="(TAGFILE):(BASEPATH)" (?> \s+) ((?> href|src) =") \2 ((?> [^"]*)") # (href|src=")BASEPATH(RELPATH") ! $3 . ((exists $tags_hash{$1}) ? (++$count, $tags_hash{$1}) : $2) . $4 !egsx; - my $change = $total ? "rewrote $count of $total" - : 'no'; + my $change = $total ? "rewrote $count of $total" : 'no'; + + if ($total == 0 and %subst_hash) + { + # Doxygen 1.8.16 and later does not store the tag file name and BASEPATH in the html files. + # The previous s!!! expression won't find anything to substitute. + $total = $buf =~ + s!(\s (?:href|src) = ") ([^"]+") # (href|src=")(BASEPUB RELPATH") + ! $1 . substitute_pub($2, \$count) + !egsx; + $change = $total ? "rewrote $count" : 'no'; + } notice('Translating ', $basename, ' (', $change, ' references)'); } elsif (defined($book_base) and $buf =~ m/\A(?> \s*)(?> (?> <[?!][^<]+ )* )