[pve-devel] [RFC PATCH docs 08/13] scan-adoc-refs: enable building pages from proxmox-docs-common/ subdir

Christoph Heiss c.heiss at proxmox.com
Fri Apr 19 11:05:14 CEST 2024


Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
 Makefile                   |  6 ++++--
 asciidoc/asciidoc-pve.conf |  2 ++
 pve-doc-generator.mk.in    |  6 ++++++
 scan-adoc-refs             | 25 ++++++++++++++++---------
 4 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/Makefile b/Makefile
index 801a2a3..5b14e3d 100644
--- a/Makefile
+++ b/Makefile
@@ -26,9 +26,11 @@ all: index.html
 verify-images:
 	for i in ./images/screenshot/*.png; do ./png-verify.pl $$i; done
 
-ADOC_SOURCES_GUESS=$(filter-out %-synopsis.adoc %-opts.adoc %-table.adoc, $(wildcard *.adoc))
+ADOC_WILDCARD_SOURCES := *.adoc proxmox-docs-common/*.adoc proxmox-docs-common/partials/*.adoc
+ADOC_SOURCES_GUESS=$(filter-out %-synopsis.adoc %-opts.adoc %-table.adoc, $(wildcard $(ADOC_WILDCARD_SOURCES)))
+
 .pve-doc-depends link-refs.json: $(ADOC_SOURCES_GUESS) scan-adoc-refs
-	./scan-adoc-refs *.adoc --depends .pve-doc-depends.tmp > link-refs.json.tmp
+	./scan-adoc-refs $(ADOC_WILDCARD_SOURCES) --depends .pve-doc-depends.tmp > link-refs.json.tmp
 	@cmp --quiet .pve-doc-depends .pve-doc-depends.tmp || mv .pve-doc-depends.tmp .pve-doc-depends
 	@cmp --quiet link-refs.json link-refs.json.tmp || mv link-refs.json.tmp link-refs.json
 
diff --git a/asciidoc/asciidoc-pve.conf b/asciidoc/asciidoc-pve.conf
index 0c28298..47139b8 100644
--- a/asciidoc/asciidoc-pve.conf
+++ b/asciidoc/asciidoc-pve.conf
@@ -3,6 +3,8 @@
 proxmoxGmbh=Proxmox Server Solutions GmbH
 copyright=Proxmox Server Solutions GmbH
 pve=Proxmox VE
+product=Proxmox VE
+product-short=pve
 pricing-url=https://proxmox.com/en/proxmox-virtual-environment/pricing
 website=https://www.proxmox.com/
 forum-url=https://forum.proxmox.com/
diff --git a/pve-doc-generator.mk.in b/pve-doc-generator.mk.in
index 77fd4f6..a733966 100644
--- a/pve-doc-generator.mk.in
+++ b/pve-doc-generator.mk.in
@@ -71,9 +71,15 @@ endif
 %-plain.html: %.adoc ${PVE_COMMON_DOC_SOURCES}
 	${ASCIIDOC_PVE} compile-wiki -o $@ $*.adoc
 
+%-plain.html: proxmox-docs-common/%.adoc ${PVE_COMMON_DOC_SOURCES}
+	${ASCIIDOC_PVE} compile-wiki -o $@ proxmox-docs-common/$*.adoc
+
 chapter-%.html: %.adoc ${PVE_COMMON_DOC_SOURCES}
 	${ASCIIDOC_PVE} compile-chapter -o $@ $*.adoc
 
+chapter-%.html: proxmox-docs-common/%.adoc ${PVE_COMMON_DOC_SOURCES}
+	${ASCIIDOC_PVE} compile-chapter -o $@ proxmox-docs-common/$*.adoc
+
 %.1: %.adoc %.1-synopsis.adoc ${PVE_COMMON_DOC_SOURCES}
 	${ASCIIDOC_PVE} compile-man -o $@ $*.adoc
 	test -z "$${PVE_DOC_INSTANTVIEW}" || man -l $@
diff --git a/scan-adoc-refs b/scan-adoc-refs
index 9252701..fd74c20 100755
--- a/scan-adoc-refs
+++ b/scan-adoc-refs
@@ -5,6 +5,8 @@ use warnings;
 use Getopt::Long;
 use IO::File;
 use JSON;
+use Cwd qw(abs_path);
+use File::Spec;
 
 use Data::Dumper;
 
@@ -19,6 +21,7 @@ my $environments = {
     wiki => 1,
     manvolnum => 1,
     pvelogo => 0, # ignore
+    pve => 0,
 };
 
 my $fileinfo = {};
@@ -76,6 +79,12 @@ sub pop_environment {
 sub register_include {
     my ($filename, $include_filename, $env_list) = @_;
 
+    # get containing directory of the file that includes ..
+    my $reldir = (File::Spec->splitpath($filename))[1];
+    # .. and resolve the included filename relative to that
+    $include_filename = abs_path(File::Spec->join($reldir, $include_filename))
+	if $reldir;
+
     foreach my $e (@$env_list) {
 	$fileinfo->{include}->{$e}->{$filename}->{$include_filename} = 1;
     }
@@ -99,6 +108,7 @@ sub register_title {
 
     # fixme: what about other macros?
     $title =~ s/\{pve\}/Proxmox VE/g;
+    $title =~ s/\{product\}/Proxmox VE/g;
     $title =~ s!http://\S+\[(.*?)\]!$1!g;
 
     # register document title (onyl once)
@@ -269,23 +279,19 @@ foreach my $e (@$start_env) {
     my $toplevel_hash = $fileinfo->{toplevel}->{$e};
     foreach my $fn (sort keys %$toplevel_hash) {
 	my $mansection = $fileinfo->{mansection}->{manvolnum}->{$fn};
+	my $realfn = $fn;
+	$realfn =~ s/^proxmox-docs-common\///;
+	$realfn =~ s/\.adoc$//;
+
 	if ($e eq 'wiki') {
-	    my $realfn = $fn;
-	    $realfn =~ s/\.adoc$//;
 	    if (defined($mansection) && ($mansection == 5)) {
 		$realfn .= ".$mansection";
 	    }
 	    $realfn = "$realfn-plain.html";
-	    $fileinfo->{outfile}->{$e}->{$fn} = $realfn;
 	} elsif ($e eq 'manvolnum') {
-	    my $realfn = $fn;
-	    $realfn =~ s/\.adoc$//;
 	    die "toplevel file '$fn' is not marked as manual page!" if !$mansection;
 	    $realfn .= ".$mansection";
-	    $fileinfo->{outfile}->{$e}->{$fn} = $realfn;
 	} elsif ($e eq 'default') {
-	    my $realfn = $fn;
-	    $realfn =~ s/\.adoc$//;
 	    if (defined($mansection) && ($mansection == 5)) {
 		$realfn .= ".$mansection";
 		$realfn = "$realfn.html";
@@ -297,8 +303,9 @@ foreach my $e (@$start_env) {
 		    $realfn = "$realfn.html";
 		}
 	    }
-	    $fileinfo->{outfile}->{$e}->{$fn} = $realfn;
 	}
+
+	$fileinfo->{outfile}->{$e}->{$fn} = $realfn;
     }
 }
 
-- 
2.44.0





More information about the pve-devel mailing list