diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java index 0713467c73..ac8dd5bf1d 100644 --- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java +++ b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/doclet/ConfigStandardDoclet.java @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,14 +31,8 @@ import org.apache.tez.tools.javadoc.util.HtmlWriter; import org.apache.tez.tools.javadoc.util.XmlWriter; -import com.sun.javadoc.AnnotationDesc; -import com.sun.javadoc.AnnotationDesc.ElementValuePair; -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.DocErrorReporter; -import com.sun.javadoc.FieldDoc; -import com.sun.javadoc.LanguageVersion; -import com.sun.javadoc.RootDoc; -import com.sun.tools.doclets.standard.Standard; +import java.io.IOException; +import java.util.Map; public final class ConfigStandardDoclet { @@ -194,40 +188,34 @@ private static void processDoc(ClassDoc doc) { } } } - } - configProperty.description = field.commentText(); - - } + HtmlWriter writer = new HtmlWriter(); + try { + writer.write(config); + } catch (IOException e) { + throw new RuntimeException(e); + } - HtmlWriter writer = new HtmlWriter(); - try { - writer.write(config); - } catch (IOException e) { - throw new RuntimeException(e); - } + XmlWriter xmlWriter = new XmlWriter(); + try { + xmlWriter.write(config); + } catch (IOException e) { + throw new RuntimeException(e); + } + } - XmlWriter xmlWriter = new XmlWriter(); - try { - xmlWriter.write(config); - } catch (IOException e) { - throw new RuntimeException(e); - } + private static String stripQuotes (String s){ + if (s.charAt(0) == '"' && s.charAt(s.length() - 1) == '"') { + return s.substring(1, s.length() - 1); + } + return s; + } - } + public static int optionLength (String option){ + return Standard.optionLength(option); + } - private static String stripQuotes(String s) { - if (s.charAt(0) == '"' && s.charAt(s.length()-1) == '"') { - return s.substring(1, s.length()-1); + public static boolean validOptions (String options[][],DocErrorReporter reporter){ + return true; + } } - return s; - } - - public static int optionLength(String option) { - return Standard.optionLength(option); - } - - public static boolean validOptions(String options[][], DocErrorReporter reporter) { - return true; - } -} diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java index 604d48ac5e..d35dfd38e1 100644 --- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java +++ b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/Config.java @@ -23,18 +23,17 @@ public class Config { - public final String templateName; - public final String configName; - public Map configProperties; + public final String templateName; + public final String configName; + public Map configProperties; - public Config(String configName, String templateName) { - this.configName = configName; - this.templateName = templateName; - this.configProperties = new TreeMap(); - } - - public Config() { - this(null, null); - } + public Config(String configName, String templateName) { + this.configName = configName; + this.templateName = templateName; + this.configProperties = new TreeMap(); + } + public Config() { + this(null, null); + } } diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/ConfigProperty.java b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/ConfigProperty.java index 89490c4a51..98ab8ae582 100644 --- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/ConfigProperty.java +++ b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/model/ConfigProperty.java @@ -20,28 +20,26 @@ public class ConfigProperty { - public String propertyName; - public String defaultValue; - public String description; - public String type = "string"; - public boolean isPrivate = false; - public boolean isUnstable = false; - public boolean isEvolving = false; - public boolean isValidConfigProp = false; - public String[] validValues; - public String inferredType; + public String propertyName; + public String defaultValue; + public String description; + public String type = "string"; + public boolean isPrivate = false; + public boolean isUnstable = false; + public boolean isEvolving = false; + public boolean isValidConfigProp = false; + public String[] validValues; + public String inferredType; - @Override - public String toString() { - return "name=" + propertyName - + ", defaultValue=" + defaultValue - + ", description=" + description - + ", type=" + type - + ", inferredType=" + inferredType - + ", private=" + isPrivate - + ", validValues=" + (validValues == null ? "null" : validValues) - + ", isConfigProp=" + isValidConfigProp; - } + @Override + public String toString() { + return "name=" + propertyName + + ", defaultValue=" + defaultValue + + ", description=" + description + + ", type=" + type + + ", inferredType=" + inferredType + + ", private=" + isPrivate + + ", validValues=" + (validValues == null ? "null" : validValues) + + ", isConfigProp=" + isValidConfigProp; + } } - - diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java index 4b531e87e5..1586e51439 100644 --- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java +++ b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/HtmlWriter.java @@ -18,144 +18,136 @@ package org.apache.tez.tools.javadoc.util; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; - -import org.apache.tez.dag.api.TezException; import org.apache.tez.tools.javadoc.model.Config; import org.apache.tez.tools.javadoc.model.ConfigProperty; +import java.io.*; + public class HtmlWriter extends Writer { - private static final String DEFAULT_STYLESHEET = "default-stylesheet.css"; + private static final String DEFAULT_STYLESHEET = "default-stylesheet.css"; - public void write(Config config) throws IOException { - PrintWriter out = null; + public void write(Config config) throws IOException { + PrintWriter out = null; - if (config.configName == null || config.configName.isEmpty()) { - throw new RuntimeException("Config Name is null or empty"); - } + if (config.configName == null || config.configName.isEmpty()) { + throw new RuntimeException("Config Name is null or empty"); + } - try { - File file = new File(config.configName + ".html"); - out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); + try { + File file = new File(config.configName + ".html"); + out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); - out.println(""); - out.println(""); + out.println(""); + out.println(""); - out.println(""); + out.println(""); - out.println(""); - out.println(""); - out.println(""+ config.configName +""); + out.println(""); + out.println(""); + out.println("" + config.configName + ""); // out.println(""); - out.println(""); - - out.println(""); - - out.println(""); - - out.println("

"); - out.println("
"); - - out.println("

"+ config.configName +"

"); - out.println("
"); - - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - // out.println(""); - out.println(""); - out.println(""); - out.println(""); - out.println(""); - - for (ConfigProperty configProperty : config.configProperties.values()) { - if (!isValidConfigProperty(configProperty)) { - continue; + out.println(""); + + out.println(""); + + out.println(""); + + out.println("
"); + out.println("
"); + + out.println("

" + config.configName + "

"); + out.println("
"); + + out.println("
" + "Property Name" + "" + "Default Value" + "" + "Description" + "" + "Type" + "" + "Valid Values" + "" + "Is Private?" + "" + "Is Unstable?" + "" + "Is Evolving?" + "
"); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + // out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + + for (ConfigProperty configProperty : config.configProperties.values()) { + if (!isValidConfigProperty(configProperty)) { + continue; + } + + String altClass = ""; + if (configProperty.isPrivate) { + altClass = "class=\"tr_private\""; + } else if (configProperty.isEvolving || configProperty.isUnstable) { + altClass = "class=\"tr_evolve_unstable\""; + } + + out.println(""); + out.println(""); + out.println(""); + out.println(""); + out.println(""); + // Re-enable after adding values + // out.println(""); + + out.println(""); + out.println(""); + out.println(""); + out.println(""); + } + + out.println("
" + "Property Name" + "" + "Default Value" + "" + "Description" + "" + "Type" + "" + "Valid Values" + "" + "Is Private?" + "" + "Is Unstable?" + "" + "Is Evolving?" + "
" + configProperty.propertyName + "" + configProperty.defaultValue + "" + configProperty.description + "" + configProperty.type + "" + configProperty.validValues + "" + configProperty.isPrivate + "" + configProperty.isEvolving + "" + configProperty.isUnstable + "
"); + + out.println("
"); + out.println("
"); + out.println(""); + out.println(""); + } finally { + if (out != null) { + out.close(); + } } - - String altClass = ""; - if (configProperty.isPrivate) { - altClass = "class=\"tr_private\""; - } else if (configProperty.isEvolving || configProperty.isUnstable) { - altClass = "class=\"tr_evolve_unstable\""; - } - - out.println(""); - out.println("" + configProperty.propertyName + ""); - out.println("" + configProperty.defaultValue + ""); - out.println("" + configProperty.description + ""); - out.println("" + configProperty.type + ""); - // Re-enable after adding values - // out.println("" + configProperty.validValues + ""); - - out.println("" + configProperty.isPrivate + ""); - out.println("" + configProperty.isEvolving + ""); - out.println("" + configProperty.isUnstable + ""); - out.println(""); - } - - out.println(""); - - out.println(""); - out.println(""); - out.println(""); - out.println(""); - - } finally { - if (out != null) { - out.close(); - } } - } - } diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java index cfb0c92738..6b9bcf9b20 100644 --- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java +++ b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/Writer.java @@ -18,22 +18,22 @@ package org.apache.tez.tools.javadoc.util; -import java.io.IOException; - import org.apache.tez.tools.javadoc.model.Config; import org.apache.tez.tools.javadoc.model.ConfigProperty; +import java.io.IOException; + public abstract class Writer { - public abstract void write(Config config) throws IOException; + public abstract void write(Config config) throws IOException; - public boolean isValidConfigProperty(ConfigProperty configProperty) { - if (!configProperty.isValidConfigProp) { - return false; - } - if (configProperty.propertyName == null || configProperty.propertyName.isEmpty()) { - return false; + public boolean isValidConfigProperty(ConfigProperty configProperty) { + if (!configProperty.isValidConfigProp) { + return false; + } + if (configProperty.propertyName == null || configProperty.propertyName.isEmpty()) { + return false; + } + return true; } - return true; - } } diff --git a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java index e9bdeb3999..e69de29bb2 100644 --- a/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java +++ b/tez-tools/tez-javadoc-tools/src/main/java/org/apache/tez/tools/javadoc/util/XmlWriter.java @@ -1,108 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tez.tools.javadoc.util; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; - -import org.apache.commons.lang.StringEscapeUtils; -import org.apache.tez.tools.javadoc.model.Config; -import org.apache.tez.tools.javadoc.model.ConfigProperty; - -import com.google.common.io.ByteStreams; - -public class XmlWriter extends Writer { - - public void write(Config config) throws IOException { - PrintWriter out = null; - - if (config.configName == null || config.configName.isEmpty()) { - throw new RuntimeException("Config Name is null or empty"); - } - - String fileName = config.templateName == null || - config.templateName.isEmpty() ? config.configName : config.templateName; - if (!fileName.endsWith(".xml")) { - fileName += ".xml"; - } - - try { - File file = new File(fileName); - writeApacheHeader(file); - - out = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file, true), "UTF-8")); - - out.println(""); - out.println(); - out.println(""); - out.println(); - out.println(""); - - for (ConfigProperty configProperty : config.configProperties.values()) { - if (!isValidConfigProperty(configProperty)) { - continue; - } - out.println(); - out.println(" "); - out.println(" " + configProperty.propertyName + ""); - if (configProperty.defaultValue != null && !configProperty.defaultValue.isEmpty()) { - out.println(" " + configProperty.defaultValue + ""); - } - if (configProperty.description != null && !configProperty.description.isEmpty()) { - out.println(" " + StringEscapeUtils.escapeXml(configProperty.description) - + ""); - } - if (configProperty.type != null && !configProperty.type.isEmpty()) { - out.println(" " + configProperty.type + ""); - } - if (configProperty.isUnstable) { - out.println(" true"); - } - if (configProperty.isEvolving) { - out.println(" true"); - } - if (configProperty.isPrivate) { - out.println(" true"); - } - out.println(" "); - } - - out.println(); - out.println(""); - - } finally { - if (out != null) { - out.close(); - } - } - } - - private void writeApacheHeader(File file) throws IOException { - try (InputStream in = this.getClass().getClassLoader().getResourceAsStream("apache-licence.xml.header"); - OutputStream out = new FileOutputStream(file)) { - ByteStreams.copy(in, out); - } - } -}