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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c06a568d53f3c10d270e3bde6f54a675654ae12
4
- data.tar.gz: 788a257e6d80a0a8587eebd539bf1cebed2afedc
3
+ metadata.gz: dcc8258dc2a089ffad93983d3b3ce3be674d59ef
4
+ data.tar.gz: 9ab4aff3fe0acdad6d240c012ec66fceb29dc31d
5
5
  SHA512:
6
- metadata.gz: f7046e14bce46e04439da78451b6f7a3351fa97d5b184d2b55d67379b7d70c16ef1b699a8cec2bc194ffbfb3f8b6eb73d9bf7272b14698051b51250c8b74dbb2
7
- data.tar.gz: ee12ed39ebaa7dc39104c12171ef80e92fb7a8984ec96cbf3f87d8ef6420299bfd5867ad01e461d378bb27485105878734bb909ca8c33554b5d635e0e468849a
6
+ metadata.gz: 01650890323070734abf02b839cac279d8336190555838d750440958ca0dde3e67f65cb42669ace4e026af479c4b9b1be26949a1cd3a8d00a59a1425476a235b
7
+ data.tar.gz: c30d4fa71a335aa731c9093906df3966563320a0e0158976601e403da504c6d11d195f7ca4a4fea188d7eaf72c5b770158c134587ff45dfe458fc7fff318a93f
@@ -19,7 +19,8 @@ module Solargraph
19
19
  include NodeMethods
20
20
 
21
21
  attr_reader :workspace
22
-
22
+ attr_reader :required
23
+
23
24
  def initialize workspace = nil
24
25
  @workspace = workspace
25
26
  clear
@@ -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 2
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
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Solargraph
2
- VERSION = '0.3.1'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -0,0 +1 @@
1
+ <p>Foo!</p>
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Layout</title>
5
+ </head>
6
+ <body>
7
+ <h1>Layout</h1>
8
+ <%= yield %>
9
+ </body>
10
+ </html>
@@ -0,0 +1,11 @@
1
+ <h1>Search Results for <kbd><%= params['query'] %></kbd></h1>
2
+
3
+ <% unless @results.empty? %>
4
+ <ul>
5
+ <% @results.each do |result| %>
6
+ <li>
7
+ <a href="#"><%= result %></a>
8
+ </li>
9
+ <% end %>
10
+ </ul>
11
+ <% end %>
@@ -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.3.1
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-23 00:00:00.000000000 Z
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