@Test
	public void doIt() {
		out.println("[[shell-command-reference]]");
		out.println("== XD Shell Command Reference");
		out.println("Below is a reference list of all Spring XD specific commands you can use in the link:Shell#interactive-shell[XD Shell].\n");


		GenericApplicationContext ctx = new GenericApplicationContext();
		ctx.getBeanFactory().registerSingleton("commandLine", new CommandLine(null, 100, null, false));
		XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(ctx);
		reader.loadBeanDefinitions("classpath*:META-INF/spring/spring-shell-plugin.xml");
		ctx.refresh();

		Comparator<Class<? extends CommandMarker>> comparator = new Comparator<Class<? extends CommandMarker>>() {

			@Override
			public int compare(Class<? extends CommandMarker> arg0, Class<? extends CommandMarker> arg1) {
				List<Class<? extends CommandMarker>> sorted = new ArrayList<Class<? extends CommandMarker>>(
						titles.keySet());
				int diff = sorted.indexOf(arg0) - sorted.indexOf(arg1);
				return diff != 0 ? diff : arg0.getSimpleName().compareTo(arg1.getSimpleName());
			}
		};

		final Map<Class<? extends CommandMarker>, Map<CliCommand, List<CliOption>>> plugins = new TreeMap<>(comparator);

		Map<String, CommandMarker> beans = BeanFactoryUtils.beansOfTypeIncludingAncestors(ctx, CommandMarker.class);
		final MethodFilter filter = new MethodFilter() {

			@Override
			public boolean matches(Method method) {
				return method.getAnnotation(CliCommand.class) != null;
			}
		};

		CommandComparator commandComparator = new CommandComparator();

		for (CommandMarker plugin : beans.values()) {
			Map<CliCommand, List<CliOption>> commands = new TreeMap<>(commandComparator);
			plugins.put(plugin.getClass(), commands);
			ReflectionUtils.doWithMethods(plugin.getClass(), new CommandsCollector(commands), filter);
		}

		String lastTitleUsed = null;
		for (Class<? extends CommandMarker> plugin : plugins.keySet()) {
			// == Stream Commands
			String title = titleFor(plugin);
			if (lastTitleUsed == null || !lastTitleUsed.equals(title)) {
				out.printf("=== %s%n", title);
				lastTitleUsed = title;
			}
			Map<CliCommand, List<CliOption>> commands = plugins.get(plugin);

			for (CliCommand command : commands.keySet()) {
				// === stream create
				out.printf("==== %s%n", pt(check(command.value()[0], COMMAND_FORMAT)));
				// Create a new stream definition.
				out.printf("%s.%n%n", pt(check(command.help(), COMMAND_HELP)));
				// stream create [--name]=<name> [--definition=<definition>]
				out.printf("    %s", command.value()[0]);
				for (CliOption option : commands.get(command)) {
					String paramName = check(paramName(option), OPTION_FORMAT);
					String optionText = String.format("<%s>", paramName);
					if (valueOptional(option)) {
						optionText = String.format("--%s [%s]", paramName, optionText);
					}
					else if (keyOptional(option)) {
						optionText = String.format("[--%s] %s", paramName, optionText);
					}
					else {
						optionText = String.format("--%s %s", paramName, optionText);
					}
					if (!option.mandatory()) {
						optionText = String.format("[%s]", optionText);
					}
					if (option.mandatory() && valueOptional(option)) {
						// This combination does not make sense. Or does it?
						throw new IllegalStateException("" + command + " " + option);
					}
					out.printf(" %s", optionText);
				}
				out.println("");
				out.println();

				// *definition*:: the stream definition
				for (CliOption option : commands.get(command)) {
					out.printf("*%s*:: %s.", pt(paramName(option)), pt(check(option.help(), OPTION_HELP)));
					if (!option.mandatory()) {
						// There can be non-mandatory, w/o default options (e.g. mutually exclusive, with 1 required,
						// options)
						if (!"__NULL__".equals(option.unspecifiedDefaultValue())) {
							out.printf(" *(default: `%s`", option.unspecifiedDefaultValue());
							if (valueOptional(option)) {
								if (option.specifiedDefaultValue().equals(option.unspecifiedDefaultValue())) {
									throw new IllegalStateException("" + option);
								}

								out.printf(", or `%s` if +--%s+ is specified without a value",
										option.specifiedDefaultValue(), paramName(option));
							}
							out.printf(")*");
						}
					}
					else {
						out.printf(" *(required)*");
					}
					out.printf("%n");
				}

				out.println();
			}
			out.println();
		}
		ctx.close();
	}
A mapping from class to Title in the doc. Insertion order will become rendering order.
documentation-toolchain/src/test/java/org/springframework/xd/documentation/ShellReferenceDoc.java