use of com.google.copybara.doc.DocBase.DocFlag in project copybara by google.
the class MarkdownRenderer method flags.
private static String flags(Collection<DocFlag> flags) {
StringBuilder sb = new StringBuilder();
if (!flags.isEmpty()) {
sb.append("\n\n**Command line flags:**\n\n");
sb.append(tableHeader("Name", "Type", "Description"));
for (DocFlag field : flags) {
sb.append(tableRow(nowrap(field.name), String.format("*%s*", field.type), field.description));
}
sb.append("\n");
}
return sb.toString();
}
use of com.google.copybara.doc.DocBase.DocFlag in project copybara by google.
the class ModuleLoader method generateFlagsInfo.
private Collection<DocFlag> generateFlagsInfo(AnnotatedElement el) {
List<DocFlag> result = new ArrayList<>();
getAnnotation(el, UsesFlags.class).ifPresent(cls -> {
for (Class<?> c : cls.value()) {
for (Field f : c.getDeclaredFields()) {
for (Parameter p : f.getAnnotationsByType(Parameter.class)) {
if (p.hidden()) {
continue;
}
String description = p.description();
if (DurationConverter.class.isAssignableFrom(p.converter())) {
description += (description.endsWith(".") ? " " : ". ") + " Example values: 30s, 20m, 1h, etc.";
}
result.add(new DocFlag(Joiner.on(", ").join(p.names()), simplerJavaTypes(f.getType()), description));
}
}
}
});
return result;
}