Browse files

Make tags available in documentation models.

  • Loading branch information...
1 parent f0008d1 commit ac115fd99ede1532adb3ac352c1009dcceb4004b @kayahr committed Jun 17, 2012
View
24 src/main/java/de/ailis/jasdoc/doc/AbstractDoc.java
@@ -9,6 +9,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import de.ailis.jasdoc.tags.Tags;
import de.ailis.jasdoc.util.HTMLUtils;
/**
@@ -21,6 +22,10 @@
/** The serial version UID. */
private static final long serialVersionUID = 1L;
+ /** Pattern to match an inline link tag. */
+ private final static Pattern LINK_TAG_PATTERN = Pattern
+ .compile("\\{@link\\s+([^\\s}]+)\\s*([^}]*)\\s*\\}");
+
/** The name. */
private final String name;
@@ -36,9 +41,8 @@
/** The parent documentation model. */
private final ModelDoc parentDoc;
- /** Pattern to match an inline link tag. */
- private final static Pattern LINK_TAG_PATTERN = Pattern
- .compile("\\{@link\\s+([^\\s}]+)\\s*([^}]*)\\s*\\}");
+ /** The tags. */
+ private final Tags tags;
/**
* Constructor.
@@ -51,9 +55,11 @@
* @param parentDoc
* The parent documentation model. Null if none (Only valid for
* global doc)
+ * @param tags
+ * The tags.
*/
public AbstractDoc(final String name, final String description,
- final ModelDoc parentDoc)
+ final ModelDoc parentDoc, final Tags tags)
{
if (name == null)
throw new IllegalArgumentException("name is null");
@@ -63,6 +69,7 @@ public AbstractDoc(final String name, final String description,
this.name = name;
this.description = description;
this.shortDescription = buildShortDescription(description);
+ this.tags = tags;
}
/**
@@ -205,4 +212,13 @@ public String getBaseUrl()
{
return this.parentDoc.getBaseUrl();
}
+
+ /**
+ * @see de.ailis.jasdoc.doc.ModelDoc#getTags()
+ */
+ @Override
+ public Tags getTags()
+ {
+ return this.tags;
+ }
}
View
8 src/main/java/de/ailis/jasdoc/doc/ClassDoc.java
@@ -16,6 +16,8 @@
import java.util.Set;
import java.util.TreeSet;
+import de.ailis.jasdoc.tags.Tags;
+
/**
* Class documentation.
*
@@ -55,12 +57,14 @@
* The super class. Must not be null. May be empty.
* @param interfaces
* The implemented interfaces. Must not be null. May be empty.
+ * @param tags
+ * The tags. Must not be null.
*/
public ClassDoc(final String name, final String description,
final NamespaceDoc namespace, final Collection<ClassDoc> superClasses,
- final Collection<InterfaceDoc> interfaces)
+ final Collection<InterfaceDoc> interfaces, final Tags tags)
{
- super(name, description, namespace);
+ super(name, description, namespace, tags);
this.superClasses =
Collections.unmodifiableSet(new TreeSet<ClassDoc>(superClasses));
this.interfaces =
View
8 src/main/java/de/ailis/jasdoc/doc/ConstructorDoc.java
@@ -5,6 +5,8 @@
package de.ailis.jasdoc.doc;
+import de.ailis.jasdoc.tags.Tags;
+
/**
* Constructor documentation.
@@ -31,11 +33,13 @@
* The constructor modifier flags. Must not be null.
* @param cls
* The class this constructor belongs to.
+ * @param tags
+ * The tags. Must not be null.
*/
public ConstructorDoc(final String name, final String description,
- final Modifier modifier, final ClassDoc cls)
+ final Modifier modifier, final ClassDoc cls, final Tags tags)
{
- super(name, description, cls);
+ super(name, description, cls, tags);
if (modifier == null)
throw new IllegalArgumentException("modifier is null");
if (cls == null)
View
33 src/main/java/de/ailis/jasdoc/doc/DocParser.java
@@ -398,7 +398,8 @@ private ClassDoc createClass(final Node node)
final Set<ClassDoc> superClasses = createSuperClasses(node);
final Set<InterfaceDoc> interfaces =
createImplementedInterfaces(node);
- cls = new ClassDoc(name, description, namespace, superClasses, interfaces);
+ cls = new ClassDoc(name, description, namespace, superClasses,
+ interfaces, node.getTags());
cls.setConstructor(createConstructor((FuncNode) node, cls));
cls.setMethods(createMethods(node, cls));
cls.setFields(createFields(node, cls));
@@ -424,7 +425,8 @@ private EnumDoc createEnum(final Node node)
final String name = node.getName();
final NamespaceDoc namespace =
createNamespace(node.getParentNode());
- cls = new EnumDoc(name, description, namespace, type);
+ cls = new EnumDoc(name, description, namespace, type,
+ node.getTags());
cls.setConstants(createEnumConstants(node, cls));
cache(node, cls);
}
@@ -450,7 +452,8 @@ private VariableDoc createVariable(final Node node)
final NamespaceDoc namespace =
createNamespace(node.getParentNode());
variable =
- new VariableDoc(type, name, description, modifier, namespace);
+ new VariableDoc(type, name, description, modifier,
+ namespace, node.getTags());
cache(node, variable);
}
return variable;
@@ -494,7 +497,8 @@ private EnumConstantDoc createEnumConstant(final Node node,
final String description = getDescription(node);
final JsType type = getEnumConstantType(node);
final Modifier modifier = getEnumConstantModifier(node);
- return new EnumConstantDoc(type, name, description, modifier, enm);
+ return new EnumConstantDoc(type, name, description, modifier, enm,
+ node.getTags());
}
/**
@@ -574,7 +578,8 @@ private NamespaceDoc createNamespace(final Node node)
String name = node.getName();
String description = getNamespaceDescription(node);
NamespaceDoc parent = createNamespace(node.getParentNode());
- namespace = new NamespaceDoc(name, description, parent);
+ namespace = new NamespaceDoc(name, description, parent,
+ node.getTags());
cache(node, namespace);
}
return namespace;
@@ -624,7 +629,7 @@ private InterfaceDoc createInterface(Node node)
final Collection<InterfaceDoc> superInterfaces =
createExtendedInterfaces(node);
intf = new InterfaceDoc(name, description, namespace,
- superInterfaces);
+ superInterfaces, node.getTags());
intf.setMethods(createMethods(node, intf));
cache(node, intf);
}
@@ -749,7 +754,7 @@ private MethodDoc createMethod(final FuncNode node,
final String description = getDescription(node);
final String name = node.getName();
final MethodDoc method = new MethodDoc(name, description, modifier,
- declaringType);
+ declaringType, node.getTags());
method.setResult(createResult(node, method));
method.setParameters(createParameters(node, method));
return method;
@@ -771,7 +776,7 @@ private FunctionDoc createFunction(final FuncNode node)
final NamespaceDoc namespace = createNamespace(node.getParentNode());
final Modifier modifier = getFunctionModifier(node);
final FunctionDoc function = new FunctionDoc(name, description,
- modifier, namespace);
+ modifier, namespace, node.getTags());
function.setResult(createResult(node, function));
function.setParameters(createParameters(node, function));
return function;
@@ -798,7 +803,8 @@ private FieldDoc createField(final Node node, ClassDoc cls)
final String description = getDescription(node);
final String name = node.getName();
final JsType type = getFieldType(node);
- return new FieldDoc(type, name, description, modifier, cls);
+ return new FieldDoc(type, name, description, modifier, cls,
+ node.getTags());
}
/**
@@ -822,8 +828,8 @@ private ConstructorDoc createConstructor(final FuncNode node,
return null;
final String description = getDescription(node);
final String name = node.getName();
- ConstructorDoc constructor =
- new ConstructorDoc(name, description, modifier, cls);
+ ConstructorDoc constructor = new ConstructorDoc(name, description,
+ modifier, cls, node.getTags());
constructor.setParameters(createParameters(node, constructor));
return constructor;
}
@@ -863,7 +869,8 @@ private ParameterDoc createParameter(final Node node,
final JsType type = getParamType(node);
final String name = node.getName();
final String description = getParamDescription(node);
- return new ParameterDoc(type, name, description, executable);
+ return new ParameterDoc(type, name, description, executable,
+ node.getTags());
}
/**
@@ -882,6 +889,6 @@ private ResultDoc createResult(final FuncNode node,
if (type == null) return null;
final String description = getReturnDescription(node);
if (description == null) return null;
- return new ResultDoc(type, description, executable);
+ return new ResultDoc(type, description, executable, node.getTags());
}
}
View
8 src/main/java/de/ailis/jasdoc/doc/EnumConstantDoc.java
@@ -5,6 +5,7 @@
package de.ailis.jasdoc.doc;
+import de.ailis.jasdoc.tags.Tags;
import de.ailis.jasdoc.types.JsType;
/**
@@ -37,11 +38,14 @@
* The enum modifier flags. Must not be null.
* @param enm
* The enum this constant belongs to. Must not be null.
+ * @param tags
+ * The tags. Must not be null.
*/
public EnumConstantDoc(final JsType type, final String name,
- final String description, final Modifier modifier, final EnumDoc enm)
+ final String description, final Modifier modifier, final EnumDoc enm,
+ final Tags tags)
{
- super(name, description, enm);
+ super(name, description, enm, tags);
if (type == null) throw new IllegalArgumentException("type is null");
if (modifier == null)
throw new IllegalArgumentException("modifier is null");
View
7 src/main/java/de/ailis/jasdoc/doc/EnumDoc.java
@@ -10,6 +10,7 @@
import java.util.Set;
import java.util.TreeSet;
+import de.ailis.jasdoc.tags.Tags;
import de.ailis.jasdoc.types.JsType;
/**
@@ -40,11 +41,13 @@
* The namespace this enum belongs to. Must not be null.
* @param type
* The enum type. Must not be null.
+ * @param tags
+ * The tags. Must not be null.
*/
public EnumDoc(final String name, final String description,
- final NamespaceDoc namespace, final JsType type)
+ final NamespaceDoc namespace, final JsType type, final Tags tags)
{
- super(name, description, namespace);
+ super(name, description, namespace, tags);
if (type == null) throw new IllegalArgumentException("type is null");
if (namespace == null)
throw new IllegalArgumentException("namespace is null");
View
8 src/main/java/de/ailis/jasdoc/doc/ExecutableDoc.java
@@ -10,6 +10,8 @@
import java.util.Collections;
import java.util.List;
+import de.ailis.jasdoc.tags.Tags;
+
/**
* Base class for function, method and constructor documentations.
*
@@ -33,11 +35,13 @@
* The description.
* @param parentDoc
* The parent documentation model. Null if none.
+ * @param tags
+ * The tags. Must not be null.
*/
public ExecutableDoc(final String name, final String description,
- final ModelDoc parentDoc)
+ final ModelDoc parentDoc, final Tags tags)
{
- super(name, description, parentDoc);
+ super(name, description, parentDoc, tags);
}
/**
View
8 src/main/java/de/ailis/jasdoc/doc/FieldDoc.java
@@ -5,6 +5,7 @@
package de.ailis.jasdoc.doc;
+import de.ailis.jasdoc.tags.Tags;
import de.ailis.jasdoc.types.JsType;
/**
@@ -37,11 +38,14 @@
* The field modifier flags. Must not be null.
* @param cls
* The class this field belongs to. Must not be null.
+ * @param tags
+ * The tags. Must not be null.
*/
public FieldDoc(final JsType type, final String name,
- final String description, final Modifier modifier, final ClassDoc cls)
+ final String description, final Modifier modifier, final ClassDoc cls,
+ final Tags tags)
{
- super(name, description, cls);
+ super(name, description, cls, tags);
if (type == null) throw new IllegalArgumentException("type is null");
if (modifier == null)
throw new IllegalArgumentException("modifier is null");
View
8 src/main/java/de/ailis/jasdoc/doc/FunctionDoc.java
@@ -5,6 +5,8 @@
package de.ailis.jasdoc.doc;
+import de.ailis.jasdoc.tags.Tags;
+
/**
* Function documentation.
@@ -31,11 +33,13 @@
* The function modifiers. Must not be null.
* @param namespace
* The namespace this function belongs to. Must not be null.
+ * @param tags
+ * The tags. Must not be null.
*/
public FunctionDoc(final String name, final String description,
- final Modifier modifier, final NamespaceDoc namespace)
+ final Modifier modifier, final NamespaceDoc namespace, final Tags tags)
{
- super(name, description, namespace);
+ super(name, description, namespace, tags);
if (namespace == null)
throw new IllegalArgumentException("namespace is null");
if (modifier == null)
View
4 src/main/java/de/ailis/jasdoc/doc/GlobalDoc.java
@@ -5,6 +5,8 @@
package de.ailis.jasdoc.doc;
+import de.ailis.jasdoc.tags.Tags;
+
/**
* The global namespace documentation.
*
@@ -28,7 +30,7 @@
*/
public GlobalDoc(final String title, final String description)
{
- super("", description, null);
+ super("", description, null, new Tags());
this.title = title;
}
View
8 src/main/java/de/ailis/jasdoc/doc/InterfaceDoc.java
@@ -15,6 +15,8 @@
import java.util.Set;
import java.util.TreeSet;
+import de.ailis.jasdoc.tags.Tags;
+
/**
* Interface documentation.
*
@@ -49,12 +51,14 @@
* The namespace this interface belongs to. Must not be null.
* @param superInterfaces
* The super interfaces.
+ * @param tags
+ * The tags. Must not be null.
*/
public InterfaceDoc(final String name, final String description,
final NamespaceDoc namespace,
- final Collection<InterfaceDoc> superInterfaces)
+ final Collection<InterfaceDoc> superInterfaces, final Tags tags)
{
- super(name, description, namespace);
+ super(name, description, namespace, tags);
this.superInterfaces =
Collections.unmodifiableSet(new TreeSet<InterfaceDoc>(
superInterfaces));
View
9 src/main/java/de/ailis/jasdoc/doc/MethodDoc.java
@@ -5,6 +5,8 @@
package de.ailis.jasdoc.doc;
+import de.ailis.jasdoc.tags.Tags;
+
/**
* Method documentation.
@@ -31,11 +33,14 @@
* The method modifier flags. Must not be null.
* @param declaringType
* The class this method belongs to. Must not be null.
+ * @param tags
+ * The tags. Must not be null.
*/
public MethodDoc(final String name, final String description,
- final Modifier modifier, final TypeDoc declaringType)
+ final Modifier modifier, final TypeDoc declaringType,
+ final Tags tags)
{
- super(name, description, declaringType);
+ super(name, description, declaringType, tags);
if (modifier == null)
throw new IllegalArgumentException("modifier is null");
if (declaringType == null)
View
9 src/main/java/de/ailis/jasdoc/doc/ModelDoc.java
@@ -7,6 +7,8 @@
import java.io.Serializable;
import java.util.Date;
+import de.ailis.jasdoc.tags.Tags;
+
/**
* Interface for documentation elements which are used as a model for
* rendering a view.
@@ -45,4 +47,11 @@
* @return This model.
*/
ModelDoc getThis();
+
+ /**
+ * Returns the tags for this model.
+ *
+ * @return The tags.
+ */
+ Tags getTags();
}
View
8 src/main/java/de/ailis/jasdoc/doc/NamespaceDoc.java
@@ -11,6 +11,8 @@
import java.util.Set;
import java.util.TreeSet;
+import de.ailis.jasdoc.tags.Tags;
+
/**
* Namespace documentation.
*
@@ -71,11 +73,13 @@
* The namespace description.
* @param superNamespace
* The super namespace or null if global namespace.
+ * @param tags
+ * The tags. Must not be null.
*/
public NamespaceDoc(final String name, final String description,
- final NamespaceDoc superNamespace)
+ final NamespaceDoc superNamespace, final Tags tags)
{
- super(name, description, superNamespace);
+ super(name, description, superNamespace, tags);
this.superNamespace = superNamespace;
this.immutableClasses = Collections.unmodifiableSet(this.classes);
this.immutableInterfaces = Collections.unmodifiableSet(this.interfaces);
View
8 src/main/java/de/ailis/jasdoc/doc/ParameterDoc.java
@@ -5,6 +5,7 @@
package de.ailis.jasdoc.doc;
+import de.ailis.jasdoc.tags.Tags;
import de.ailis.jasdoc.types.JsType;
/**
@@ -34,11 +35,14 @@
* The parameter description. Must not be null. May be empty.
* @param executable
* The executable this parameter belongs to. Must not be null.
+ * @param tags
+ * The tags. Must not be null.
*/
public ParameterDoc(final JsType type, final String name,
- final String description, final ExecutableDoc executable)
+ final String description, final ExecutableDoc executable,
+ final Tags tags)
{
- super(name, description, executable);
+ super(name, description, executable, tags);
if (name.isEmpty())
throw new IllegalArgumentException("name is empty");
if (type == null)
View
7 src/main/java/de/ailis/jasdoc/doc/ResultDoc.java
@@ -5,6 +5,7 @@
package de.ailis.jasdoc.doc;
+import de.ailis.jasdoc.tags.Tags;
import de.ailis.jasdoc.types.JsType;
/**
@@ -32,11 +33,13 @@
* The result description. Must not be null. May be empty.
* @param executable
* The executable this result belongs to.
+ * @param tags
+ * The tags. Must not be null.
*/
public ResultDoc(final JsType type, final String description,
- final ExecutableDoc executable)
+ final ExecutableDoc executable, final Tags tags)
{
- super("", description, executable);
+ super("", description, executable, tags);
if (type == null)
throw new IllegalArgumentException("type is null");
if (executable == null)
View
8 src/main/java/de/ailis/jasdoc/doc/TypeDoc.java
@@ -12,6 +12,8 @@
import java.util.Set;
import java.util.TreeSet;
+import de.ailis.jasdoc.tags.Tags;
+
/**
* Base class for class and interface documentation.
*
@@ -39,11 +41,13 @@
* The type description. Must not be null.
* @param namespace
* The namespace this type belongs to. Must not be null.
+ * @param tags
+ * The tags. Must not be null.
*/
public TypeDoc(final String name, final String description,
- final NamespaceDoc namespace)
+ final NamespaceDoc namespace, final Tags tags)
{
- super(name, description, namespace);
+ super(name, description, namespace, tags);
if (namespace == null)
throw new IllegalArgumentException("namespace is null");
this.namespace = namespace;
View
7 src/main/java/de/ailis/jasdoc/doc/VariableDoc.java
@@ -5,6 +5,7 @@
package de.ailis.jasdoc.doc;
+import de.ailis.jasdoc.tags.Tags;
import de.ailis.jasdoc.types.JsType;
/**
@@ -37,12 +38,14 @@
* The variable modifier flags. Must not be null.
* @param namespace
* The namespace this variable belongs to. Must not be null.
+ * @param tags
+ * The tags. Must not be null.
*/
public VariableDoc(final JsType type, final String name,
final String description, final Modifier modifier,
- final NamespaceDoc namespace)
+ final NamespaceDoc namespace, final Tags tags)
{
- super(name, description, namespace);
+ super(name, description, namespace, tags);
if (type == null) throw new IllegalArgumentException("type is null");
if (modifier == null)
throw new IllegalArgumentException("modifier is null");
View
23 src/main/java/de/ailis/jasdoc/tags/InheritDocTag.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2012 Klaus Reimer <k@ailis.de>
+ * See LICENSE.md for licensing information.
+ */
+
+package de.ailis.jasdoc.tags;
+
+/**
+ * InheritDoc tag.
+ *
+ * @author Klaus Reimer (k@ailis.de)
+ */
+public class InheritDocTag implements UniqueTag
+{
+ /**
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString()
+ {
+ return "@inheritdoc";
+ }
+}
View
2 src/main/java/de/ailis/jasdoc/tags/TagParser.java
@@ -149,6 +149,8 @@ else if ("final".equals(annoName))
tags.add(new FinalTag());
else if ("constant".equals(annoName))
tags.add(new ConstTag());
+ else if ("inheritDoc".equals(annoName))
+ tags.add(new InheritDocTag());
}
catch (final IllegalArgumentException e)
{

0 comments on commit ac115fd

Please sign in to comment.