diff options
author | Stefan Sauer <ensonic@users.sf.net> | 2015-06-17 22:53:43 +0200 |
---|---|---|
committer | Stefan Sauer <ensonic@users.sf.net> | 2015-06-24 14:35:19 +0200 |
commit | 3a3d70d24217c2ea7197d50363ea82908e3d5473 (patch) | |
tree | badfb839bee06de018cd668d4b3f68593104bd1a /gtkdoc-rebase.in | |
parent | 02e545371e2132a97458888895cacf57b8c0f83a (diff) | |
download | gtk-doc-3a3d70d24217c2ea7197d50363ea82908e3d5473.tar.gz |
index.sgml: stop generating index.sgml files
Use the data from devhelp2 files. Saves diskspace and makes the html phase about 10% faster.
Fixes #742404
Diffstat (limited to 'gtkdoc-rebase.in')
-rw-r--r-- | gtkdoc-rebase.in | 72 |
1 files changed, 64 insertions, 8 deletions
diff --git a/gtkdoc-rebase.in b/gtkdoc-rebase.in index 202a348..abade25 100644 --- a/gtkdoc-rebase.in +++ b/gtkdoc-rebase.in @@ -155,21 +155,50 @@ sub ScanDirectory { } my $file; + my $onlinedir; + my $have_index = 0; foreach $file (readdir(HTMLDIR)) { if ($file eq '.' or $file eq '..') { next; } elsif (-d "$dir/$file") { push @subdirs, $file; + next; + } + if ($file =~ m/\.devhelp2$/) { + print "Reading index from $file\n" if $VERBOSE; + my $o = &ReadDevhelp($dir, $file); + # Prefer this location over possibly stale index.sgml + if ($o) { + $onlinedir = $o; + } + $have_index = 1; } - elsif ($file eq "index.sgml") { - &AddMap($dir); + if (!$onlinedir and ($file eq "index.sgml")) { + print "Reading index from index.sgml\n" if $VERBOSE; + $onlinedir = &ReadIndex($dir, $file); + $have_index = 1; } elsif ($file eq "index.sgml.gz") { - print "Please fix https://bugs.launchpad.net/ubuntu/+source/gtk-doc/+bug/77138\n"; + # debian/ubuntu started to compress this as index.sgml.gz :/ + print <<EOF; +Please fix https://bugs.launchpad.net/ubuntu/+source/gtk-doc/+bug/77138 . For now run: +gunzip $file +EOF + } + elsif ($file =~ m/\.devhelp2.gz$/) { + # debian/ubuntu started to compress this as *devhelp2.gz :/ + print <<EOF; +Please fix https://bugs.launchpad.net/ubuntu/+source/gtk-doc/+bug/1466210 . For now run: +gunzip $file +EOF } + # we could consider supporting: use IO::Zlib; } closedir (HTMLDIR); + if ($have_index) { + &AddMap($dir, $onlinedir); + } # Now recursively scan the subdirectories. my $d; @@ -179,12 +208,30 @@ sub ScanDirectory { } -sub AddMap { - my ($dir) = @_; - my $file = "$dir/index.sgml"; - my ($onlinedir, $package); +sub ReadDevhelp { + my ($dir, $file) = @_; + my $onlinedir; + + open(INDEXFILE, "$dir/$file") || die "Can't open $dir/$file: $!"; + while (<INDEXFILE>) { + # online must come before chapter/functions + last if m/<(chapters|functions)/; + if (m/ online="([^"]*)"/) { + $onlinedir = $1; + # Remove trailing non-directory component. + $onlinedir =~ s#(.*/).*#$1#; + } + } + close (INDEXFILE); + return $onlinedir; +} - open(INDEXFILE, $file) || die "Can't open $file: $!"; + +sub ReadIndex { + my ($dir, $file) = @_; + my $onlinedir; + + open(INDEXFILE, "$dir/$file") || die "Can't open $dir/$file: $!"; while (<INDEXFILE>) { # ONLINE must come before any ANCHORs last if m/^<ANCHOR/; @@ -195,6 +242,13 @@ sub AddMap { } } close (INDEXFILE); + return $onlinedir; +} + + +sub AddMap { + my ($dir, $onlinedir) = @_; + my $package; $dir =~ s#/?$#/#; ($package = $dir) =~ s#.*/([^/]+)/#$1#; @@ -205,6 +259,8 @@ sub AddMap { print "On-line location of $package: $onlinedir\n" if $VERBOSE; $OnlineMap{ $package } = $onlinedir; $RevMap{ $onlinedir } = $package; + } else { + print "No On-line location for $package found\n" if $VERBOSE; } print "Local location of $package: $dir\n" if $VERBOSE; $LocalMap{ $package } = $dir; |