From b139d09fdd538ec89fa37c5b196f9f05c0775e3d Mon Sep 17 00:00:00 2001 From: Zhuyuan Wu Date: Thu, 16 Jun 2016 09:57:54 +0100 Subject: [PATCH 1/2] Resolving 'type' and 'enum' as well as ['struct','trait','fn'] --- lib/docs-resolver.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/docs-resolver.coffee b/lib/docs-resolver.coffee index 11ddf38..fb79610 100644 --- a/lib/docs-resolver.coffee +++ b/lib/docs-resolver.coffee @@ -8,7 +8,7 @@ module.exports = DocsResolver = @searchMathingDocs(path, callback) searchMathingDocs: (path, callback) -> - for objectType in ['struct','trait','fn'] + for objectType in ['type','enum','struct','trait','fn'] @assertPageAvailability(path, "#{objectType}.$1.html", callback) @assertModulePageAvailability(path, callback) From 22392431fbca6fae74a566d7479bf13ce2f0d525 Mon Sep 17 00:00:00 2001 From: Zhuyuan Wu Date: Thu, 16 Jun 2016 10:44:42 +0100 Subject: [PATCH 2/2] Allow choosing the channel from which the document will be searched --- lib/docs-resolver.coffee | 3 ++- lib/rust-api-docs-helper.coffee | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/docs-resolver.coffee b/lib/docs-resolver.coffee index fb79610..95dac46 100644 --- a/lib/docs-resolver.coffee +++ b/lib/docs-resolver.coffee @@ -15,10 +15,11 @@ module.exports = DocsResolver = assertModulePageAvailability: (path, callback) -> @assertPageAvailability(path, "$1/index.html", callback) assertPageAvailability: (path, resourceEndFormat, callback) -> + channel = atom.config.get('rust-api-docs-helper.rustChannel') p = path.replace(/(\w*?)$/, resourceEndFormat) req = new XMLHttpRequest() req.onloadend = @onLoadEnd(path, @cache, callback) - req.open("HEAD","http://doc.rust-lang.org/#{p}") + req.open("HEAD","http://doc.rust-lang.org/#{channel}/#{p}") req.send() onLoadEnd: (path, cache, callback) -> (e) -> diff --git a/lib/rust-api-docs-helper.coffee b/lib/rust-api-docs-helper.coffee index 3f03770..eaee566 100644 --- a/lib/rust-api-docs-helper.coffee +++ b/lib/rust-api-docs-helper.coffee @@ -7,6 +7,13 @@ Shell = require 'shell' module.exports = RustApiDocsHelper = config: + rustChannel: + type: 'string' + description: """ + The distribution channel from which the document will be searched + """ + enum: ['stable','beta','nightly'] + default: 'stable' useInternalBrowser: type:'boolean' description: """If set, a URL open request will be sent, that will attempt to open the docs URL within atom,