use of com.disney.groovity.doc.Tag in project groovity by disney.
the class Taggables method getDocs.
@SuppressWarnings({ "rawtypes", "unchecked" })
public List getDocs() {
ArrayList docs = new ArrayList();
ArrayList<Map.Entry<String, Taggable>> entries = new ArrayList<Map.Entry<String, Taggable>>();
entries.addAll(groovyTags.entrySet());
// alphabetize for consistency
Collections.sort(entries, new Comparator<Map.Entry<String, Taggable>>() {
public int compare(Entry<String, Taggable> o1, Entry<String, Taggable> o2) {
return o1.getKey().compareTo(o2.getKey());
}
});
for (Map.Entry<String, Taggable> entry : entries) {
Tag ti = entry.getValue().getClass().getAnnotation(Tag.class);
if (ti != null) {
LinkedHashMap doc = new LinkedHashMap();
docs.add(doc);
doc.put(NAME, entry.getKey());
doc.put(INFO, ti.info());
if (ti.body() != null) {
doc.put(BODY, ti.body());
}
if (ti.returns() != null) {
doc.put(RETURNS, ti.returns());
}
if (ti.sample() != null) {
doc.put(SAMPLE, ti.sample());
}
boolean isCore = false;
Package pkg = entry.getValue().getClass().getPackage();
if (pkg != null) {
isCore = GROOVITY_CORE_TAG_PACKAGE.equals(pkg.getName());
}
doc.put(CORE, isCore);
Attr[] atts = ti.attrs();
if (atts != null) {
ArrayList attMap = new ArrayList();
for (Attr att : atts) {
HashMap attVal = new HashMap();
attVal.put(NAME, att.name());
attVal.put(INFO, att.info());
attVal.put(REQUIRED, att.required());
attMap.add(attVal);
}
doc.put(ATTRS, attMap);
}
}
;
}
return docs;
}
Aggregations