X-Git-Url: https://git.proxmox.com/?p=pve-docs.git;a=blobdiff_plain;f=asciidoc-pve.in;h=d1a754d5a0f5034d15e4f95a4287d4065b12c1c8;hp=e298abfed0551e1e447754ddd7816dbdef00635d;hb=73b78e5efba1c8a919d901549a7c273f04856f7c;hpb=fd02ab9033cacd7a6f0e2e2c5a5db0638564069b diff --git a/asciidoc-pve.in b/asciidoc-pve.in index e298abf..d1a754d 100644 --- a/asciidoc-pve.in +++ b/asciidoc-pve.in @@ -23,13 +23,13 @@ while () { $data_str .= $_; } my $fileinfo = decode_json($data_str); -my $tmpprefix = ".asciidoc-pve-tmp_"; +my $tmpprefix = '.asciidoc-pve-tmp'.$$.'_'; my $adoc_source_dir = "/usr/share/pve-doc-generator"; # inside pve-docs source dir? -if (-f "attributes.txt" && -f "pve-admin-guide.adoc") { - $adoc_source_dir = "." +if (-f "asciidoc-pve.in" && -f "pve-admin-guide.adoc") { + $adoc_source_dir = getcwd(); } my $prepared_files = {}; @@ -146,7 +146,10 @@ sub replace_man_xref { die "xref: no text for man page link '$blockid'\n" if !$text; my $section = $fileinfo->{mansection}->{manvolnum}->{$link}; - die "link target is not a manual page" if !defined($section); + if (!defined($section)) { + warn "link '$blockid' target '$link' is not a manual page, ignoring\n"; + return "$text"; + } if ($man_target eq 'html') { @@ -234,6 +237,12 @@ sub prepare_adoc_file { next; } + if ($line =~ m/xref:\S+?\[[^\]]*$/) { + die "possible xref spanning multiple lines in '$filename':\n(line $.): $line\n"; + } + if ($line =~ m/<<((?!\>\>).)*$/) { + die "possible xref spanning multiple lines in '$filename':\n(line $.): $line\n"; + } # fix xrefs $line =~ s/xref:([^\s\[\]]+)\[([^\]]*)\]/replace_xref(${target_env},$1,$2)/ge; @@ -262,7 +271,7 @@ sub compile_asciidoc { die "too many arguments...\n"; my $outfilemap = $fileinfo->{outfile}->{$env}->{$infile} || - die "no output file mapping '$infile => $outfile' ($env)"; + die "no output file mapping for '$infile' ($env)"; if ($man_target eq 'html') { $outfilemap .= '.html'; @@ -270,8 +279,12 @@ sub compile_asciidoc { $outfilemap .= '-plain.html'; } - die "wrong output file name '$outfile != $outfilemap' ($env)" - if $outfile ne $outfilemap; + if (defined($outfile)) { + die "wrong output file name '$outfile != $outfilemap' ($env)" + if $outfile ne $outfilemap; + } else { + $outfile = $outfilemap; + } defined($fileinfo->{titles}->{$env}) || die "unknown environment '$env'"; @@ -290,7 +303,12 @@ sub compile_asciidoc { $leveloffset = - $doctype; - my $date = `date`; + my $date; + if (defined($ENV{SOURCE_DATE_EPOCH})) { + $date = `date -d "\@$ENV{SOURCE_DATE_EPOCH}"`; + } else { + $date = `date`; + } chomp $date; my $attributes = { @@ -298,6 +316,7 @@ sub compile_asciidoc { leveloffset => $leveloffset, revnumber => $release, revdate => $date, + 'footer-style' => 'revdate', }; my $mansection = $fileinfo->{mansection}->{$env}->{$infile}; @@ -331,7 +350,9 @@ sub compile_asciidoc { # section like footnotes, so we cannot use a2x. # We use xmlto instead. - my $cmd = ['asciidoc', '-dmanpage', '-bdocbook', '-a', 'docinfo1']; + my $cmd = ['asciidoc', '-dmanpage', '-bdocbook', + '-f', "$adoc_source_dir/asciidoc/asciidoc-pve.conf", + '-a', 'docinfo1']; foreach my $key (keys %$attributes) { my $value = $attributes->{$key}; @@ -373,19 +394,16 @@ sub compile_asciidoc { $attributes->{icons} = undef; $attributes->{'data-uri'} = undef; - my $cmd = ['asciidoc']; + my $cmd = ['asciidoc', + '-f', "$adoc_source_dir/asciidoc/asciidoc-pve.conf", + ]; if (($env eq 'wiki') || (($env eq 'manvolnum') && ($man_target eq 'wiki'))) { - push @$cmd, '-s'; - - if (-f "./asciidoc/mediawiki.conf") { - my $cwd = getcwd(); - push @$cmd, '-b', "$cwd/asciidoc/mediawiki"; - } else { - push @$cmd, '-b', "mediawiki"; - } + push @$cmd, '-b', "$adoc_source_dir/asciidoc/mediawiki"; + } else { + push @$cmd, '-b', "$adoc_source_dir/asciidoc/pve-html"; } foreach my $key (keys %$attributes) {