Skip to content

Commit

Permalink
Gem documentation commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
castwide committed Apr 16, 2018
1 parent 36156f8 commit 03a74dc
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,6 @@
## 0.16.1 - April 23, 2018
- Commands for building gem documentation

## 0.16.0 - April 16, 2018
- `solargraph.diagnostics` default is false
- Updated solargraph-utils
Expand Down
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -9,6 +9,7 @@ Solargraph is a language server that provides intellisense, code completion, and
* Context-aware suggestions and documentation for the Ruby core
* Detection of some variable types and method return values (e.g., `String.new.` returns String instance methods)
* Identification of local, class, and instance variables within the current scope
* Support for gems
* Near-complete support for the Ruby stdlib
* Partial support for Ruby on Rails

Expand Down Expand Up @@ -61,6 +62,11 @@ Hover your mouse over code to see method definitions, return values, and links t

To go to a method or variable's definition, right-click and select "Go to Definition" from the context menu, or press F12 for the definition at the cursor.

### Gem Support

Solargraph is capable of providing code completion and documentation for gems. When your code uses `require` to include a gem, its classes and methods become available in completion and intellisense.

You can make sure your gems are available with the commands `Build new gem documentation` or `Rebuild all gem documentation` in the command palette.

### Diagnostics (Linting)

Expand Down
13 changes: 11 additions & 2 deletions package.json
Expand Up @@ -3,7 +3,7 @@
"displayName": "Ruby Solargraph",
"description": "Code completion and inline documentation for Ruby",
"icon": "solargraph.png",
"version": "0.16.0",
"version": "0.16.1",
"publisher": "castwide",
"author": {
"name": "Fred Snyder"
Expand All @@ -26,7 +26,6 @@
"autocomplete",
"intellisense",
"YARD",
"code completion",
"language server"
],
"engines": {
Expand Down Expand Up @@ -100,6 +99,16 @@
"command": "solargraph.downloadCore",
"title": "Download current Ruby documentation",
"category": "Solargraph"
},
{
"command": "solargraph.buildGemDocs",
"title": "Build new gem documentation",
"category": "Solargraph"
},
{
"command": "solargraph.rebuildAllGemDocs",
"title": "Rebuild all gem documentation",
"category": "Solargraph"
}
],
"keybindings": [
Expand Down
38 changes: 38 additions & 0 deletions src/extension.ts
Expand Up @@ -152,6 +152,44 @@ export function activate(context: ExtensionContext) {
});
context.subscriptions.push(disposableSearch);

// Build gem documentation command
var disposableBuildGemDocs = vscode.commands.registerCommand('solargraph.buildGemDocs', () => {
var disposableStatus = vscode.window.setStatusBarMessage('Building new YARD documentation...')
var cmd = solargraph.commands.yardCommand(['gems'], solargraphConfiguration);
cmd.on('exit', (code) => {
disposableStatus.dispose();
if (code == 0) {
vscode.window.setStatusBarMessage('YARD documentation complete.', 3000);
} else {
vscode.window.setStatusBarMessage('An error occurred during build.', 3000);
}
});
cmd.on('error', (err) => {
disposableStatus.dispose();
vscode.window.setStatusBarMessage('Unable to build documentation.', 3000);
});
});
context.subscriptions.push(disposableBuildGemDocs);

// Rebuild gems documentation command
var disposableRebuildAllGemDocs = vscode.commands.registerCommand('solargraph.rebuildAllGemDocs', () => {
var disposableStatus = vscode.window.setStatusBarMessage('Rebuilding all YARD documentation...')
var cmd = solargraph.commands.yardCommand(['gems', '--rebuild'], solargraphConfiguration);
cmd.on('exit', (code) => {
disposableStatus.dispose();
if (code == 0) {
vscode.window.setStatusBarMessage('YARD documentation rebuild complete.', 3000);
} else {
vscode.window.setStatusBarMessage('An error occurred during rebuild.', 3000);
}
});
cmd.on('error', (err) => {
disposableStatus.dispose();
vscode.window.setStatusBarMessage('Unable to rebuild documentation.', 3000);
});
});
context.subscriptions.push(disposableRebuildAllGemDocs);

solargraph.verifyGemIsInstalled(solargraphConfiguration).then((result) => {
if (result) {
console.log('The Solargraph gem is installed and working.');
Expand Down

0 comments on commit 03a74dc

Please sign in to comment.