Merge "Added javadoc to maven-yang-plugin."
authorGiovanni Meo <gmeo@cisco.com>
Wed, 17 Apr 2013 05:55:47 +0000 (05:55 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 17 Apr 2013 05:55:47 +0000 (05:55 +0000)
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin/pom.xml
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin/src/main/java/org/opendaylight/controller/yang2sources/plugin/ConfigArg.java
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin/src/main/java/org/opendaylight/controller/yang2sources/plugin/YangToResourcesMojo.java
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin/src/main/java/org/opendaylight/controller/yang2sources/plugin/YangToSourcesMojo.java
opendaylight/sal/yang-prototype/code-generator/maven-yang/src/main/java/org/opendaylight/controller/yang2sources/spi/CodeGenerator.java
opendaylight/sal/yang-prototype/code-generator/maven-yang/src/main/java/org/opendaylight/controller/yang2sources/spi/ResourceGenerator.java

index 1dd56914115732c6675cfbb70bf77cfda7e25f65..f9e3a9a6ffe65afad1e117e2634114ef547a01cd 100644 (file)
@@ -9,6 +9,14 @@
 
     <artifactId>maven-yang-plugin</artifactId>
     <packaging>maven-plugin</packaging>
+    <description>
+        This plugin is a wrapper for "yang to source code" generation.
+        It can be configured by a set of third-party code generators and resource providers.
+        For further info see available goals.
+        Sample usage:
+
+        TODO: add sample usage when finished
+    </description>
 
     <dependencies>
         <dependency>
         </dependency>
     </dependencies>
 
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-plugin-plugin</artifactId>
+                <version>3.2</version>
+            </plugin>
+        </plugins>
+    </reporting>
+
     <build>
         <plugins>
             <plugin>
index f6602e6aae5bf029773cefb38cc1162bfa29aa2f..85f2d8905dd51e48e648a495c85dc8f8d93afaf1 100644 (file)
@@ -12,7 +12,7 @@ import java.io.File;
 import com.google.common.base.Preconditions;
 
 /**
- * Complex configuration arguments
+ * Base complex configuration arguments
  */
 public abstract class ConfigArg {
 
@@ -31,6 +31,9 @@ public abstract class ConfigArg {
 
     public abstract void check();
 
+    /**
+     * Configuration argument for resource generator class and output directory.
+     */
     public static final class ResourceProviderArg extends ConfigArg {
         private String resourceProviderClass;
 
@@ -59,7 +62,7 @@ public abstract class ConfigArg {
     }
 
     /**
-     * Transfer object for code generator class and output directory.
+     * Configuration argument for code generator class and output directory.
      */
     public static final class CodeGeneratorArg extends ConfigArg {
         private String codeGeneratorClass;
index 7bb49dc0dff1abb78d6d893b198077dc28425659..b4490499cfd43dcc3d727240d0ccb5b2aa9a9b16 100644 (file)
@@ -23,14 +23,40 @@ import org.opendaylight.controller.yang2sources.spi.ResourceGenerator;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.Maps;
 
+/**
+ * Generate resources from yang files using user provided set of
+ * {@link ResourceGenerator}s. Can be used to copy yang files that served as
+ * blueprint for code generation into resources directory. Steps of this
+ * process:
+ * <ol>
+ * <li>List yang files from {@link #yangFilesRootDir} (If this goal is in the
+ * same execution as generate-sources, the same cached list will be used and the
+ * root folder will not be searched for yang files twice)</li>
+ * <li>For each {@link ResourceGenerator} from {@link #resourceProviders}:</li>
+ * <ol>
+ * <li>Instantiate using default constructor</li>
+ * <li>Call {@link ResourceGenerator#generateResourceFiles(Collection, File)}</li>
+ * </ol>
+ * </ol>
+ */
 @Mojo(name = "generate-resources", defaultPhase = LifecyclePhase.GENERATE_RESOURCES)
 public final class YangToResourcesMojo extends AbstractMojo {
 
     private static final String LOG_PREFIX = "yang-to-resources:";
 
+    /**
+     * Classes implementing {@link ResourceGenerator} interface. An instance
+     * will be created out of every class using default constructor. Method
+     * {@link ResourceGenerator#generateResourceFiles(Collection, File)} will be
+     * called on every instance.
+     */
     @Parameter(required = true)
     private ResourceProviderArg[] resourceProviders;
 
+    /**
+     * Source directory that will be recursively searched for yang files (ending
+     * with .yang suffix).
+     */
     @Parameter(required = true)
     private String yangFilesRootDir;
 
index 29282988d6ef267b82f2e1383ca8eb1653d716be..32ad2abb104c65a9cfe78aec8acb4bb310796961 100644 (file)
@@ -29,14 +29,37 @@ import org.opendaylight.controller.yang2sources.spi.CodeGenerator;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.Maps;
 
+/**
+ * Generate sources from yang files using user provided set of
+ * {@link CodeGenerator}s. Steps of this process:
+ * <ol>
+ * <li>List yang files from {@link #yangFilesRootDir}</li>
+ * <li>Process yang files using {@link YangModelParserImpl}</li>
+ * <li>For each {@link CodeGenerator} from {@link #codeGenerators}:</li>
+ * <ol>
+ * <li>Instantiate using default constructor</li>
+ * <li>Call {@link CodeGenerator#generateSources(SchemaContext, File)}</li>
+ * </ol>
+ * </ol>
+ */
 @Mojo(name = "generate-sources", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
 public final class YangToSourcesMojo extends AbstractMojo {
 
     private static final String LOG_PREFIX = "yang-to-sources:";
 
+    /**
+     * Classes implementing {@link CodeGenerator} interface. An instance will be
+     * created out of every class using default constructor. Method
+     * {@link CodeGenerator#generateSources(SchemaContext, File)} will be called
+     * on every instance.
+     */
     @Parameter(required = true)
     private CodeGeneratorArg[] codeGenerators;
 
+    /**
+     * Source directory that will be recursively searched for yang files (ending
+     * with .yang suffix).
+     */
     @Parameter(required = true)
     private String yangFilesRootDir;
 
index 2b39320989e542e4c55a4d83f330562a8404809a..534c37de10399447b95a06962ce99e88d0303a96 100644 (file)
@@ -12,7 +12,21 @@ import java.util.Collection;
 
 import org.opendaylight.controller.yang.model.api.SchemaContext;
 
+/**
+ * Classes implementing this interface can be submitted to maven-yang-plugin's
+ * generate-sources goal.
+ */
 public interface CodeGenerator {
 
+    /**
+     * Generate sources from provided {@link SchemaContext}
+     * 
+     * @param context
+     *            parsed from yang files
+     * @param outputBaseDir
+     *            expected output directory for generated sources configured by
+     *            user
+     * @return collection of files that were generated from schema context
+     */
     Collection<File> generateSources(SchemaContext context, File outputBaseDir);
 }
index 9095155b0ccf5b52021771f8ce491a1c8eefa434..2638dc33b021fae8bec0261719da95c27109bbe9 100644 (file)
@@ -10,7 +10,20 @@ package org.opendaylight.controller.yang2sources.spi;
 import java.io.File;
 import java.util.Collection;
 
+/**
+ * Classes implementing this interface can be submitted to maven-yang-plugin's
+ * generate-resources goal.
+ */
 public interface ResourceGenerator {
 
+    /**
+     * Generate resources (e.g. copy files into resources folder) from provided
+     * list of yang files
+     * 
+     * @param resources
+     *            list of parsed yang files
+     * @param outputBaseDir
+     *            expected output directory for resources configured by user
+     */
     void generateResourceFiles(Collection<File> resources, File outputBaseDir);
 }