public String toEnrichedRst() {
        StringBuilder b = new StringBuilder();

        String lastKeyGroupName = "";
        for (ConfigKey key : sortedConfigs()) {
            if (key.internalConfig) {
                continue;
            }
            if (key.group != null) {
                if (!lastKeyGroupName.equalsIgnoreCase(key.group)) {
                    b.append(key.group).append("\n");

                    char[] underLine = new char[key.group.length()];
                    Arrays.fill(underLine, '^');
                    b.append(new String(underLine)).append("\n\n");
                }
                lastKeyGroupName = key.group;
            }

            getConfigKeyRst(key, b);

            if (key.dependents != null && key.dependents.size() > 0) {
                int j = 0;
                b.append("  * Dependents: ");
                for (String dependent : key.dependents) {
                    b.append("``");
                    b.append(dependent);
                    if (++j == key.dependents.size())
                        b.append("``");
                    else
                        b.append("``, ");
                }
                b.append("\n");
            }
            b.append("\n");
        }
        return b.toString();
    }
@Test
    public void toEnrichedRst() {
        final ConfigDef def = new ConfigDef()
                .define("opt1.of.group1", Type.STRING, "a", ValidString.in("a", "b", "c"), Importance.HIGH, "Doc doc.",
                        "Group One", 0, Width.NONE, "..", Collections.emptyList())
                .define("opt2.of.group1", Type.INT, ConfigDef.NO_DEFAULT_VALUE, Importance.MEDIUM, "Doc doc doc.",
                        "Group One", 1, Width.NONE, "..", Arrays.asList("some.option1", "some.option2"))
                .define("opt2.of.group2", Type.BOOLEAN, false, Importance.HIGH, "Doc doc doc doc.",
                        "Group Two", 1, Width.NONE, "..", Collections.emptyList())
                .define("opt1.of.group2", Type.BOOLEAN, false, Importance.HIGH, "Doc doc doc doc doc.",
                        "Group Two", 0, Width.NONE, "..", singletonList("some.option"))
                .define("poor.opt", Type.STRING, "foo", Importance.HIGH, "Doc doc doc doc.");

        final String expectedRst =
                "``poor.opt``\n" +
                "  Doc doc doc doc.\n" +
                "\n" +
                "  * Type: string\n" +
                "  * Default: foo\n" +
                "  * Importance: high\n" +
                "\n" +
                "Group One\n" +
                "^^^^^^^^^\n" +
                "\n" +
                "``opt1.of.group1``\n" +
                "  Doc doc.\n" +
                "\n" +
                "  * Type: string\n" +
                "  * Default: a\n" +
                "  * Valid Values: [a, b, c]\n" +
                "  * Importance: high\n" +
                "\n" +
                "``opt2.of.group1``\n" +
                "  Doc doc doc.\n" +
                "\n" +
                "  * Type: int\n" +
                "  * Importance: medium\n" +
                "  * Dependents: ``some.option1``, ``some.option2``\n" +
                "\n" +
                "Group Two\n" +
                "^^^^^^^^^\n" +
                "\n" +
                "``opt1.of.group2``\n" +
                "  Doc doc doc doc doc.\n" +
                "\n" +
                "  * Type: boolean\n" +
                "  * Default: false\n" +
                "  * Importance: high\n" +
                "  * Dependents: ``some.option``\n" +
                "\n" +
                "``opt2.of.group2``\n" +
                "  Doc doc doc doc.\n" +
                "\n" +
                "  * Type: boolean\n" +
                "  * Default: false\n" +
                "  * Importance: high\n" +
                "\n";

        assertEquals(expectedRst, def.toEnrichedRst());
    }