Search in sources :

Example 1 with DocFlag

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();
}
Also used : DocFlag(com.google.copybara.doc.DocBase.DocFlag)

Example 2 with DocFlag

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;
}
Also used : DocField(com.google.copybara.doc.DocBase.DocField) Field(java.lang.reflect.Field) DocFlag(com.google.copybara.doc.DocBase.DocFlag) UsesFlags(com.google.copybara.doc.annotations.UsesFlags) ArrayList(java.util.ArrayList) Parameter(com.beust.jcommander.Parameter)

Aggregations

DocFlag (com.google.copybara.doc.DocBase.DocFlag)2 Parameter (com.beust.jcommander.Parameter)1 DocField (com.google.copybara.doc.DocBase.DocField)1 UsesFlags (com.google.copybara.doc.annotations.UsesFlags)1 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1