public static void main(String[] args) throws Exception {
    final String OUTPUT_ARGUMENT = "output";

    Options options = new Options();
    options.addOption(Option.builder().longOpt(OUTPUT_ARGUMENT).desc(
        "The absolute location of the index.md file to generate").required().type(
            String.class).hasArg().valueSeparator(' ').build());

    CommandLineParser parser = new DefaultParser();
    CommandLine line = parser.parse(options, args);
    String outputFile = (String) line.getParsedOptionValue(OUTPUT_ARGUMENT);

    // first, sort all of the fields by their keys
    SortedMap<String, Field> sortedFields = new TreeMap<>();
    List<Field> fields = new ArrayList<>(500);
    for (Field field : Configuration.class.getFields()) {
      if (field.getType() != ConfigurationProperty.class) {
        continue;
      }

      fields.add(field);
      ConfigurationProperty<?> configurationProperty = (ConfigurationProperty<?>) field.get(null);
      sortedFields.put(configurationProperty.getKey(), field);
    }

    // build the table header
    StringBuilder allPropertiesBuffer = new StringBuilder("| Property Name | Description | Default |");
    allPropertiesBuffer.append(System.lineSeparator());
    allPropertiesBuffer.append("| --- | --- | --- |");
    allPropertiesBuffer.append(System.lineSeparator());

    // now that the keys are ordered, generate  the bulk of the Markdown - the property table
    for (String fieldKey : sortedFields.keySet()) {
      // see which annotation the element has - we only care about the base Markdown one now
      Field field = sortedFields.get(fieldKey);
      Markdown markdown = field.getAnnotation(Markdown.class);
      if( null == markdown ){
        ConfigurationMarkdown configMarkdown = field.getAnnotation(ConfigurationMarkdown.class);
        markdown = configMarkdown.markdown();
      }

      // skip internal properties
      if( markdown.internal() ) {
        continue;
      }

      ConfigurationProperty<?> configurationProperty = (ConfigurationProperty<?>) field.get(null);
      String key = configurationProperty.getKey();
      Object defaultValue = configurationProperty.getDefaultValue();

      // | foo.key | description |
      // build the description, which includes examples and related properties
      allPropertiesBuffer.append("| ").append(key).append(" | ");
      StringBuilder description = new StringBuilder(markdown.description());
      if( StringUtils.isNotEmpty(markdown.relatedTo()) ){
        String relatedTo = String.format(MARKDOWN_RELATED_TO_TEMPLATE, markdown.relatedTo());
        description.append(HTML_BREAK_TAG).append(HTML_BREAK_TAG).append(relatedTo);
      }

      // use HTML to build a list of examples inside of the markdown table
      if( markdown.examples().length > 0 ){
        description.append(HTML_BREAK_TAG).append(HTML_BREAK_TAG);
        description.append("The following are examples of valid values:").append("<ul>");
        for( String example : markdown.examples() ){
          description.append("<li>").append("`").append(example).append("`");
        }
        description.append("</ul>");
      }

      allPropertiesBuffer.append(description);
      allPropertiesBuffer.append(" |");

      // append the default value and then close the table row
      if( null != defaultValue && StringUtils.isNotEmpty(defaultValue.toString()) ){
        allPropertiesBuffer.append("`").append(defaultValue).append("`");
      }

      allPropertiesBuffer.append(" | ").append(System.lineSeparator());
    }

    // now write out specific groupings
    StringBuilder baselineBuffer = new StringBuilder(1024);
    for( ConfigurationGrouping grouping : ConfigurationGrouping.values() ){
      baselineBuffer.append("#### ").append(grouping);
      baselineBuffer.append(System.lineSeparator());
      baselineBuffer.append("| Property Name | ");

      // 10 Hosts | 100 Hosts | 500 Hosts |
      for( ClusterSizeType clusterSizeType : ClusterSizeType.values() ){
        baselineBuffer.append(clusterSizeType).append( " | ");
      }

      // print the table heading separator
      baselineBuffer.append(System.lineSeparator());
      baselineBuffer.append("| --- | --- | --- | --- | --- |");
      baselineBuffer.append(System.lineSeparator());

      for (Field field : fields) {
        ConfigurationMarkdown configMarkdown = field.getAnnotation(ConfigurationMarkdown.class);
        if( null == configMarkdown || configMarkdown.group() != grouping ) {
          continue;
        }

        ConfigurationProperty<?> configurationProperty = (ConfigurationProperty<?>) field.get(null);

        ClusterScale[] scaleValues = configMarkdown.scaleValues();
        SortedMap<ClusterSizeType, String> miniSort = new TreeMap<>();
        for( ClusterScale clusterScale : scaleValues ){
          miniSort.put(clusterScale.clusterSize(), clusterScale.value());
        }

        baselineBuffer.append("| ").append(configurationProperty.getKey()).append(" | ");
        for( ClusterSizeType clusterSizeType : miniSort.keySet() ){
          baselineBuffer.append(miniSort.get(clusterSizeType)).append( " | ");
        }

        baselineBuffer.append(System.lineSeparator());
      }

      baselineBuffer.append(System.lineSeparator());
    }

    // replace the tokens in the markdown template and write out the final MD file
    InputStream inputStream = null;
    try {
      if (System.getProperties().containsKey(AMBARI_CONFIGURATION_MD_TEMPLATE_PROPERTY)) {
        inputStream = new FileInputStream(System.getProperties().getProperty(AMBARI_CONFIGURATION_MD_TEMPLATE_PROPERTY));
      } else {
        inputStream = Configuration.class.getResourceAsStream(MARKDOWN_TEMPLATE_FILE);
      }
      String template = IOUtils.toString(inputStream);
      String markdown = template.replace(MARKDOWN_CONFIGURATION_TABLE_KEY, allPropertiesBuffer.toString());
      markdown = markdown.replace(MARKDOWN_BASELINE_VALUES_KEY, baselineBuffer.toString());

      File file = new File(outputFile);
      FileUtils.writeStringToFile(file, markdown, Charset.defaultCharset());
      System.out.println("Successfully created " + outputFile);
      LOG.info("Successfully created {}", outputFile);
    } finally {
      IOUtils.closeQuietly(inputStream);
    }
  }
Generates a markdown table which includes:
<ul>
<li>Property key name</li>
<li>Description</li>
<li>Default value</li>
<li>Recommendended baseline values</li>
<ul>

@param args
@throws Exception
ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java