The Visual Studio Code editor can be a convenient tool for editing RosettaScripts XML. This document shows how to enable auto-completion and mouse-over help in VSCode.
Follow the following five steps:
Open VSCode, and from the View menu, select Extensions. Type "XSD" in the search dialogue, and select Xml Complete. Click Install.
You will probably want to install the XML and XML Tools packages as well. These allow more information from your XSD including docs for the sections and each class within.
Export a RosettaScripts XSD file (a file defining all the allowed commands and syntax in RosettaScripts) from RosettaScripts. To do this, from the commandline run:
<path to Rosetta>/Rosetta/main/source/bin/rosetta_scripts.default.linuxgccrelease -output_schema rosettascripts.xsd
<path to Rosetta>with your Rostta path, and
.default.linuxgccreleasewith your build, operating system, compiler, and mode (e.g.
.cxx11thread.maxcosclangreleasefor the threaded build on MacOS). This command will run the RosettaScripts application, which will write out an XSD file and then exit. Place this XSD file someplace convenient. (Note that Rosetta must be compiled first.)
Open a RosettaScripts XML file in VSCode. (You can create a new, empty RosettaScripts XML file by running the RosettaScripts application with no options and cutting-and-pasting from the output into VSCode.) Add the following lines to the top of your XML file:
<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file://<path to file>/rosettascripts.xsd" />
In the above, replace
<path to file> with the path absolute path to the RosettaScripts xml file (e.g. /home/user). Only absolute paths are fully supported, but when a plain filename is provided, the extension will search for schema next to local file for convenience.
And that's it! Steps 1, 2, and 3 only need be done once. Step 4 need only be done when you compile a new version of Rosetta. Step 5 needs to be done for each XML file that you work with, and unfortunately, the added
<root ... /> lines need to be commented out (flanked with
-->) before running the script. This will likely be addressed in the near future so that Rosetta just disregards these extra lines. In the mean time, one can comment and uncomment these lines easily in VSCode by selecting them and pressing
Ctrl + / on a PC, or
Command + / on a Mac.
When using VSCode:
Ctrl + spacewill bring up tab completion. For example, in the
<MOVERS> ... </MOVERS>block of a RosettaScripts script, you will see a list of all available scriptable movers if you hit
Ctrl + space. Within a tag, you'll see a list of all options for that tag. In some cases, you can even get a list of allowed values for an option. For example, if you type
<MinMover name="minimize" type="" />, put the cursor between the two quotation marks, and press
Ctrl + space, you will see a list of all allowed minimization flavours in Rosetta.