From b328ed4d18c1cf8488a9e5c611c33d1cdb8ae1de Mon Sep 17 00:00:00 2001 From: Philip Crotwell Date: Thu, 4 Mar 2021 15:16:27 -0500 Subject: [PATCH] add xref for subcommands --- .../java/picocli/codegen/docgen/manpage/ManPageGenerator.java | 3 ++- .../src/test/resources/manpagegenerator/main_class.adoc | 2 +- .../manpagegenerator/top-level-command-subcommand.adoc | 2 +- .../test/resources/manpagegenerator/top-level-command.adoc | 4 ++-- picocli-codegen/src/test/resources/testHidden.manpage.adoc | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/picocli-codegen/src/main/java/picocli/codegen/docgen/manpage/ManPageGenerator.java b/picocli-codegen/src/main/java/picocli/codegen/docgen/manpage/ManPageGenerator.java index 7e6871a47..18fbd5b5f 100644 --- a/picocli-codegen/src/main/java/picocli/codegen/docgen/manpage/ManPageGenerator.java +++ b/picocli-codegen/src/main/java/picocli/codegen/docgen/manpage/ManPageGenerator.java @@ -656,7 +656,8 @@ static void genCommands(PrintWriter pw, CommandSpec spec) { Text namesText = subHelp.commandNamesText(", "); String names = namesText.toString(); - pw.printf("%s::%n", names); + String xrefname = makeFileName(subHelp.commandSpec()); + pw.printf("xref:%s[%s]::%n", xrefname, names); CommandLine.Model.UsageMessageSpec usage = subHelp.commandSpec().usageMessage(); String header = !empty(usage.header()) diff --git a/picocli-codegen/src/test/resources/manpagegenerator/main_class.adoc b/picocli-codegen/src/test/resources/manpagegenerator/main_class.adoc index d61a534cf..334e8ba58 100644 --- a/picocli-codegen/src/test/resources/manpagegenerator/main_class.adoc +++ b/picocli-codegen/src/test/resources/manpagegenerator/main_class.adoc @@ -44,7 +44,7 @@ __:: // tag::picocli-generated-man-section-commands[] == Commands -*gen-manpage*:: +xref:main_class-gen-manpage.adoc[*gen-manpage*]:: Generates man pages for all commands in the specified directory. // end::picocli-generated-man-section-commands[] diff --git a/picocli-codegen/src/test/resources/manpagegenerator/top-level-command-subcommand.adoc b/picocli-codegen/src/test/resources/manpagegenerator/top-level-command-subcommand.adoc index 5867bab17..4e1ce7691 100644 --- a/picocli-codegen/src/test/resources/manpagegenerator/top-level-command-subcommand.adoc +++ b/picocli-codegen/src/test/resources/manpagegenerator/top-level-command-subcommand.adoc @@ -47,7 +47,7 @@ Example subcommand // tag::picocli-generated-man-section-commands[] == Commands -*gen-manpage*:: +xref:top-level-command-subcommand-gen-manpage.adoc[*gen-manpage*]:: Generates man pages for all commands in the specified directory. // end::picocli-generated-man-section-commands[] diff --git a/picocli-codegen/src/test/resources/manpagegenerator/top-level-command.adoc b/picocli-codegen/src/test/resources/manpagegenerator/top-level-command.adoc index 4e1bd341c..6dcdf0c06 100644 --- a/picocli-codegen/src/test/resources/manpagegenerator/top-level-command.adoc +++ b/picocli-codegen/src/test/resources/manpagegenerator/top-level-command.adoc @@ -50,10 +50,10 @@ example top-level command // tag::picocli-generated-man-section-commands[] == Commands -*subcommand*:: +xref:top-level-command-subcommand.adoc[*subcommand*]:: Example subcommand -*visible*:: +xref:top-level-command-visible.adoc[*visible*]:: Example visible subcommand // end::picocli-generated-man-section-commands[] diff --git a/picocli-codegen/src/test/resources/testHidden.manpage.adoc b/picocli-codegen/src/test/resources/testHidden.manpage.adoc index 6b1ead66f..dd7bf8056 100644 --- a/picocli-codegen/src/test/resources/testHidden.manpage.adoc +++ b/picocli-codegen/src/test/resources/testHidden.manpage.adoc @@ -50,7 +50,7 @@ This app does great things. // tag::picocli-generated-man-section-commands[] == Commands -*a-sub*:: +xref:testHidden-a-sub.adoc[*a-sub*]:: A sub command // end::picocli-generated-man-section-commands[]