use of com.linkedin.restli.tools.idlgen.DocletDocsProvider in project rest.li by linkedin.
the class RestLiSnapshotExporter method export.
public GeneratorResult export(String apiName, String[] classpath, String[] sourcePaths, String[] resourcePackages, String[] resourceClasses, String outdir, List<DocsProvider> additionalDocProviders) throws IOException {
final RestLiConfig config = new RestLiConfig();
if (resourcePackages != null) {
config.addResourcePackageNames(resourcePackages);
}
final Map<String, String> classFileNames = new HashMap<String, String>();
for (String path : sourcePaths) {
classFileNames.putAll(FileClassNameScanner.scan(path));
}
Collection<String> sourceFileNames = null;
if (resourceClasses != null || resourcePackages == null) {
if (resourceClasses != null) {
config.addResourceClassNames(resourceClasses);
sourceFileNames = new ArrayList<String>(resourceClasses.length);
for (String resourceClass : resourceClasses) {
final String resourceFileName = classFileNames.get(resourceClass);
if (resourceFileName == null) {
log.warn("Unable to find source file for class " + resourceClass + " . No Javadoc will be generated for it.");
} else {
sourceFileNames.add(resourceFileName);
}
}
} else {
config.addResourceClassNames(classFileNames.keySet());
}
}
log.info("Executing Rest.li annotation processor...");
final RestLiApiBuilder apiBuilder = new RestLiApiBuilder(config);
final Map<String, ResourceModel> rootResourceMap = apiBuilder.build();
if (rootResourceMap.isEmpty()) {
return new SnapshotResult();
}
// We always include the doc provider for javadoc
DocsProvider javadocProvider = new DocletDocsProvider(apiName, classpath, sourcePaths, resourcePackages);
DocsProvider docsProvider;
if (additionalDocProviders == null || additionalDocProviders.isEmpty()) {
docsProvider = javadocProvider;
} else {
// dynamically load doc providers for additional language, if available
List<DocsProvider> languageSpecificDocsProviders = new ArrayList<DocsProvider>();
languageSpecificDocsProviders.add(javadocProvider);
languageSpecificDocsProviders.addAll(MultiLanguageDocsProvider.loadExternalProviders(additionalDocProviders));
docsProvider = new MultiLanguageDocsProvider(languageSpecificDocsProviders);
}
log.info("Registering source files with doc providers...");
docsProvider.registerSourceFiles(classFileNames.values());
log.info("Exporting snapshot files...");
final GeneratorResult result = generateSnapshotFiles(apiName, outdir, rootResourceMap, docsProvider);
log.info("Done!");
return result;
}
Aggregations