The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
Mistake in OperatorDocLoader.loadSelectedOperatorDocuLocally?
I've been looking into how RapidMiner defines operator documentation bundles in XML (resources/com/rapidminer/resources/i18n/OperatorsCoreDocumentation.xml) but then substitutes html in the GUI's help window. For instance, the stream_database operator's XML doc bundle (an element of OperatorsCoreDocumentation.xml) is not used: rather, RapidMiner substitutes /resources/com/rapidminer/resources/doc/core/stream_database.html
This is not hinted at anywhere within the operator documentation; there is nothing in the operator's description XML that links it to the html documentation (unlike the xml documentation, which is explicitly identified in the extension's OperatorsSHORTNAME.xml, 'operators' element, 'docbundle' attribute). It took me a while to find that it happens in OperatorDocLoader.loadSelectedOperatorDocuLocally, which (if online) first looks for a page on the RapidMiner wiki, and then falls back to an html file. Only if this also fails is the XML doc bunde actually used.
Fine, I'm now ready to write an html page similar to those describing the core operators and include it in my operator plugin...But loadSelectedOperatorDocuLocally constructs the name like this:
com/rapidminer/resources/doc/NAMESPACE/SHORTNAME:NAME.html
...which is not a legal file name under most file systems because of the colon (highlighted in red in the line above). The culprit is line 496:
String documentationResource = "/" + RESOURCE_SUB_DIR + "/" + namespace + "/" + opDesc.getKey() + ".html"
I have a feeling it should instead be:
String documentationResource = "/" + RESOURCE_SUB_DIR + "/" + namespace + "/" + opDesc.getKeyWithoutPrefix() + ".html"
Am I right?
(Note also how the 'key' used here is NOT the 'key' defined in the operator's XML description: it is instead the 'shortName' element prefixed to the 'name' element (with substitution of underscores for spaces); this is a little confusing)
This is not hinted at anywhere within the operator documentation; there is nothing in the operator's description XML that links it to the html documentation (unlike the xml documentation, which is explicitly identified in the extension's OperatorsSHORTNAME.xml, 'operators' element, 'docbundle' attribute). It took me a while to find that it happens in OperatorDocLoader.loadSelectedOperatorDocuLocally, which (if online) first looks for a page on the RapidMiner wiki, and then falls back to an html file. Only if this also fails is the XML doc bunde actually used.
Fine, I'm now ready to write an html page similar to those describing the core operators and include it in my operator plugin...But loadSelectedOperatorDocuLocally constructs the name like this:
com/rapidminer/resources/doc/NAMESPACE/SHORTNAME:NAME.html
...which is not a legal file name under most file systems because of the colon (highlighted in red in the line above). The culprit is line 496:
String documentationResource = "/" + RESOURCE_SUB_DIR + "/" + namespace + "/" + opDesc.getKey() + ".html"
I have a feeling it should instead be:
String documentationResource = "/" + RESOURCE_SUB_DIR + "/" + namespace + "/" + opDesc.getKeyWithoutPrefix() + ".html"
Am I right?
(Note also how the 'key' used here is NOT the 'key' defined in the operator's XML description: it is instead the 'shortName' element prefixed to the 'name' element (with substitution of underscores for spaces); this is a little confusing)
Tagged:
0
Answers
Currently we try to change the documentation system. The loading of the help from the html files is (or will be in near future) deprecated. For greater flexibility we will use XML files which is already done for a lot of our operators. If you take a look on the current code in the SVN repository you will notice a file "rm_doc.jar" in the lib directory. All documentation is stored here in a directory structure induced by the keys in the "OperatorsCore.xml" file. Every documentation is now a XML file and the issue with the prefix is already fixed for this mechanism and should work for your extension.
To write your own XML-documentation just create a directory with the name of your plugin namespace under the "resources" directory and then further subdirectories to match the group keys in your OperatorsXXX.xml file for a given operator. Then name a XML file after the key of your operator and your are done.
Use the XML files in the "rm_doc.jar" file as a template, e.g. the "Retrive" operator:
What about /resources/com/rapidminer/resources/i18n/OperatorsCoreDocumentation.xml? It has an 'operator' element with sub-elements 'name' ("Retrieve"), 'synopsis' and 'help' (containing a rudimentary description). By comparison, /resources/com/rapidminer/resources/OperatorsCore.xml has an 'operator' element with sub-elements 'key' ("retrieve"), 'class' ("com.rapidminer.operator.io.RepositorySource"), 'icon', and 'replaces'. At its root, OperatorsCore.xml sets docbundle to OperatorsCoreDocumentation. Meanwhile, core/repository_access/retrieve.xml opens with an 'operator' element whose key attribute (not a sub-element, mind you) is "operator.retrieve".
I also note the stream_database operator is not in lib/rm_doc.jar (there is no com.import.data in there), which explains why its html help is being displayed.
Here are the relevant fragments of my extension. In its build.xml, I have: In OperatorsLTFReader.xml: In OperatorsDocLTFReader.xml: When com.rapidminer.gui.OperatorDocLoader.loadOperatorDocumentation is invoked for my extension (when I select it in the Operators palette of the GUI), it receives an OperatorDescription which has fullyQualifiedGroupKey == "import.data"; key == "stream_trace"; provider.extensionId == "rmx_LTFDataReader"; provider.name == "LTFReader"; and provider.prefix == "LTFDataReader".
Being online, loadOperatorDocumentation first tries loadSelectedOperatorDocuFromWiki, which builds
operatorWikiName = opDesc.getName().replace(" ", "_") thus "Stream_LTF_Trace" (it's the operator name, not the extension name). Then it gets the prefix from the provider: So it asks the wiki for the document "LTFDataReader:Stream_LTF_Trace". I get the warning:
WARNING: Could not open http://rapid-i.com/wiki/index.php?title=LTFDataReader:Stream_LTF_Trace: http://rapid-i.com/wiki/index.php?title=LTFDataReader:Stream_LTF_Trace
(It is not clear why some operators in the wiki have a "prefix:name" entry instead of a plain "name" entry)
This naturally fails so it falls back on OperatorDocLoader.loadSelectedOperatorDocuLocally which considers namespace to be the provider's extensionId and then builds
String documentationResource = "/" + RESOURCE_SUB_DIR + "/" + namespace + "/" + opDesc.getKeyWithoutPrefix() + ".html"
which yields /com/rapidminer/resources/doc/rmx_LTFDataReader/stream_trace.html.
Opening this stream also fails of course, so loadSelectedOperatorDocuLocally falls back on makeOperatorDocumentation which extracts the operatorDocBundle (com/rapidminer/resources/i18n/OperatorsDocLTFReader).
Most of this is now kind of moot, as I'll try and follow the rm_doc.jar approach instead.
Oh, I see here (http://rapid-i.com/rapidforum/index.php/topic,5696.0.html) that it can't be done. With the RapidMiner sample data repositories. Is there a way my extension could install its own little data repository?
Anyway, the planned order which documentation will be used is: