solargraph 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/solargraph/api_map.rb +2 -1
- data/lib/solargraph/server.rb +46 -1
- data/lib/solargraph/shell.rb +4 -0
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/views/foo.erb +1 -0
- data/lib/solargraph/views/layout.erb +10 -0
- data/lib/solargraph/views/search.erb +11 -0
- data/lib/solargraph/yard_map.rb +26 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcc8258dc2a089ffad93983d3b3ce3be674d59ef
|
4
|
+
data.tar.gz: 9ab4aff3fe0acdad6d240c012ec66fceb29dc31d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01650890323070734abf02b839cac279d8336190555838d750440958ca0dde3e67f65cb42669ace4e026af479c4b9b1be26949a1cd3a8d00a59a1425476a235b
|
7
|
+
data.tar.gz: c30d4fa71a335aa731c9093906df3966563320a0e0158976601e403da504c6d11d195f7ca4a4fea188d7eaf72c5b770158c134587ff45dfe458fc7fff318a93f
|
data/lib/solargraph/api_map.rb
CHANGED
data/lib/solargraph/server.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'sinatra/base'
|
2
2
|
require 'thread'
|
3
|
+
require 'yard'
|
3
4
|
|
4
5
|
module Solargraph
|
5
6
|
class Server < Sinatra::Base
|
7
|
+
|
6
8
|
set :port, 7657
|
7
9
|
|
8
10
|
@@api_hash = {}
|
@@ -31,6 +33,36 @@ module Solargraph
|
|
31
33
|
end
|
32
34
|
end
|
33
35
|
|
36
|
+
get '/search' do
|
37
|
+
workspace = params['workspace']
|
38
|
+
api_map = @@api_hash[workspace]
|
39
|
+
required = []
|
40
|
+
unless api_map.nil?
|
41
|
+
required.concat api_map.required
|
42
|
+
end
|
43
|
+
yard = YardMap.new(required: required, workspace: workspace)
|
44
|
+
@results = yard.search(params['query'])
|
45
|
+
erb :search
|
46
|
+
end
|
47
|
+
|
48
|
+
get '/document' do
|
49
|
+
workspace = params['workspace']
|
50
|
+
api_map = @@api_hash[workspace]
|
51
|
+
required = []
|
52
|
+
unless api_map.nil?
|
53
|
+
required.concat api_map.required
|
54
|
+
end
|
55
|
+
yard = YardMap.new(required: required, workspace: workspace)
|
56
|
+
@objects = yard.document(params['query'])
|
57
|
+
erb :document
|
58
|
+
end
|
59
|
+
|
60
|
+
def htmlify object
|
61
|
+
h = Helpers.new
|
62
|
+
h.object = object
|
63
|
+
h.htmlify object.docstring.all, :rdoc
|
64
|
+
end
|
65
|
+
|
34
66
|
class << self
|
35
67
|
def run!
|
36
68
|
constant_updates
|
@@ -53,10 +85,23 @@ module Solargraph
|
|
53
85
|
@@api_hash[k] = update
|
54
86
|
}
|
55
87
|
}
|
56
|
-
sleep
|
88
|
+
sleep 10
|
57
89
|
end
|
58
90
|
}
|
59
91
|
end
|
60
92
|
end
|
93
|
+
|
94
|
+
class Helpers
|
95
|
+
attr_accessor :object
|
96
|
+
attr_accessor :serializer
|
97
|
+
include YARD::Templates::Helpers::HtmlHelper
|
98
|
+
def options
|
99
|
+
@options ||= YARD::Templates::TemplateOptions.new
|
100
|
+
end
|
101
|
+
# HACK: The linkify method just returns the arguments as plain text
|
102
|
+
def linkify *args
|
103
|
+
args.join(', ')
|
104
|
+
end
|
105
|
+
end
|
61
106
|
end
|
62
107
|
end
|
data/lib/solargraph/shell.rb
CHANGED
@@ -44,8 +44,12 @@ module Solargraph
|
|
44
44
|
|
45
45
|
desc 'server', 'Start a Solargraph server'
|
46
46
|
option :port, type: :numeric, aliases: :p, desc: 'The server port', default: 7657
|
47
|
+
option :views, type: :string, aliases: :v, desc: 'The view template directory', default: nil
|
48
|
+
option :files, type: :string, aliases: :f, desc: 'The public files directory', default: nil
|
47
49
|
def server
|
48
50
|
Solargraph::Server.set :port, options[:port]
|
51
|
+
Solargraph::Server.set :views, options[:views] unless options[:views].nil?
|
52
|
+
Solargraph::Server.set :public_folder, options[:files] unless options[:files].nil?
|
49
53
|
Solargraph::Server.run!
|
50
54
|
end
|
51
55
|
|
data/lib/solargraph/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
<p>Foo!</p>
|
data/lib/solargraph/yard_map.rb
CHANGED
@@ -38,6 +38,32 @@ module Solargraph
|
|
38
38
|
@yardocs ||= []
|
39
39
|
end
|
40
40
|
|
41
|
+
def search query
|
42
|
+
found = []
|
43
|
+
yardocs.each { |y|
|
44
|
+
yard = YARD::Registry.load! y
|
45
|
+
unless yard.nil?
|
46
|
+
yard.paths.each { |p|
|
47
|
+
found.push p if p.downcase.include?(query.downcase)
|
48
|
+
}
|
49
|
+
end
|
50
|
+
}
|
51
|
+
found
|
52
|
+
end
|
53
|
+
|
54
|
+
def document query
|
55
|
+
found = []
|
56
|
+
yardocs.each { |y|
|
57
|
+
yard = YARD::Registry.load! y
|
58
|
+
unless yard.nil?
|
59
|
+
obj = yard.at query
|
60
|
+
#found.push YARD::Templates::Engine.render(format: :html, object: obj) unless obj.nil?
|
61
|
+
found.push obj unless obj.nil?
|
62
|
+
end
|
63
|
+
}
|
64
|
+
found
|
65
|
+
end
|
66
|
+
|
41
67
|
def get_constants namespace, scope = ''
|
42
68
|
consts = []
|
43
69
|
result = []
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solargraph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -131,6 +131,9 @@ files:
|
|
131
131
|
- lib/solargraph/snippets.rb
|
132
132
|
- lib/solargraph/suggestion.rb
|
133
133
|
- lib/solargraph/version.rb
|
134
|
+
- lib/solargraph/views/foo.erb
|
135
|
+
- lib/solargraph/views/layout.erb
|
136
|
+
- lib/solargraph/views/search.erb
|
134
137
|
- lib/solargraph/yard_map.rb
|
135
138
|
- yardoc/2.0.0.tar.gz
|
136
139
|
homepage: http://castwide.com
|