static void genOptions(PrintWriter pw, CommandSpec spec) {
        List<OptionSpec> options = new ArrayList<OptionSpec>(spec.options()); // options are stored in order of
                                                                              // declaration

        // remove hidden options
        for (Iterator<OptionSpec> iter = options.iterator(); iter.hasNext();) {
            if (iter.next().hidden()) {
                iter.remove();
            }
        }

        IOptionRenderer optionRenderer = spec.commandLine().getHelp().createDefaultOptionRenderer();
        IParamLabelRenderer paramLabelRenderer = spec.commandLine().getHelp().createDefaultParamLabelRenderer();
        IParameterRenderer parameterRenderer = spec.commandLine().getHelp().createDefaultParameterRenderer();

        List<ArgGroupSpec> groups = optionListGroups(spec);
        for (ArgGroupSpec group : groups) {
            options.removeAll(group.options());
        }

        if (options.isEmpty() && !spec.usageMessage().showEndOfOptionsDelimiterInUsageHelp()) {
            pw.printf("// tag::picocli-generated-man-section-options[]%n");
            pw.printf("// end::picocli-generated-man-section-options[]%n");
            pw.println();
            return;
        }
        pw.printf("// tag::picocli-generated-man-section-options[]%n");
        pw.printf("== Options%n");

        Comparator<OptionSpec> optionSort = spec.usageMessage().sortOptions()
                ? new SortByShortestOptionNameAlphabetically()
                : createOrderComparatorIfNecessary(spec.options());
        if (optionSort != null) {
            Collections.sort(options, optionSort); // default: sort options ABC
        }
        for (OptionSpec option : options) {
            writeOption(pw, optionRenderer, paramLabelRenderer, option);
        }

        if (spec.usageMessage().showEndOfOptionsDelimiterInUsageHelp()) {
            CommandLine cmd = new CommandLine(spec).setColorScheme(COLOR_SCHEME);
            CommandLine.Help help = cmd.getHelp();
            writeEndOfOptions(pw, optionRenderer, paramLabelRenderer, help.END_OF_OPTIONS_OPTION);
        }

        // now create a custom option section for each arg group that has a heading
        Collections.sort(groups, new SortByOrder<ArgGroupSpec>());
        for (ArgGroupSpec group : groups) {
            pw.println();
            String heading = makeHeading(group.heading(), "Options Group");
            pw.printf("== %s%n", COLOR_SCHEME.text(heading));

            for (PositionalParamSpec positional : group.positionalParameters()) {
                if (!positional.hidden()) {
                    writePositional(pw, positional, parameterRenderer, paramLabelRenderer);
                }
            }
            List<OptionSpec> groupOptions = new ArrayList<OptionSpec>(group.options());
            if (optionSort != null) {
                Collections.sort(groupOptions, optionSort);
            }
            for (OptionSpec option : groupOptions) {
                writeOption(pw, optionRenderer, paramLabelRenderer, option);
            }
        }
        pw.println();
        pw.printf("// end::picocli-generated-man-section-options[]%n");
        pw.println();
    }
Generates AsciiDoc files for the specified classes to the specified output
directory, optionally also generating template files in the
{@code customizablePagesDirectory} directory.

@param outdir                     Output directory to write the generated
                                  AsciiDoc files to.
@param customizablePagesDirectory Optional directory to write customizable
                                  man page template files. If
                                  non-{@code null}, an additional "template"
                                  file is created here for each generated
                                  manpage AsciiDoc file.
@param verbosity                  the length of this array determines
                                  verbosity during processing
@param overwriteCustomizablePages Overwrite existing man page templates. The
                                  default is false, meaning processing is
                                  aborted and the process exits with status
                                  code 4 if a man page template file already
                                  exists.
@param specs                      the Commands to generate AsciiDoc man pages
                                  for
@return the exit code
@throws IOException if a problem occurred writing to the file system
docs/genadoc.java