accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmil...@apache.org
Subject [accumulo] branch master updated: Add experimental props to doc gen (#644)
Date Wed, 12 Sep 2018 21:12:17 GMT
This is an automated email from the ASF dual-hosted git repository.

mmiller pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/master by this push:
     new b1e742e  Add experimental props to doc gen (#644)
b1e742e is described below

commit b1e742e05325a119f665041ac37d2b9ecc366921
Author: Mike Miller <mmiller@apache.org>
AuthorDate: Wed Sep 12 17:12:13 2018 -0400

    Add experimental props to doc gen (#644)
    
    * Printed the experimental properties inline with all properties
    * Removed inner classes cluttering up ConfigurationDocGen
---
 .../accumulo/core/conf/ConfigurationDocGen.java    | 189 +++++++++------------
 1 file changed, 79 insertions(+), 110 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationDocGen.java b/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationDocGen.java
index ab48996..dacf09f 100644
--- a/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationDocGen.java
+++ b/core/src/main/java/org/apache/accumulo/core/conf/ConfigurationDocGen.java
@@ -28,134 +28,107 @@ import java.util.TreeMap;
  * presentable form.
  */
 class ConfigurationDocGen {
-  private abstract class Format {
-
-    abstract void beginSection(String section);
-
-    void generate() {
-      pageHeader();
-
-      beginTable("Property");
-      for (Property prop : sortedProps.values()) {
-        if (!prop.isExperimental()) {
-          if (prop.getType() == PropertyType.PREFIX) {
-            prefixSection(prop);
-          } else {
-            property(prop);
-          }
-        }
-      }
+  private PrintStream doc;
+  private final TreeMap<String,Property> sortedProps = new TreeMap<>();
 
-      beginSection("Property Types");
-      beginTable("Type");
-      propertyTypeDescriptions();
+  void generate() {
+    pageHeader();
 
-      doc.close();
+    beginTable("Property");
+    for (Property prop : sortedProps.values()) {
+      if (prop.getType() == PropertyType.PREFIX) {
+        prefixSection(prop);
+      } else {
+        property(prop);
+      }
     }
 
-    abstract void beginTable(String name);
-
-    abstract void pageHeader();
-
-    abstract void prefixSection(Property prefix);
-
-    abstract void property(Property prop);
-
-    abstract void propertyTypeDescriptions();
+    beginSection("Property Types");
+    beginTable("Type");
+    propertyTypeDescriptions();
 
+    doc.close();
   }
 
-  private class Markdown extends Format {
-
-    @Override
-    void beginSection(String section) {
-      doc.println("\n### " + section + "\n");
-    }
+  void beginSection(String section) {
+    doc.println("\n### " + section + "\n");
+  }
 
-    @Override
-    void beginTable(String name) {
-      doc.println("| " + name + " | Description |");
-      doc.println("|--------------|-------------|");
-    }
+  void beginTable(String name) {
+    doc.println("| " + name + " | Description |");
+    doc.println("|--------------|-------------|");
+  }
 
-    @Override
-    void pageHeader() {
-      doc.println("---");
-      doc.println("title: Server Properties");
-      doc.println("category: administration");
-      doc.println("order: 3");
-      doc.println("---\n");
-      doc.println("<!-- WARNING: Do not edit this file. It is a generated file"
-          + " that is copied from Accumulo build (from core/target/generated-docs)" + " -->\n");
-      doc.println("Below are properties set in `accumulo.properties` or the"
-          + " Accumulo shell that configure Accumulo servers (i.e tablet server,"
-          + " master, etc):\n");
-    }
+  void pageHeader() {
+    doc.println("---");
+    doc.println("title: Server Properties");
+    doc.println("category: administration");
+    doc.println("order: 3");
+    doc.println("---\n");
+    doc.println("<!-- WARNING: Do not edit this file. It is a generated file"
+        + " that is copied from Accumulo build (from core/target/generated-docs)" + " -->\n");
+    doc.println("Below are properties set in `accumulo.properties` or the"
+        + " Accumulo shell that configure Accumulo servers (i.e tablet server,"
+        + " master, etc). Properties labeled 'Experimental' could be part of an incomplete"
+        + " feature or have a higher risk of changing in the future.\n");
+  }
 
-    @Override
-    void prefixSection(Property prefix) {
-      boolean depr = prefix.isDeprecated();
-      doc.print("| <a name=\"" + prefix.getKey().replace(".", "_")
-          + "prefix\" class=\"prop\"></a> **" + prefix.getKey() + "*** | ");
-      doc.println((depr ? "**Deprecated.** " : "") + strike(sanitize(prefix.getDescription()),
depr)
-          + " |");
-    }
+  void prefixSection(Property prefix) {
+    boolean depr = prefix.isDeprecated();
+    doc.print("| <a name=\"" + prefix.getKey().replace(".", "_") + "prefix\" class=\"prop\"></a>
**"
+        + prefix.getKey() + "*** | ");
+    doc.print(prefix.isExperimental() ? "**Experimental.** " : "");
+    doc.println(
+        (depr ? "**Deprecated.** " : "") + strike(sanitize(prefix.getDescription()), depr)
+ " |");
+  }
 
-    @Override
-    void property(Property prop) {
-      boolean depr = prop.isDeprecated();
-      doc.print("| <a name=\"" + prop.getKey().replace(".", "_") + "\" class=\"prop\"></a>
"
-          + prop.getKey() + " | ");
-      doc.print((depr ? "**Deprecated.** " : "") + strike(sanitize(prop.getDescription()),
depr)
-          + "<br>");
-      doc.print(strike("**type:** " + prop.getType().name(), depr) + ", ");
-      doc.print(strike("**zk mutable:** " + isZooKeeperMutable(prop), depr) + ", ");
-      String defaultValue = sanitize(prop.getRawDefaultValue()).trim();
-      if (defaultValue.length() == 0) {
-        defaultValue = strike("**default value:** empty", depr);
-      } else if (defaultValue.contains("\n")) {
-        // deal with multi-line values, skip strikethrough of value
-        defaultValue = strike("**default value:** ", depr) + "\n```\n" + defaultValue + "\n```\n";
+  void property(Property prop) {
+    boolean depr = prop.isDeprecated();
+    doc.print("| <a name=\"" + prop.getKey().replace(".", "_") + "\" class=\"prop\"></a>
"
+        + prop.getKey() + " | ");
+    doc.print(prop.isExperimental() ? "**Experimental.** " : "");
+    doc.print(
+        (depr ? "**Deprecated.** " : "") + strike(sanitize(prop.getDescription()), depr)
+ "<br>");
+    doc.print(strike("**type:** " + prop.getType().name(), depr) + ", ");
+    doc.print(strike("**zk mutable:** " + isZooKeeperMutable(prop), depr) + ", ");
+    String defaultValue = sanitize(prop.getRawDefaultValue()).trim();
+    if (defaultValue.length() == 0) {
+      defaultValue = strike("**default value:** empty", depr);
+    } else if (defaultValue.contains("\n")) {
+      // deal with multi-line values, skip strikethrough of value
+      defaultValue = strike("**default value:** ", depr) + "\n```\n" + defaultValue + "\n```\n";
+    } else {
+      if (prop.getType() == PropertyType.CLASSNAME
+          && defaultValue.startsWith("org.apache.accumulo")) {
+        defaultValue = strike("**default value:** " + "{% jlink -f " + defaultValue + " %}",
depr);
       } else {
-        if (prop.getType() == PropertyType.CLASSNAME
-            && defaultValue.startsWith("org.apache.accumulo")) {
-          defaultValue = strike("**default value:** " + "{% jlink -f " + defaultValue + "
%}",
-              depr);
-        } else {
-          defaultValue = strike("**default value:** " + "`" + defaultValue + "`", depr);
-        }
+        defaultValue = strike("**default value:** " + "`" + defaultValue + "`", depr);
       }
-      doc.println(defaultValue + " |");
-    }
-
-    private String strike(String s, boolean isDeprecated) {
-      return (isDeprecated ? "~~" : "") + s + (isDeprecated ? "~~" : "");
     }
+    doc.println(defaultValue + " |");
+  }
 
-    @Override
-    void propertyTypeDescriptions() {
-      for (PropertyType type : PropertyType.values()) {
-        if (type == PropertyType.PREFIX)
-          continue;
-        doc.println("| " + sanitize(type.toString()) + " | " + sanitize(type.getFormatDescription())
-            + " |");
-      }
-    }
+  private String strike(String s, boolean isDeprecated) {
+    return (isDeprecated ? "~~" : "") + s + (isDeprecated ? "~~" : "");
+  }
 
-    String sanitize(String str) {
-      return str.replace("\n", "<br>");
+  void propertyTypeDescriptions() {
+    for (PropertyType type : PropertyType.values()) {
+      if (type == PropertyType.PREFIX)
+        continue;
+      doc.println(
+          "| " + sanitize(type.toString()) + " | " + sanitize(type.getFormatDescription())
+ " |");
     }
   }
 
-  private PrintStream doc;
-  private final TreeMap<String,Property> sortedProps = new TreeMap<>();
+  String sanitize(String str) {
+    return str.replace("\n", "<br>");
+  }
 
   private ConfigurationDocGen(PrintStream doc) {
     this.doc = doc;
     for (Property prop : Property.values()) {
-      if (!prop.isExperimental()) {
-        this.sortedProps.put(prop.getKey(), prop);
-      }
+      this.sortedProps.put(prop.getKey(), prop);
     }
   }
 
@@ -167,10 +140,6 @@ class ConfigurationDocGen {
     return "yes";
   }
 
-  private void generateMarkdown() {
-    new Markdown().generate();
-  }
-
   /**
    * Generates documentation for accumulo.properties file usage. Arguments are: "--generate-markdown
    * filename"
@@ -183,7 +152,7 @@ class ConfigurationDocGen {
   public static void main(String[] args)
       throws FileNotFoundException, UnsupportedEncodingException {
     if (args.length == 2 && args[0].equals("--generate-markdown")) {
-      new ConfigurationDocGen(new PrintStream(args[1], UTF_8.name())).generateMarkdown();
+      new ConfigurationDocGen(new PrintStream(args[1], UTF_8.name())).generate();
     } else {
       throw new IllegalArgumentException(
           "Usage: " + ConfigurationDocGen.class.getName() + " --generate-markdown <filename>");


Mime
View raw message