We’ve been making the move to Visual Studio Code, which is – as far as we can tell – Salesforce’s recommended path forward for an IDE. If you haven’t checked it out, make some time soon. It’s a terrific tool. There are many options for integrating SfApexDoc into a VS Code project.
We created a custom task, that can be run via a keyboard shortcut. Here’s how to get this hooked up yourself:
- Copy SfApexDoc.jar to the root folder of your project
- Create a shell script (generateDocs.sh) to delete old docs, generate new docs, open the index in a browser, etc. If you’re on a PC, you may choose to use a batch file or different shell. Also, you may need to make the file executable.
#!/bin/sh
rm -fr ./SfApexDocs
java -jar ./SfApexDoc.jar -s ./src/classes -t . -h ./SfApexDocHome.txt -a ./SfApexDocAuthor.txt
open ./SfApexDocs/index.html
- Add the following task to your project’s tasks.json file (you may need to create this in the .vscode folder).
{
"label": "SfApexDoc Generate",
"command": "./generateDocs.sh",
"type": "shell",
"presentation": {
"reveal": "always",
"panel": "shared",
"echo": false
},
"problemMatcher": []
}
That should do it! If 3 or 4 keystrokes is just too inconvenient, assign this task to a keyboard shortcut and generate docs with a single <cmd>+d. Go to Keyboard Shortcuts preferences, click on the “keybindings.json” link, and add this to the array:
{
"key": "cmd+d",
"command": "workbench.action.tasks.runTask",
"args": "SfApexDoc Generate"
}
As always, let us know if you have questions or feature ideas for SfApexDoc. We’d be glad to help!