|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen stable-4.10] docs/gen-html-index: Extract titles from HTML documents
commit 0609dd1c5e81507a71a2d450fcdf14733ba81382
Author: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
AuthorDate: Fri Apr 6 19:09:02 2018 +0100
Commit: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
CommitDate: Wed Apr 25 14:25:03 2018 +0100
docs/gen-html-index: Extract titles from HTML documents
Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Release-acked-by: Juergen Gross <jgross@xxxxxxxx>
Acked-by: Lars Kurth <lars.kurth@xxxxxxxxxx>
(cherry picked from commit 7782db9260d4c6499458de4e8d9866bc0427e143)
[ Combined with: ]
docs/gen-html-index: Make HTML::TreeBuilder::XPath optional again
7782db9260d4 "docs/gen-html-index: Extract titles from HTML documents"
requires HTML::TreeBuilder::XPath.
This is sadly not as widely available as I had hoped. Work around
this problem by making the use of this module optional: instead of
`use'ing at the toplevel, we `require' it in the eval. If it's not
present, then the title is simply not extracted and the filename is
used as before, which is tolerable.
Also add some debugging.
Reported-by: Doug Goldstein <cardoe@xxxxxxxxxx>
Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
Reviewed-by: Doug Goldstein <cardoe@xxxxxxxxxx>
Tested-by: Doug Goldstein <cardoe@xxxxxxxxxx>
(cherry picked from commit 16fb4b5a9a79f95df17f10ba62e9f44d21cf89b5)
Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
docs/gen-html-index | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/docs/gen-html-index b/docs/gen-html-index
index e9792bf937..410674e594 100644
--- a/docs/gen-html-index
+++ b/docs/gen-html-index
@@ -20,8 +20,10 @@ our @dirs;
our %index;
our $outdir;
+our $debug;
-GetOptions("i=s" => sub { read_index(@_);} )
+GetOptions("i=s" => sub { read_index(@_);},
+ "D" => \$debug)
or die;
($outdir,@docs) = @ARGV;
@@ -64,6 +66,20 @@ sub make_linktext ($) {
return "$1($2)" if $l =~ m,^man/(.*)\.([0-9].*)\.html,;
$l =~ s/.(?:html|txt)$//g;
return $index{$l} if exists $index{$l};
+
+ my $from_html;
+ eval {
+ require HTML::TreeBuilder::XPath;
+ my $tree = new HTML::TreeBuilder::XPath;
+ my $f = "$outdir/$l.html";
+ open F, '<', $f or die "$l $f $!";
+ $tree->parse_file(\*F) or die;
+ close F;
+ $from_html = $tree->findvalue("/html/head/title");
+ };
+ print "$l: get title: $@" if $@ && $debug;
+ return $from_html if $from_html;
+
return basename($l);
}
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.10
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |