diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 21:12:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 21:12:02 +0000 |
commit | 77e50caaf2ef81cd91075cf836fed0e75718ffb4 (patch) | |
tree | 53b7b411290b63192fc9e924a3b6b65cdf67e9d0 /debian/vendor-h2o/misc/makedoc.pl | |
parent | Adding upstream version 1.8.3. (diff) | |
download | dnsdist-77e50caaf2ef81cd91075cf836fed0e75718ffb4.tar.xz dnsdist-77e50caaf2ef81cd91075cf836fed0e75718ffb4.zip |
Adding debian version 1.8.3-2.debian/1.8.3-2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/vendor-h2o/misc/makedoc.pl')
-rwxr-xr-x | debian/vendor-h2o/misc/makedoc.pl | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/debian/vendor-h2o/misc/makedoc.pl b/debian/vendor-h2o/misc/makedoc.pl new file mode 100755 index 0000000..b025536 --- /dev/null +++ b/debian/vendor-h2o/misc/makedoc.pl @@ -0,0 +1,69 @@ +#! /usr/bin/env perl + +use strict; +use warnings; +no warnings qw(once); + +use File::Basename qw(dirname); +use File::Path qw(mkpath); +use Scalar::Util qw(looks_like_number); +use Text::MicroTemplate qw(build_mt render_mt encoded_string); +use Text::MicroTemplate::File; + +my $mt = Text::MicroTemplate::File->new( + include_path => [ qw(../srcdoc/snippets .) ], +); + +die "Usage: $0 <src-file> <dst-file>\n" + unless @ARGV == 2; + +my ($src_file, $dst_file) = @ARGV; + +$main::context = { + filename => $dst_file, + code => build_mt( + '<pre><code><?= $_[0] ?></code></pre>', + ), + example => build_mt(<<'EOT', +<div class="example"> +<div class="caption">Example. <?= encoded_string($_[0]) ?></div> +<pre><code><?= $_[1] ?></code></pre> +</div> +EOT + ), + directive => sub { + my %args = @_; + $mt->wrapper_file("directive.mt", \%args); + }, + mruby_method => sub { + my %args = @_; + $mt->wrapper_file("mruby_method.mt", \%args); + }, + notes => [], + note => sub { + my ($index, $html); + if (looks_like_number($_[0])) { + $index = $_[0] < 0 ? scalar(@{$main::context->{notes}}) + $_[0] : $_[0]; + $html = $main::context->{notes}->[$index]; + } else { + $index = scalar @{$main::context->{notes}}; + $html = $_[0]; + push @{$main::context->{notes}}, encoded_string($html); + } + my $alt = $html; + $alt =~ s/<.*?>//g; + return render_mt( + '<sup><a href="#note_<?= $_[0] ?>" id="#cite_<?= $_[0] ?>" title="<?= $_[1] ?>"><?= $_[0] ?></sup></a></sup>', + $index + 1, + $alt, + ); + }, +}; +my $output = $mt->render_file($src_file); +mkpath(dirname($dst_file)); + +chmod 0666, $dst_file; +open my $dst_fh, '>:utf8', $dst_file + or die "failed to open file:$dst_file:$!"; +print $dst_fh $output; +close $dst_fh; |