You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by dh...@apache.org on 2014/06/19 23:45:36 UTC
git commit: Added parameter destDir to make sure API component
documentation is generated in specified report directory,
defaults to cameldocs
Repository: camel
Updated Branches:
refs/heads/master ad26a8ab4 -> 34e441e00
Added parameter destDir to make sure API component documentation is generated in specified report directory, defaults to cameldocs
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/34e441e0
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/34e441e0
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/34e441e0
Branch: refs/heads/master
Commit: 34e441e0058942e49c68e493084f7eefee91f9bd
Parents: ad26a8a
Author: Dhiraj Bokde <dh...@yahoo.com>
Authored: Thu Jun 19 14:45:23 2014 -0700
Committer: Dhiraj Bokde <dh...@yahoo.com>
Committed: Thu Jun 19 14:45:23 2014 -0700
----------------------------------------------------------------------
.../camel/maven/DocumentGeneratorMojo.java | 53 +++++++++++++++++---
.../src/main/resources/api-document.vm | 10 ++--
.../camel/maven/DocumentGeneratorMojoTest.java | 5 +-
3 files changed, 53 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/34e441e0/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/DocumentGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/DocumentGeneratorMojo.java b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/DocumentGeneratorMojo.java
index 17a87cb..b2e3077 100644
--- a/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/DocumentGeneratorMojo.java
+++ b/tooling/maven/camel-api-component-maven-plugin/src/main/java/org/apache/camel/maven/DocumentGeneratorMojo.java
@@ -60,10 +60,14 @@ import org.codehaus.plexus.util.StringUtils;
public class DocumentGeneratorMojo extends AbstractGeneratorMojo implements MavenReport {
// document output directory
- @Parameter(property = "reportOutputDirectory",
- defaultValue = "${project.reporting.outputDirectory}/cameldocs", required = true)
+ @Parameter(property = PREFIX + "reportOutputDirectory",
+ defaultValue = "${project.reporting.outputDirectory}/cameldocs")
private File reportOutputDirectory;
+ // name of destination directory
+ @Parameter(property = PREFIX + "destDir", defaultValue = "cameldocs")
+ private String destDir;
+
/**
* The name of the Camel report to be displayed in the Maven Generated Reports page
* (i.e. <code>project-reports.html</code>).
@@ -122,6 +126,7 @@ public class DocumentGeneratorMojo extends AbstractGeneratorMojo implements Mave
// component URI format
// look for single API, no endpoint-prefix
+ @SuppressWarnings("unchecked")
final Set<String> apiNames = new TreeSet<String>(collection.getApiNames());
context.put("apiNames", apiNames);
String suffix;
@@ -147,6 +152,7 @@ public class DocumentGeneratorMojo extends AbstractGeneratorMojo implements Mave
Map.Entry entry = (Map.Entry) element;
final String name = ((ApiName) entry.getValue()).getName();
+ @SuppressWarnings("unchecked")
Class<? extends ApiMethod> apiMethod = (Class<? extends ApiMethod>) entry.getKey();
apiMethods.put(name, apiMethod);
@@ -209,7 +215,11 @@ public class DocumentGeneratorMojo extends AbstractGeneratorMojo implements Mave
}
private File getDocumentFile() {
- return new File(getReportOutputDirectory(), getOutputName() + ".html");
+ return new File(getReportOutputDirectory(), getDocumentName() + ".html");
+ }
+
+ private String getDocumentName() {
+ return this.componentName + "Component";
}
@Override
@@ -226,7 +236,7 @@ public class DocumentGeneratorMojo extends AbstractGeneratorMojo implements Mave
@Override
public String getOutputName() {
- return this.componentName + "Component";
+ return this.destDir + "/" + getDocumentName();
}
@Override
@@ -234,6 +244,10 @@ public class DocumentGeneratorMojo extends AbstractGeneratorMojo implements Mave
return CATEGORY_PROJECT_REPORTS;
}
+ public void setName(String name) {
+ this.name = name;
+ }
+
@Override
public String getName(Locale locale) {
if (StringUtils.isEmpty(name)) {
@@ -242,6 +256,10 @@ public class DocumentGeneratorMojo extends AbstractGeneratorMojo implements Mave
return name;
}
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
@Override
public String getDescription(Locale locale) {
if (StringUtils.isEmpty(description)) {
@@ -251,13 +269,32 @@ public class DocumentGeneratorMojo extends AbstractGeneratorMojo implements Mave
}
@Override
- public void setReportOutputDirectory(File reportOutputDirectory) {
- this.reportOutputDirectory = reportOutputDirectory;
+ public File getReportOutputDirectory() {
+ return reportOutputDirectory;
}
@Override
- public File getReportOutputDirectory() {
- return reportOutputDirectory;
+ public void setReportOutputDirectory(File reportOutputDirectory) {
+ updateReportOutputDirectory(reportOutputDirectory);
+ }
+
+ private void updateReportOutputDirectory(File reportOutputDirectory) {
+ // append destDir if needed
+ if (this.destDir != null && reportOutputDirectory != null &&
+ !reportOutputDirectory.getAbsolutePath().endsWith(destDir)) {
+ this.reportOutputDirectory = new File(reportOutputDirectory, destDir);
+ } else {
+ this.reportOutputDirectory = reportOutputDirectory;
+ }
+ }
+
+ public String getDestDir() {
+ return destDir;
+ }
+
+ public void setDestDir(String destDir) {
+ this.destDir = destDir;
+ updateReportOutputDirectory(this.reportOutputDirectory);
}
@Override
http://git-wip-us.apache.org/repos/asf/camel/blob/34e441e0/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-document.vm
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-document.vm b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-document.vm
index b87e19c..9e14962 100644
--- a/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-document.vm
+++ b/tooling/maven/camel-api-component-maven-plugin/src/main/resources/api-document.vm
@@ -92,8 +92,8 @@
</p>
#else
<p>
- Producer endpoints can use endpoint prefixes followed by endpoint names and options described next.
- A shorthand alias can be used for some endpoints. The URI MUST specify one of the following prefixes.
+ Producer endpoints can use endpoint prefixes followed by endpoint names and associated options described next.
+ A shorthand alias can be used for some endpoints. The endpoint URI MUST contain a prefix.
</p>
#end
<p>
@@ -145,9 +145,9 @@
## multiple API use case, list API names and their methods and options
#foreach( $apiMethod in $apiMethods.entrySet() )
#set( $apiName = $apiMethod.Key )
- <h3>${foreach.count}. Endpoint Prefix $apiName</h3>
+ <h3>${foreach.count}. Endpoint Prefix <em>$apiName</em></h3>
<hr/>
- <p>The following endpoints can be invoked with the prefix $apiName as follows:</p>
+ <p>The following endpoints can be invoked with the prefix <code>$apiName</code> as follows:</p>
<pre>
${scheme}://${apiName}/endpoint?[options]
</pre>
@@ -169,7 +169,7 @@
</tr>
#end
</table>
- <h4>URI Options for $apiName</h4>
+ <h4>URI Options for <em>$apiName</em></h4>
<hr/>
<table>
<tr>
http://git-wip-us.apache.org/repos/asf/camel/blob/34e441e0/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/DocumentGeneratorMojoTest.java
----------------------------------------------------------------------
diff --git a/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/DocumentGeneratorMojoTest.java b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/DocumentGeneratorMojoTest.java
index a0459a3..c1ff746 100644
--- a/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/DocumentGeneratorMojoTest.java
+++ b/tooling/maven/camel-api-component-maven-plugin/src/test/java/org/apache/camel/maven/DocumentGeneratorMojoTest.java
@@ -30,7 +30,7 @@ public class DocumentGeneratorMojoTest extends AbstractGeneratorMojoTest {
@Test
public void testExecute() throws Exception {
// delete target file to begin
- final File outDir = new File("target/site/camelDocs");
+ final File outDir = new File("target/site/cameldocs");
final File outFile = new File(outDir, "TestComponent.html");
if (outFile.exists()) {
outFile.delete();
@@ -38,7 +38,8 @@ public class DocumentGeneratorMojoTest extends AbstractGeneratorMojoTest {
final DocumentGeneratorMojo mojo = new DocumentGeneratorMojo();
configureGeneratorMojo(mojo);
- mojo.setReportOutputDirectory(outDir);
+ mojo.setDestDir("cameldocs");
+ mojo.setReportOutputDirectory(outDir.getParentFile());
mojo.execute();