Permalink
Browse files

Merge pull request #34 from brendanlong/master

Print parameter documentation in the order its defined in
  • Loading branch information...
2 parents 05e7bfe + 1a39f67 commit d725a0ecb2188f3e99f1c5dfa45c888be4ed6f8b @FroMage committed Mar 21, 2012
@@ -101,6 +101,9 @@ public static boolean hasAnnotation(final ProgramElementDoc programElementDoc, f
}
public static MethodDoc findAnnotatedMethod(final ClassDoc declaringClass, final MethodDoc method, final Class<?>... soughtAnnotations) {
+ if(isExcluded(method)) {
+ return null;
+ }
final AnnotationDesc onMethod = findAnnotation(method, soughtAnnotations);
if (onMethod != null) {
return method;
@@ -193,7 +196,7 @@ public static ClassDoc findAnnotatedInterface(final ClassDoc klass, final Class<
final Type[] interfaceTypes = klass.interfaceTypes();
for (final Type interfaceType : interfaceTypes) {
final ClassDoc interfaceClassDoc = interfaceType.asClassDoc();
- if (interfaceClassDoc != null) {
+ if (interfaceClassDoc != null && !isExcluded(interfaceClassDoc)) {
if (hasAnnotation(interfaceClassDoc, soughtAnnotations)) {
return interfaceClassDoc;
}
@@ -207,7 +210,7 @@ public static ClassDoc findAnnotatedInterface(final ClassDoc klass, final Class<
}
public static ClassDoc findAnnotatedClass(final ClassDoc klass, final Class<?>... soughtAnnotations) {
- if (!klass.isClass())
+ if (!klass.isClass() || isExcluded(klass))
return null;
if (hasAnnotation(klass, soughtAnnotations)) {
return klass;
@@ -271,7 +274,7 @@ public static Type findSuperTypeFromClass(final ClassDoc klass, String typeName)
}
public static String appendURLFragments(String... fragments) {
- StringBuffer strbuf = new StringBuffer();
+ StringBuilder strbuf = new StringBuilder();
for (String fragment : fragments) {
// skip empty fragments
if (fragment == null || fragment.length() == 0)
@@ -378,7 +381,7 @@ public static String urlToRoot(String from) {
if (from == null || from.length() == 0) {
return "";
}
- StringBuffer pathstr = new StringBuffer();
+ StringBuilder pathstr = new StringBuilder();
for (int i = 0; i < from.length(); i++) {
char ch = from.charAt(i);
if (ch == '/') {
@@ -394,14 +397,8 @@ public static void createDirectory(String path) {
return;
}
File dir = new File(path);
- if (dir.exists()) {
- return;
- } else {
- if (dir.mkdirs()) {
- return;
- } else {
- throw new RuntimeException("Could not create path: " + path);
- }
+ if (!dir.exists() && !dir.mkdirs()) {
+ throw new RuntimeException("Could not create path: " + path);
}
}
@@ -841,4 +838,8 @@ public static String getAbsolutePath(DocletWriter writer, Resource resource) {
public static void log(String mesg) {
// System.err.println(mesg);
}
+
+ private static boolean isExcluded(Doc doc) {
+ return doc.tags("exclude").length != 0;
+ }
}
@@ -19,8 +19,8 @@
package com.lunatech.doclets.jax.jaxrs;
import java.util.Collections;
-import java.util.LinkedList;
import java.util.List;
+import java.util.LinkedList;
import javax.ws.rs.Path;
@@ -29,12 +29,7 @@
import com.lunatech.doclets.jax.jaxrs.model.Resource;
import com.lunatech.doclets.jax.jaxrs.model.ResourceClass;
import com.lunatech.doclets.jax.jaxrs.model.ResourceMethod;
-import com.lunatech.doclets.jax.jaxrs.tags.HTTPTaglet;
-import com.lunatech.doclets.jax.jaxrs.tags.IncludeTaglet;
-import com.lunatech.doclets.jax.jaxrs.tags.InputWrappedTaglet;
-import com.lunatech.doclets.jax.jaxrs.tags.RequestHeaderTaglet;
-import com.lunatech.doclets.jax.jaxrs.tags.ResponseHeaderTaglet;
-import com.lunatech.doclets.jax.jaxrs.tags.ReturnWrappedTaglet;
+import com.lunatech.doclets.jax.jaxrs.tags.*;
import com.lunatech.doclets.jax.jaxrs.writers.IndexWriter;
import com.lunatech.doclets.jax.jaxrs.writers.SummaryWriter;
import com.sun.javadoc.ClassDoc;
@@ -87,6 +82,7 @@ public JAXRSDoclet(RootDoc rootDoc) {
htmlDoclet.configuration.tagletManager.addCustomTag(new LegacyTaglet(new ReturnWrappedTaglet()));
htmlDoclet.configuration.tagletManager.addCustomTag(new LegacyTaglet(new InputWrappedTaglet()));
htmlDoclet.configuration.tagletManager.addCustomTag(new LegacyTaglet(new IncludeTaglet()));
+ htmlDoclet.configuration.tagletManager.addCustomTag(new ExcludeTaglet());
}
@Override
@@ -101,7 +97,7 @@ public void start() {
handleJAXRSClass(klass);
}
}
- Collections.sort(jaxrsMethods);
+ Collections.sort(this.jaxrsMethods);
Resource rootResource = Resource.getRootResource(jaxrsMethods);
rootResource.write(this, conf);
new IndexWriter(conf, rootResource).write();
@@ -19,6 +19,7 @@
package com.lunatech.doclets.jax.jaxrs.model;
import java.lang.annotation.Annotation;
+import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -112,7 +113,7 @@ public String getAbsolutePath() {
return "/";
}
- public static Resource getRootResource(List<ResourceMethod> resourceMethods) {
+ public static Resource getRootResource(Collection<ResourceMethod> resourceMethods) {
Resource rootResource = new Resource("", null);
for (ResourceMethod resourceMethod : resourceMethods) {
rootResource.addResourceMethod(resourceMethod);
@@ -145,8 +146,7 @@ public void dump(int offset) {
for (ResourceMethod method : methods) {
dump(offset + 1, "+ [M]" + method.toString());
}
- for (String subResourceKey : subResources.keySet()) {
- Resource subResource = subResources.get(subResourceKey);
+ for (Resource subResource : subResources.values()) {
subResource.dump(offset + 1);
}
}
@@ -164,8 +164,7 @@ public String getName() {
public void write(JAXRSDoclet doclet, JAXConfiguration configuration) {
ResourceWriter writer = new ResourceWriter(configuration, this, doclet);
writer.write();
- for (String subResourceKey : subResources.keySet()) {
- Resource subResource = subResources.get(subResourceKey);
+ for (Resource subResource : subResources.values()) {
subResource.write(doclet, configuration);
}
}
@@ -179,8 +178,6 @@ public void write(JAXRSDoclet doclet, JAXConfiguration configuration) {
}
public boolean hasRealMethods() {
- if (methods.isEmpty())
- return false;
for (ResourceMethod method : methods) {
if (!method.isResourceLocator())
return true;
@@ -193,7 +190,7 @@ public Resource getParent() {
}
public String getPathFrom(Resource parent) {
- StringBuffer strbuf = new StringBuffer();
+ StringBuilder strbuf = new StringBuilder();
Resource resource = this;
while (resource != parent) {
strbuf.insert(0, resource.getName());
Oops, something went wrong.

0 comments on commit d725a0e

Please sign in to comment.