From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id E81181FF380
	for <inbox@lore.proxmox.com>; Fri, 19 Apr 2024 11:06:03 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 5AE20347E;
	Fri, 19 Apr 2024 11:05:46 +0200 (CEST)
From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Fri, 19 Apr 2024 11:05:14 +0200
Message-ID: <20240419090519.291775-9-c.heiss@proxmox.com>
X-Mailer: git-send-email 2.44.0
In-Reply-To: <20240419090519.291775-1-c.heiss@proxmox.com>
References: <20240419090519.291775-1-c.heiss@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.002 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: [pve-devel] [RFC PATCH docs 08/13] scan-adoc-refs: enable building
 pages from proxmox-docs-common/ subdir
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

Signed-off-by: Christoph Heiss <c.heiss@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



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel