use of com.google.copybara.doc.annotations.Library in project copybara by google.
the class ModuleLoader method load.
public ImmutableList<DocModule> load(List<String> jarFiles) throws IOException {
List<String> classes = loadClassList(jarFiles);
List<DocModule> modules = new ArrayList<>();
DocModule docModule = new DocModule("Globals", "Global functions available in Copybara");
modules.add(docModule);
for (String clsName : classes) {
try {
Class<?> cls = Generator.class.getClassLoader().loadClass(clsName);
getAnnotation(cls, Library.class).ifPresent(library -> docModule.functions.addAll(processFunctions(cls, null)));
getAnnotation(cls, StarlarkBuiltin.class).ifPresent(library -> {
if (!library.documented()) {
return;
}
DocSignaturePrefix prefixAnn = cls.getAnnotation(DocSignaturePrefix.class);
String prefix = prefixAnn != null ? prefixAnn.value() : library.name();
DocModule mod = new DocModule(library.name(), library.doc());
mod.functions.addAll(processFunctions(cls, prefix));
mod.fields.addAll(processFields(cls));
mod.flags.addAll(generateFlagsInfo(cls));
modules.add(mod);
});
} catch (ClassNotFoundException e) {
throw new IllegalStateException("Cannot generate documentation for " + clsName, e);
}
}
return deduplicateAndSort(modules);
}
Aggregations