From 75808db17caf8b960b351e3408e74142f4c85aac Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:42:30 +0200 Subject: Adding upstream version 2.117.0. Signed-off-by: Daniel Baumann --- private/generate-html-docs | 115 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100755 private/generate-html-docs (limited to 'private/generate-html-docs') diff --git a/private/generate-html-docs b/private/generate-html-docs new file mode 100755 index 0000000..5fed4b7 --- /dev/null +++ b/private/generate-html-docs @@ -0,0 +1,115 @@ +#!/usr/bin/perl + +use v5.20; +use warnings; +use utf8; + +use Const::Fast; +use IPC::Run3; +use Pod::Simple::HTMLBatch; +use Unicode::UTF8 qw(encode_utf8); + +const my $EMPTY => q{}; + +my $destination = pop @ARGV; +my @input = @ARGV; + +push @input, './lib', './doc/tutorial' unless @input; +$destination //= './doc/api.html'; +my $lintian_version = guess_version(); + +if (!-d $destination) { + mkdir $destination + or die encode_utf8("could not create directory: $!"); +} + +my $convert = Pod::Simple::HTMLBatch->new; +$convert->html_render_class('My::Pod::Simple::XHTML'); +$convert->contents_page_start(header()); +# No footer - it contains a "current time" and is thus unreproducible +$convert->contents_page_end(q{}); +$convert->css_flurry(0); +$convert->batch_convert(\@input, $destination); + +print encode_utf8("HTML version available at $destination/index.html\n"); + +sub header { + + return <<"EOF"; + + + + Lintian (v$lintian_version) API doc + + + +

Lintian (v$lintian_version) API doc

+

Note: This API is not stable between releases.

+EOF +} + +sub guess_version { + my $version; + my $dist; + + my @dpkg_command = qw{dpkg-parsechangelog -c0}; + my $output; + + run3(\@dpkg_command, \undef, \$output); + my @lines = split(/\n/, $output); + + while (defined(my $line = shift @lines)) { + $version = $1 if $line =~ m{\A Version: \s*+ (\S++) \s* \Z}xsm; + $dist = $1 if $line =~ m{\A Distribution: \s*+ (\S++) \s* \Z}xsm; + } + + if ((not defined($dist) or $dist eq 'UNRELEASED') and -d '.git') { + + delete $ENV{'GITDIR'}; + + # For unreleased versions, git describe is probably a better + # choice when available. + my @command = qw(git describe); + my $guess; + run3(\@command, \undef, \$guess); + + chomp $guess; + $version = $guess + if $guess ne $EMPTY && $guess =~ m{\A \d+\. }xsm; + + # Ignore git being missing (or even failing to work) + # - the version being incorrect for non-release cases is + # not a major issue. + } + return $version; +} + +package My::Pod::Simple::XHTML; + +use strict; +use warnings; +use parent qw(Pod::Simple::XHTML); + +# Skip the version tag (incl. a date) to get reproducible output +sub version_tag_comment { + return q{}; +} + +sub batch_mode_page_object_init { + my ($self) = @_; + + $self->html_doctype( +'' + ); + + $self->html_charset('UTF-8'); + + return; +} + +# Local Variables: +# indent-tabs-mode: nil +# cperl-indent-level: 4 +# End: +# vim: syntax=perl sw=4 sts=4 sr et -- cgit v1.2.3