doc_to_dash 0.0.3 → 0.0.4
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.
- data/lib/doc_to_dash/rdoc_darkfish_parser.rb +57 -0
- data/lib/doc_to_dash/version.rb +1 -1
- data/lib/doc_to_dash/yard_parser.rb +5 -0
- data/lib/doc_to_dash.rb +10 -6
- metadata +2 -1
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module DocToDash
|
4
|
+
class RdocDarkfishParser
|
5
|
+
def initialize(doc_directory)
|
6
|
+
@doc_directory = doc_directory
|
7
|
+
@classes = []
|
8
|
+
@methods = []
|
9
|
+
|
10
|
+
fix_css_file
|
11
|
+
|
12
|
+
load_search_json
|
13
|
+
parse_through_json
|
14
|
+
end
|
15
|
+
|
16
|
+
def fix_css_file
|
17
|
+
File.open(@doc_directory + '/rdoc.css', 'a') { |file| file.write('nav, footer { display: none !important; } #documentation { margin: 0 !important; } .method-source-code { display: block !important; }') }
|
18
|
+
end
|
19
|
+
|
20
|
+
def load_search_json
|
21
|
+
search_index_js_path = @doc_directory + '/js/search_index.js'
|
22
|
+
search_index_js_file = File.read(search_index_js_path)
|
23
|
+
search_index_js_file.gsub!('var search_data = ', '')
|
24
|
+
|
25
|
+
@search_json = JSON::parse(search_index_js_file)
|
26
|
+
@search_json = @search_json["index"]["info"]
|
27
|
+
end
|
28
|
+
|
29
|
+
def parse_through_json
|
30
|
+
return false unless @search_json
|
31
|
+
|
32
|
+
blacklist = %w{README_FOR_APP}
|
33
|
+
|
34
|
+
@search_json.each do |item|
|
35
|
+
next if blacklist.include?(item[0])
|
36
|
+
|
37
|
+
if item[3] == ""
|
38
|
+
@classes << [item[2], item[0]]
|
39
|
+
elsif item[3] == "()"
|
40
|
+
@methods << [item[2], "#{item[1]}##{item[0]}"]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
true
|
45
|
+
end
|
46
|
+
|
47
|
+
def classes
|
48
|
+
@classes
|
49
|
+
end
|
50
|
+
alias :parse_classes :classes
|
51
|
+
|
52
|
+
def methods
|
53
|
+
@methods
|
54
|
+
end
|
55
|
+
alias :parse_methods :methods
|
56
|
+
end
|
57
|
+
end
|
data/lib/doc_to_dash/version.rb
CHANGED
@@ -4,6 +4,11 @@ module DocToDash
|
|
4
4
|
@doc_directory = doc_directory
|
5
5
|
end
|
6
6
|
|
7
|
+
#TODO: fix the CSS file and remove the top header. JS will not work on Dash.
|
8
|
+
#def fix_css_file
|
9
|
+
# File.open(@doc_directory + '/rdoc.css', 'a') { |file| file.write('nav, footer { display: none !important; } #documentation { margin: 0 !important; } .method-source-code { display: block !important; }') }
|
10
|
+
#end
|
11
|
+
|
7
12
|
def parse_classes
|
8
13
|
classes_file = File.read(@doc_directory + '/class_list.html')
|
9
14
|
classes_html = Nokogiri::HTML(classes_file)
|
data/lib/doc_to_dash.rb
CHANGED
@@ -45,12 +45,16 @@ module DocToDash
|
|
45
45
|
@classes = parser.parse_classes
|
46
46
|
@methods = parser.parse_methods
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
if @methods && @classes
|
49
|
+
load_methods_into_database
|
50
|
+
load_classes_into_database
|
51
|
+
|
52
|
+
log "Docset created."
|
53
|
+
@docset_path
|
54
|
+
else
|
55
|
+
log "Docset could not be created. Parser returned no data."
|
56
|
+
return false
|
57
|
+
end
|
54
58
|
end
|
55
59
|
|
56
60
|
private
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doc_to_dash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- bin/doc_to_dash
|
60
60
|
- doc_to_dash.gemspec
|
61
61
|
- lib/doc_to_dash.rb
|
62
|
+
- lib/doc_to_dash/rdoc_darkfish_parser.rb
|
62
63
|
- lib/doc_to_dash/version.rb
|
63
64
|
- lib/doc_to_dash/yard_parser.rb
|
64
65
|
homepage: https://rubygems.org/gems/doc_to_dash
|