use of de.philippkatz.knime.jsondocgen.docs.PortTypeDoc in project knime-json-node-doc-generator by NodePit.
the class JsonNodeDocuGenerator method generate.
/**
* Starts generating the node reference documents.
*
* @throws Exception
*/
private void generate() throws Exception {
if (!m_skipNodeDocumentation) {
LOGGER.info("Reading node repository");
IRepositoryObject root = RepositoryManager.INSTANCE.getRoot();
rootCategoryDoc = new CategoryDocBuilder();
rootCategoryDoc.setId(root.getID());
rootCategoryDoc.setName(root.getName());
rootCategoryDoc.setContributingPlugin(root.getContributingPlugin());
// replace '/' with points and remove leading '/'
if (m_catPath.startsWith("/")) {
m_catPath = m_catPath.substring(1);
}
m_catPath = m_catPath.replaceAll("/", ".");
// recursively generate the node reference and the node description
// pages
generate(m_directory, root, null, rootCategoryDoc);
CategoryDoc rootCategory = rootCategoryDoc.build();
String resultJson = rootCategory.toJson();
File resultFile = new File(m_directory, "nodeDocumentation.json");
LOGGER.info("Writing nodes to " + resultFile);
IOUtils.write(resultJson, new FileOutputStream(resultFile), StandardCharsets.UTF_8);
}
if (!m_skipPortDocumentation) {
LOGGER.info("Generating port documentation");
Map<Class<? extends PortObject>, PortTypeDocBuilder> builders = new HashMap<>();
// all registered port types indexed by the PortObject class; read this only
// once from the registry and cache it, b/c the registry creates new PortTypes
// dynamically when requesting an unknown type
Map<Class<? extends PortObject>, PortType> portTypes = PortTypeRegistry.getInstance().availablePortTypes().stream().collect(Collectors.toMap(PortType::getPortObjectClass, Function.identity()));
LOGGER.debug(String.format("Found %s ports to process", portTypes.size()));
processPorts(portTypes.keySet(), portTypes, builders);
// get the root element (all PortObjects inherit from this interface).
PortTypeDoc rootElement = builders.get(PortObject.class).build();
File portTypeResultFile = new File(m_directory, "portDocumentation.json");
LOGGER.info("Writing port types to " + portTypeResultFile);
IOUtils.write(Utils.toJson(rootElement), new FileOutputStream(portTypeResultFile), StandardCharsets.UTF_8);
}
if (!m_skipSplashIcons) {
LOGGER.debug("Generating splash icons");
List<SplashIconDoc> splashIcons = SplashIconReader.readSplashIcons();
LOGGER.debug(String.format("Found %s splash icons", splashIcons.size()));
File splashIconsResultFile = new File(m_directory, "splashIcons.json");
LOGGER.info("Writing splash icons to " + splashIconsResultFile);
IOUtils.write(Utils.toJson(splashIcons), new FileOutputStream(splashIconsResultFile), StandardCharsets.UTF_8);
}
}
Aggregations