rdoc-markdown 0.1.8 → 0.1.12
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/Gemfile.lock +3 -1
- data/lib/rdoc/generator/markdown.rb +42 -32
- data/lib/rdoc/markdown/version.rb +1 -1
- data/lib/templates/classfile.md.erb +2 -2
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8541f95990a90cf56b56fc4ac7ddc00ee027327023a127063c30cb1b87449b6
|
4
|
+
data.tar.gz: b00c270ed9c64a36120900e0bfb8eb794afda0ab1b28cdb4cbc51c016b9c4999
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58ba2c78a1f23cea5738a2e65df6468a4c70da00fb8654affd479cb2ed244930fa63c56d91451d83c0475c1c31102319af9970f3d9d7f000ea04bfecd146616a
|
7
|
+
data.tar.gz: 5960431dc78731a5b65b57a004b6982e7eac883ed1bc2306e92bf34f3948bd3bf33494e3daac4dab1685a1d19e6b8831993247cfd1d91ee8ae0852c483c79453
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rdoc-markdown (0.1.
|
4
|
+
rdoc-markdown (0.1.10)
|
5
5
|
erb (~> 2.0)
|
6
|
+
extralite-bundle (~> 1.0)
|
6
7
|
rdoc (~> 6.0)
|
7
8
|
reverse_markdown (~> 2.0)
|
8
9
|
|
@@ -13,6 +14,7 @@ GEM
|
|
13
14
|
cgi (0.3.3)
|
14
15
|
erb (2.2.3)
|
15
16
|
cgi
|
17
|
+
extralite-bundle (1.16)
|
16
18
|
json (2.6.2)
|
17
19
|
minitest (5.16.3)
|
18
20
|
nokogiri (1.13.8-arm64-darwin)
|
@@ -5,10 +5,8 @@ gem "rdoc"
|
|
5
5
|
require "pathname"
|
6
6
|
require "erb"
|
7
7
|
require "reverse_markdown"
|
8
|
+
require 'extralite'
|
8
9
|
|
9
|
-
# Markdown generator.
|
10
|
-
# Registers command line options and generates markdown files
|
11
|
-
# RDoc documentation and options.
|
12
10
|
class RDoc::Generator::Markdown
|
13
11
|
RDoc::RDoc.add_generator self
|
14
12
|
|
@@ -33,21 +31,6 @@ class RDoc::Generator::Markdown
|
|
33
31
|
|
34
32
|
attr_reader :classes
|
35
33
|
|
36
|
-
##
|
37
|
-
# Files to be displayed by this generator
|
38
|
-
|
39
|
-
attr_reader :files
|
40
|
-
|
41
|
-
##
|
42
|
-
# Methods to be displayed by this generator
|
43
|
-
|
44
|
-
attr_reader :methods
|
45
|
-
|
46
|
-
##
|
47
|
-
# Sorted list of classes and modules to be displayed by this generator
|
48
|
-
|
49
|
-
attr_reader :modsort
|
50
|
-
|
51
34
|
##
|
52
35
|
# Directory where generated class HTML files live relative to the output
|
53
36
|
# dir.
|
@@ -66,9 +49,6 @@ class RDoc::Generator::Markdown
|
|
66
49
|
@base_dir = Pathname.pwd.expand_path
|
67
50
|
|
68
51
|
@classes = nil
|
69
|
-
@files = nil
|
70
|
-
@methods = nil
|
71
|
-
@modsort = nil
|
72
52
|
end
|
73
53
|
|
74
54
|
def generate
|
@@ -81,6 +61,10 @@ class RDoc::Generator::Markdown
|
|
81
61
|
debug("Generate documentation in #{@output_dir}")
|
82
62
|
|
83
63
|
emit_classfiles
|
64
|
+
|
65
|
+
debug("Generate index db file: #{output_dir}/index.db")
|
66
|
+
|
67
|
+
emit_sqlite
|
84
68
|
end
|
85
69
|
|
86
70
|
private
|
@@ -95,6 +79,29 @@ class RDoc::Generator::Markdown
|
|
95
79
|
end
|
96
80
|
end
|
97
81
|
|
82
|
+
def emit_sqlite
|
83
|
+
db = Extralite::Database.new("#{output_dir}/index.db")
|
84
|
+
|
85
|
+
db.execute <<-SQL
|
86
|
+
create table contentIndex (
|
87
|
+
id INTEGER PRIMARY KEY,
|
88
|
+
name TEXT,
|
89
|
+
type TEXT,
|
90
|
+
path TEXT
|
91
|
+
);
|
92
|
+
SQL
|
93
|
+
|
94
|
+
@classes.map do |klass|
|
95
|
+
{
|
96
|
+
name: klass.full_name,
|
97
|
+
type: klass.type.capitalize,
|
98
|
+
path: turn_to_path(klass.full_name)
|
99
|
+
}
|
100
|
+
end.each do |rec|
|
101
|
+
db.execute "insert into contentIndex (name, type, path) values (:name, :type, :path)", rec
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
98
105
|
def emit_classfiles
|
99
106
|
@classes.each do |klass|
|
100
107
|
klass_methods = []
|
@@ -112,7 +119,7 @@ class RDoc::Generator::Markdown
|
|
112
119
|
|
113
120
|
template = ERB.new File.read(File.join(TEMPLATE_DIR, "classfile.md.erb"))
|
114
121
|
|
115
|
-
out_file = Pathname.new("#{output_dir}/#{turn_to_path klass.full_name}
|
122
|
+
out_file = Pathname.new("#{output_dir}/#{turn_to_path klass.full_name}")
|
116
123
|
out_file.dirname.mkpath
|
117
124
|
|
118
125
|
result = template.result(binding)
|
@@ -124,22 +131,27 @@ class RDoc::Generator::Markdown
|
|
124
131
|
|
125
132
|
private
|
126
133
|
|
127
|
-
def
|
128
|
-
|
134
|
+
def turn_to_path(class_name)
|
135
|
+
"#{class_name.gsub("::", "/")}.md"
|
136
|
+
end
|
137
|
+
|
138
|
+
def markdownify(input)
|
139
|
+
md= ReverseMarkdown.convert input, github_flavored: true
|
140
|
+
|
141
|
+
# Replace .html to .md extension in all markdown links
|
142
|
+
md = md.gsub(/\[(.+)\]\((.+).html(.*)\)/) do |_|
|
129
143
|
match = Regexp.last_match
|
130
144
|
|
131
145
|
"[#{match[1]}](#{match[2]}.md#{match[3]})"
|
132
146
|
end
|
133
|
-
end
|
134
147
|
|
135
|
-
|
136
|
-
class_name.gsub("::", "/")
|
137
|
-
end
|
148
|
+
# clean up things, to make it look neat.
|
138
149
|
|
139
|
-
|
140
|
-
replace_extensions_in_links ReverseMarkdown.convert string.strip, github_flavored: true
|
150
|
+
md.gsub("[↑](#top)", "").lstrip
|
141
151
|
end
|
142
152
|
|
153
|
+
alias_method :h, :markdownify
|
154
|
+
|
143
155
|
def setup
|
144
156
|
return if instance_variable_defined?(:@output_dir)
|
145
157
|
|
@@ -148,8 +160,6 @@ class RDoc::Generator::Markdown
|
|
148
160
|
return unless @store
|
149
161
|
|
150
162
|
@classes = @store.all_classes_and_modules.sort
|
151
|
-
@files = @store.all_files.sort
|
152
|
-
@methods = @classes.map(&:method_list).flatten.sort
|
153
163
|
@modsort = get_sorted_module_list @classes
|
154
164
|
end
|
155
165
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
# <% if klass.type == 'class' %><%= klass.type.capitalize %>: **<%= klass.full_name %>**<% if klass.superclass %> < <% end %><% unless String === klass.superclass %><%= klass.superclass&.name %> <% else %> <%= klass.superclass %> <% end %> <% else %> <%= klass.type.capitalize
|
2
|
-
|
1
|
+
# <% if klass.type == 'class' %><%= klass.type.capitalize %>: **<%= klass.full_name %>**<% if klass.superclass %> < <% end %><% unless String === klass.superclass %><%= klass.superclass&.name %> <% else %> <%= klass.superclass %> <% end %> <% else %> <%= klass.type.capitalize %>: <%= klass&.name %> <% end %>
|
2
|
+
<% if klass.description && !klass.description.empty? %><%= h klass.description %><% end %>
|
3
3
|
<% unless klass.constants.empty? %>
|
4
4
|
## Constants
|
5
5
|
***
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdoc-markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stanislav (Stas) Katkov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: extralite-bundle
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: minitest
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|