diff --git a/application/META-INF/MANIFEST.MF b/application/META-INF/MANIFEST.MF index 323fcde..bd370b6 100644 --- a/application/META-INF/MANIFEST.MF +++ b/application/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: JSON node documentation generator Bundle-SymbolicName: de.philippkatz.knime.jsondocgen.application;singleton:=true -Bundle-Version: 1.15.0.qualifier +Bundle-Version: 1.16.0.qualifier Bundle-Vendor: Philipp Katz; Selenium Nodes Bundle-RequiredExecutionEnvironment: JavaSE-17 Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.6.0,5.0.0)", diff --git a/application/pom.xml b/application/pom.xml index 2f9989d..0df1c87 100644 --- a/application/pom.xml +++ b/application/pom.xml @@ -4,13 +4,13 @@ 4.0.0 de.philippkatz.knime.jsondocgen.application - 1.15.0-SNAPSHOT + 1.16.0-SNAPSHOT eclipse-plugin de.philippkatz.knime.jsondocgen de.philippkatz.knime.jsondocgen - 1.15.0-SNAPSHOT + 1.16.0-SNAPSHOT diff --git a/application/src/de/philippkatz/knime/jsondocgen/JsonNodeDocuGenerator.java b/application/src/de/philippkatz/knime/jsondocgen/JsonNodeDocuGenerator.java index c8b1f37..6ca489d 100644 --- a/application/src/de/philippkatz/knime/jsondocgen/JsonNodeDocuGenerator.java +++ b/application/src/de/philippkatz/knime/jsondocgen/JsonNodeDocuGenerator.java @@ -82,6 +82,8 @@ import org.knime.core.node.context.ports.ConfigurablePortGroup; import org.knime.core.node.context.ports.ModifiablePortsConfiguration; import org.knime.core.node.context.ports.PortGroupConfiguration; +import org.knime.core.node.extension.InvalidNodeFactoryExtensionException; +import org.knime.core.node.extension.NodeFactoryExtensionManager; import org.knime.core.node.port.PortObject; import org.knime.core.node.port.PortObjectSpec; import org.knime.core.node.port.PortType; @@ -92,6 +94,7 @@ import org.knime.core.webui.node.dialog.kai.KaiNodeInterfaceFactory; import org.knime.workbench.repository.RepositoryManager; import org.knime.workbench.repository.model.Category; +import org.knime.workbench.repository.model.DefaultNodeTemplate; import org.knime.workbench.repository.model.IContainerObject; import org.knime.workbench.repository.model.IRepositoryObject; import org.knime.workbench.repository.model.NodeTemplate; @@ -129,6 +132,8 @@ public class JsonNodeDocuGenerator implements IApplication { private static final String INCLUDE_DEPRECATED_ARG = "-includeDeprecated"; + private static final String INCLUDE_HIDDEN_NODES_ARG = "-includeHidden"; + private static final String SKIP_NODE_DOCUMENTATION = "-skipNodeDocumentation"; private static final String SKIP_PORT_DOCUMENTATION = "-skipPortDocumentation"; @@ -151,6 +156,8 @@ private static void printUsage() { + " category-path (e.g. /community) : Only nodes within the specified category path will be considered. If not specified '/' is used."); System.err.println( "\t" + INCLUDE_DEPRECATED_ARG + " : Include nodes marked as 'deprecated' in the extension point."); + System.err.println( + "\t" + INCLUDE_HIDDEN_NODES_ARG + " : Include nodes marked as 'hidden' in the extension point."); System.err.println("\t" + SKIP_NODE_DOCUMENTATION + " : Skip generating node documentation"); System.err.println("\t" + SKIP_PORT_DOCUMENTATION + " : Skip generating port documentation"); System.err.println("\t" + SKIP_SPLASH_ICONS + " : Skip extracting splash screen icons"); @@ -165,6 +172,8 @@ private static void printUsage() { private String m_catPath = "/"; private boolean m_includeDeprecated = false; + + private boolean m_includeHiddenNodes = false; private boolean m_skipNodeDocumentation = false; @@ -199,6 +208,8 @@ public Object start(final IApplicationContext context) throws Exception { m_pluginIds.add(args[i + 1]); } else if (args[i].equals(INCLUDE_DEPRECATED_ARG)) { m_includeDeprecated = true; + } else if (args[i].equals(INCLUDE_HIDDEN_NODES_ARG)) { + m_includeHiddenNodes = true; } else if (args[i].equals(SKIP_NODE_DOCUMENTATION)) { m_skipNodeDocumentation = true; } else if (args[i].equals(SKIP_PORT_DOCUMENTATION)) { @@ -267,9 +278,16 @@ private void generate() throws Exception { } m_catPath = m_catPath.replaceAll("/", "."); + var hiddenNodeFactoryIds = Collections.emptySet(); + + // add “hidden” nodes to the root + if (m_includeHiddenNodes) { + hiddenNodeFactoryIds = addHiddenNodes(root); + } + // recursively generate the node reference and the node description // pages - generate(m_directory, root, null, rootCategoryDoc); + generate(root, null, rootCategoryDoc, hiddenNodeFactoryIds); CategoryDoc rootCategory = rootCategoryDoc.build(); String resultJson = rootCategory.toJson(); @@ -331,6 +349,27 @@ private void generate() throws Exception { } } + @SuppressWarnings({ "removal", "unchecked" }) + private static Set addHiddenNodes(IRepositoryObject root) throws InvalidNodeFactoryExtensionException { + Set hiddenNodeFactoryIds = new HashSet(); + for (var nodeFactoryExtension : NodeFactoryExtensionManager.getInstance().getNodeFactoryExtensions()) { + if (nodeFactoryExtension.isHidden()) { + var factory = nodeFactoryExtension.getFactory(); + LOGGER.info("Add hidden node " + factory.getFactoryId()); + var pluginID = nodeFactoryExtension.getPlugInSymbolicName(); + var categoryPath = nodeFactoryExtension.getCategoryPath(); + var node = new DefaultNodeTemplate((Class>) factory.getClass(), + factory.getNodeName(), pluginID, categoryPath, factory.getType()); + node.setAfterID(nodeFactoryExtension.getAfterID()); + node.setDeprecated(nodeFactoryExtension.isDeprecated()); + var parentContainer = ((Root) root).findContainer(node.getCategoryPath()); + parentContainer.addChild(node); + hiddenNodeFactoryIds.add(factory.getFactoryId()); + } + } + return hiddenNodeFactoryIds; + } + /** * Process port type information (and recursively build the hierarchical * documentation structure). @@ -410,13 +449,14 @@ private static void processPorts(Collection> portObj /** * Recursively generates the nodes description documents and the menu entries. * - * @param directory * @param current * @param parent * parent repository object as some nodes pointing to "frequently * used"-repository object as a parent * @param parentCategory * The parent category where to insert the JSON entry. + * @param hiddenNodeFactoryIds + * Node factory IDs which are marked as “hidden” (for setting the hidden flag.) * @throws Exception * @throws TransformerException * @@ -424,8 +464,8 @@ private static void processPorts(Collection> portObj * been skipped */ @SuppressWarnings({ "restriction", "unchecked" }) - private boolean generate(final File directory, final IRepositoryObject current, final IRepositoryObject parent, - CategoryDocBuilder parentCategory) throws TransformerException, Exception { + private boolean generate(final IRepositoryObject current, final IRepositoryObject parent, + CategoryDocBuilder parentCategory, Set hiddenNodeFactoryIds) throws TransformerException, Exception { if (current instanceof NodeTemplate nodeTemplate) { @@ -492,6 +532,9 @@ private boolean generate(final File directory, final IRepositoryObject current, // so, do not overwrite with false, if already set to true builder.setDeprecated(true); } + + builder.setHidden(hiddenNodeFactoryIds.contains(current.getID())); + if ((!deprecated || m_includeDeprecated)) { parentCategory.addNode(builder.build()); } @@ -518,7 +561,7 @@ private boolean generate(final File directory, final IRepositoryObject current, boolean hasChildren = false; for (IRepositoryObject repoObj : repoObjs) { - hasChildren = hasChildren | generate(directory, repoObj, current, newCategory); + hasChildren = hasChildren | generate(repoObj, current, newCategory, hiddenNodeFactoryIds); } if (hasChildren && current instanceof Category) { diff --git a/application/src/de/philippkatz/knime/jsondocgen/MigrationRuleExtractor.java b/application/src/de/philippkatz/knime/jsondocgen/MigrationRuleExtractor.java index 8cea1d9..1ee7ae3 100644 --- a/application/src/de/philippkatz/knime/jsondocgen/MigrationRuleExtractor.java +++ b/application/src/de/philippkatz/knime/jsondocgen/MigrationRuleExtractor.java @@ -39,6 +39,7 @@ public static List extractMigrationRules() { // they replaced this in 5.2 but of course the “get all” is not accessible - // facepalm; in case it gets removed, we'll need to build this ourselves or get // it from the “generate node documenation” phase instead + @SuppressWarnings({ "removal" }) var nodeFactoryExtensions = NodeFactoryExtensionManager.getInstance().getNodeFactoryExtensions(); LOGGER.info(String.format("Generating %s migration rules", migrationRules.size())); diff --git a/application/src/de/philippkatz/knime/jsondocgen/docs/NodeDoc.java b/application/src/de/philippkatz/knime/jsondocgen/docs/NodeDoc.java index 333ff4d..20f711a 100644 --- a/application/src/de/philippkatz/knime/jsondocgen/docs/NodeDoc.java +++ b/application/src/de/philippkatz/knime/jsondocgen/docs/NodeDoc.java @@ -229,7 +229,7 @@ public DynamicPortGroup(Integer insertBefore, String name, String groupIdentifie public final List views; public final String type; public final boolean deprecated; - /** @deprecated We no longer set this. */ + /** @since v1.16 (undeprecated) */ public final boolean hidden; public final InteractiveView interactiveView; public final boolean streamable; diff --git a/feature/feature.xml b/feature/feature.xml index fe7a387..504f959 100644 --- a/feature/feature.xml +++ b/feature/feature.xml @@ -2,7 +2,7 @@ 4.0.0 de.philippkatz.knime.jsondocgen.feature - 1.15.0-SNAPSHOT + 1.16.0-SNAPSHOT eclipse-feature de.philippkatz.knime.jsondocgen de.philippkatz.knime.jsondocgen - 1.15.0-SNAPSHOT + 1.16.0-SNAPSHOT diff --git a/p2/pom.xml b/p2/pom.xml index 050f1a4..3b5a611 100644 --- a/p2/pom.xml +++ b/p2/pom.xml @@ -4,13 +4,13 @@ 4.0.0 de.philippkatz.knime.jsondocgen.p2 - 1.15.0-SNAPSHOT + 1.16.0-SNAPSHOT eclipse-repository de.philippkatz.knime.jsondocgen de.philippkatz.knime.jsondocgen - 1.15.0-SNAPSHOT + 1.16.0-SNAPSHOT diff --git a/pom.xml b/pom.xml index 76cb764..07ea0db 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 de.philippkatz.knime.jsondocgen de.philippkatz.knime.jsondocgen - 1.15.0-SNAPSHOT + 1.16.0-SNAPSHOT pom @@ -39,7 +39,7 @@ de.philippkatz.knime.jsondocgen de.philippkatz.knime.jsondocgen.targetplatform - 1.15.0-SNAPSHOT + 1.16.0-SNAPSHOT diff --git a/targetplatform/pom.xml b/targetplatform/pom.xml index b0c1291..8a8dbab 100644 --- a/targetplatform/pom.xml +++ b/targetplatform/pom.xml @@ -9,7 +9,7 @@ de.philippkatz.knime.jsondocgen de.philippkatz.knime.jsondocgen - 1.15.0-SNAPSHOT + 1.16.0-SNAPSHOT diff --git a/tests/META-INF/MANIFEST.MF b/tests/META-INF/MANIFEST.MF index cb0f54f..8ff1515 100644 --- a/tests/META-INF/MANIFEST.MF +++ b/tests/META-INF/MANIFEST.MF @@ -2,8 +2,8 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: JSON node documentation generator tests Bundle-SymbolicName: de.philippkatz.knime.jsondocgen.tests;singleton:=true -Bundle-Version: 1.15.0.qualifier +Bundle-Version: 1.16.0.qualifier Bundle-Vendor: Philipp Katz; Selenium Nodes Bundle-RequiredExecutionEnvironment: JavaSE-17 -Fragment-Host: de.philippkatz.knime.jsondocgen.application;bundle-version="1.15.0" +Fragment-Host: de.philippkatz.knime.jsondocgen.application;bundle-version="1.16.0" Require-Bundle: org.junit;bundle-version="4.12.0" diff --git a/tests/pom.xml b/tests/pom.xml index 5bd8c13..0ecc6df 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -4,13 +4,13 @@ 4.0.0 de.philippkatz.knime.jsondocgen.tests - 1.15.0-SNAPSHOT + 1.16.0-SNAPSHOT eclipse-test-plugin de.philippkatz.knime.jsondocgen de.philippkatz.knime.jsondocgen - 1.15.0-SNAPSHOT + 1.16.0-SNAPSHOT