in streampipes-maven-plugin/src/main/java/org/apache/streampipes/smp/ExtractDocumentationMojo.java [77:149]
public void execute() throws MojoFailureException {
var log = getLog();
var targetDir = this.session.getCurrentProject().getBasedir() + File.separator + "target";
var spIgnoreFile =
this.session.getCurrentProject().getBasedir() + File.separator + SP_IGNORE_FILENAME;
var docsBasePath = Paths.get(targetDir, DOCS_ROOT_FOLDER);
try {
List<String> pipelineElementsToExclude = new ArrayList<>();
var path = Paths.get(spIgnoreFile);
if (Files.exists(path)) {
try {
pipelineElementsToExclude = Files.readAllLines(path);
} catch (IOException e) {
log.error(String.format("Could not open .spignore file at path %s", path));
}
}
var loader = getClassLoader(project);
var finalPipelineElementsToExclude = pipelineElementsToExclude;
var localesExtractor = new LocalesExtractor(log, loader);
var extensionsElements = new ExtensionsFinder(loader, initClass)
.findExtensions()
.stream()
.filter(am -> !finalPipelineElementsToExclude.contains(am.getAppId()))
.peek(localesExtractor::applyLocales)
.sorted(AssetModel::compareTo)
.toList();
log.info(String.format("Will generate documentation for %s resources", extensionsElements.size()));
for (AssetModel extensionsElement : extensionsElements) {
try {
var imgPath = Paths.get(targetDir, DOCS_ROOT_FOLDER, IMG_FOLDER, extensionsElement.getAppId());
new IconResourceGenerator(loader, extensionsElement, imgPath).generate();
var docsPath = Paths.get(
targetDir,
DOCS_ROOT_FOLDER,
DOCS_PE_FOLDER);
new DocumentationResourceGenerator(loader, extensionsElement, docsPath).generate();
log.info(
String.format(
"Generated documentation for %s (%s, %s)",
extensionsElement.getAppId(),
extensionsElement.getPipelineElementName(),
extensionsElement.getPipelineElementDescription()));
new AdditionalAssetsResourceGenerator(log, loader, extensionsElement, imgPath).generate();
} catch (IOException e) {
log.warn(
String.format(
"Could not generate documentation for %s (%s, %s)",
extensionsElement.getAppId(),
extensionsElement.getPipelineElementName(),
extensionsElement.getPipelineElementDescription()), e);
}
}
var sidebarConfig = new SidebarConfigGenerator(log, extensionsElements).generate();
var sidebarPath = docsBasePath.resolve("sidebars.json");
log.info(String.format("Writing sidebar config to %s", sidebarPath));
FileUtils.writeStringToFile(sidebarPath.toFile(),
sidebarConfig, Charsets.UTF_8);
} catch (IOException | DependencyResolutionRequiredException | ClassNotFoundException
| IllegalAccessException | InstantiationException e) {
throw new MojoFailureException(
"Could not generate documentation - please check the initClass for available extensions", e);
}
}