From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH common 3/3] fix #6656: cli handler: generate anchors for all (sub-)commands
Date: Tue, 12 Aug 2025 11:56:27 +0200 [thread overview]
Message-ID: <20250812095637.444463-4-c.heiss@proxmox.com> (raw)
In-Reply-To: <20250812095637.444463-1-c.heiss@proxmox.com>
First part of fixing #6656 [0].
The `cli_` prefix here is chosen to make them unambiguous.
For example, anchors for subsections in the QEMU top-level section are
named `qm_<something>`, which could potentially introduce conflicts
without the prefix.
[0] https://bugzilla.proxmox.com/show_bug.cgi?id=6656
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
src/PVE/CLIHandler.pm | 9 ++++++---
src/PVE/RESTHandler.pm | 2 ++
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/PVE/CLIHandler.pm b/src/PVE/CLIHandler.pm
index 82118a8..89cb7b7 100644
--- a/src/PVE/CLIHandler.pm
+++ b/src/PVE/CLIHandler.pm
@@ -233,7 +233,9 @@ sub generate_usage_str {
$oldclass = $class;
} elsif (defined($def->{$cmd}->{alias}) && ($format eq 'asciidoc')) {
-
+ my $safeprefix = $prefix =~ s/\s/_/rg;
+ my $safecmd = $cmd =~ s/\s/_/rg;
+ $str .= "[[cli_${safeprefix}_${safecmd}]]\n";
$str .=
"*$prefix $cmd*\n\nAn alias for '$prefix $def->{$cmd}->{alias}'.\n\n";
@@ -336,7 +338,8 @@ __PACKAGE__->register_method({
sub print_simple_asciidoc_synopsis {
$assert_initialized->();
- my $synopsis = "*${exename}* `help`\n\n";
+ my $synopsis = "[[cli_${exename}_help]]\n";
+ $synopsis .= "*${exename}* `help`\n\n";
$synopsis .= generate_usage_str('asciidoc');
return $synopsis;
@@ -345,7 +348,7 @@ sub print_simple_asciidoc_synopsis {
sub print_asciidoc_synopsis {
$assert_initialized->();
- my $synopsis = "";
+ my $synopsis = "[[cli_${exename}]]\n";
$synopsis .= "*${exename}* `<COMMAND> [ARGS] [OPTIONS]`\n\n";
diff --git a/src/PVE/RESTHandler.pm b/src/PVE/RESTHandler.pm
index 4c31ea1..82e6db5 100644
--- a/src/PVE/RESTHandler.pm
+++ b/src/PVE/RESTHandler.pm
@@ -820,6 +820,8 @@ sub getopt_usage {
}
if ($format eq 'asciidoc') {
+ my $safeprefix = $prefix =~ s/\s/_/rg;
+ $out .= "[[cli_${safeprefix}]]\n";
$out .= "*${prefix}*";
$out .= " `$args`" if $args;
$out .= " `[OPTIONS]`" if $opts;
--
2.50.1
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
next prev parent reply other threads:[~2025-08-12 9:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-12 9:56 [pve-devel] [PATCH common/docs 0/5] fix #6656: add clickable anchors for cli subcommands Christoph Heiss
2025-08-12 9:56 ` [pve-devel] [PATCH common 1/3] gitignore: add rules for more build artifacts Christoph Heiss
2025-09-05 18:45 ` [pve-devel] applied: " Thomas Lamprecht
2025-08-12 9:56 ` [pve-devel] [PATCH common 2/3] cli handler: drop unused subroutine Christoph Heiss
2025-09-05 18:45 ` [pve-devel] applied: " Thomas Lamprecht
2025-08-12 9:56 ` Christoph Heiss [this message]
2025-09-05 18:45 ` [pve-devel] applied: [PATCH common 3/3] fix #6656: cli handler: generate anchors for all (sub-)commands Thomas Lamprecht
2025-08-12 9:56 ` [pve-devel] [PATCH docs 4/5] fix #6656: asciidoc: add anchor links for paragraphs with ids Christoph Heiss
2025-09-05 19:06 ` [pve-devel] applied: " Thomas Lamprecht
2025-08-12 9:56 ` [pve-devel] [PATCH docs 5/5] update generated cli synopsis files Christoph Heiss
2025-09-05 19:06 ` Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250812095637.444463-4-c.heiss@proxmox.com \
--to=c.heiss@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox