rdoc-markdown 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -13
- data/README.md +14 -9
- data/lib/rdoc/generator/markdown.rb +12 -42
- data/lib/rdoc/markdown/version.rb +1 -1
- data/lib/templates/classfile.md.erb +29 -22
- metadata +5 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 022adabd6f2ced45f3d5ff3216b48376914f7ba7b80cc1b87d83e8d7507824d7
|
4
|
+
data.tar.gz: 5d9a514dbbcf570811d0a3f230a2eff9434d61413cf994500bb6fd1f1f49a5d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41604d7644f1e4a437f79c3fcbc868c71189355e4b4ae79be430bd313e7729970d8029af95e2d649c71226079acef183329a1b63c1ce500a00815fa82ef587c1
|
7
|
+
data.tar.gz: f0a44ac4166d92a26b5166c8a290cbcfe16970b8d20c4f8c92ea4f0b5c3a1ae9a23ffe0348f79323c22caad9687eddb0d82346da3a31ba5b7594aeb39dd5e971
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rdoc-markdown (0.
|
5
|
-
activesupport (~> 7.0)
|
4
|
+
rdoc-markdown (0.3)
|
6
5
|
erb (~> 2.0)
|
7
6
|
extralite-bundle (~> 1.0)
|
8
7
|
rdoc (~> 6.0)
|
@@ -12,19 +11,11 @@ PATH
|
|
12
11
|
GEM
|
13
12
|
remote: https://rubygems.org/
|
14
13
|
specs:
|
15
|
-
activesupport (7.0.4)
|
16
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
-
i18n (>= 1.6, < 2)
|
18
|
-
minitest (>= 5.1)
|
19
|
-
tzinfo (~> 2.0)
|
20
14
|
ast (2.4.2)
|
21
15
|
cgi (0.3.3)
|
22
|
-
concurrent-ruby (1.1.10)
|
23
16
|
erb (2.2.3)
|
24
17
|
cgi
|
25
18
|
extralite-bundle (1.16)
|
26
|
-
i18n (1.12.0)
|
27
|
-
concurrent-ruby (~> 1.0)
|
28
19
|
json (2.6.2)
|
29
20
|
minitest (5.16.3)
|
30
21
|
nokogiri (1.13.9-arm64-darwin)
|
@@ -56,7 +47,7 @@ GEM
|
|
56
47
|
rubocop-ast (>= 1.20.1, < 2.0)
|
57
48
|
ruby-progressbar (~> 1.7)
|
58
49
|
unicode-display_width (>= 1.4.0, < 3.0)
|
59
|
-
rubocop-ast (1.
|
50
|
+
rubocop-ast (1.23.0)
|
60
51
|
parser (>= 3.1.1.0)
|
61
52
|
rubocop-performance (1.14.3)
|
62
53
|
rubocop (>= 1.7.0, < 2.0)
|
@@ -66,8 +57,6 @@ GEM
|
|
66
57
|
rubocop (= 1.35.1)
|
67
58
|
rubocop-performance (= 1.14.3)
|
68
59
|
stringio (3.0.2)
|
69
|
-
tzinfo (2.0.5)
|
70
|
-
concurrent-ruby (~> 1.0)
|
71
60
|
unicode-display_width (2.3.0)
|
72
61
|
unindent (1.0)
|
73
62
|
|
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# Rdoc::Markdown
|
2
|
-
|
3
|
-
|
4
|
-
It is still actively in development and while works as proof of concept, still has some quirks here and there.
|
2
|
+
RDoc plugin to generate markdown documentation and search index as sqlite database for entire content.
|
5
3
|
|
6
4
|
## Installation
|
7
5
|
|
@@ -14,15 +12,10 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
14
12
|
$ gem install rdoc-markdown
|
15
13
|
|
16
14
|
## Usage
|
17
|
-
First thing to do, is to install a gem
|
18
|
-
|
19
|
-
`gem install rdoc-markdown`
|
20
|
-
|
21
|
-
Then proceed to directory where you want to generate documentation:
|
22
15
|
|
23
16
|
`rdoc --format=markdown`
|
24
17
|
|
25
|
-
|
18
|
+
No additional parameters are currently available, but that may change.
|
26
19
|
|
27
20
|
## Development
|
28
21
|
Biggest issue is testing this locally, but that's not as hard to do these days.
|
@@ -41,11 +34,23 @@ or you can do the same, but through gemfile:
|
|
41
34
|
gem 'rdoc-markdown`, path: "../rdoc-markdown/`
|
42
35
|
```
|
43
36
|
|
37
|
+
I have scripted entire process in [rm-reload.sh script](https://github.com/skatkov/gum/blob/master/rm-reload.sh). But it assumes, that you have [gum library](https://github.com/charmbracelet/gum) installed.
|
38
|
+
|
39
|
+
## Testing
|
40
|
+
Testing is not excessive, just verifies that basic functionality is operational. Following command should run entire testsuit:
|
41
|
+
|
42
|
+
```
|
43
|
+
rake test
|
44
|
+
```
|
45
|
+
|
44
46
|
## Release
|
45
47
|
```
|
46
48
|
gem build rdoc-markdown.gemspec
|
47
49
|
gem push rdoc-markdown-0.1.2.gem
|
48
50
|
```
|
51
|
+
|
52
|
+
There is `./publish.sh` script that does that. But it assumes, that you have [gum library](https://github.com/charmbracelet/gum) installed.
|
53
|
+
|
49
54
|
## Contributing
|
50
55
|
|
51
56
|
Bug reports and pull requests are welcome on GitHub at https://github.com/skatkov/rdoc-markdown. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/skatkov/rdoc-markdown/blob/master/CODE_OF_CONDUCT.md).
|
@@ -5,9 +5,8 @@ gem "rdoc"
|
|
5
5
|
require "pathname"
|
6
6
|
require "erb"
|
7
7
|
require "reverse_markdown"
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require 'unindent'
|
8
|
+
require "extralite"
|
9
|
+
require "unindent"
|
11
10
|
|
12
11
|
class RDoc::Generator::Markdown
|
13
12
|
RDoc::RDoc.add_generator self
|
@@ -32,7 +31,7 @@ class RDoc::Generator::Markdown
|
|
32
31
|
|
33
32
|
##
|
34
33
|
# Classes and modules to be used by this generator, not necessarily
|
35
|
-
# displayed.
|
34
|
+
# displayed.
|
36
35
|
|
37
36
|
attr_reader :classes
|
38
37
|
|
@@ -63,11 +62,9 @@ class RDoc::Generator::Markdown
|
|
63
62
|
# Generates markdown files and search index file
|
64
63
|
|
65
64
|
def generate
|
66
|
-
|
67
|
-
|
68
|
-
debug("Create directory #{@output_dir}")
|
65
|
+
debug("Setting things up #{@output_dir}")
|
69
66
|
|
70
|
-
|
67
|
+
setup
|
71
68
|
|
72
69
|
debug("Generate documentation in #{@output_dir}")
|
73
70
|
|
@@ -97,7 +94,7 @@ class RDoc::Generator::Markdown
|
|
97
94
|
# This class emits a search index for generated documentation as sqlite database
|
98
95
|
#
|
99
96
|
|
100
|
-
def emit_sqlite(name="index.db")
|
97
|
+
def emit_sqlite(name = "index.db")
|
101
98
|
db = Extralite::Database.new("#{output_dir}/#{name}")
|
102
99
|
|
103
100
|
db.execute <<-SQL
|
@@ -124,7 +121,7 @@ class RDoc::Generator::Markdown
|
|
124
121
|
result << {
|
125
122
|
name: "#{klass.full_name}.#{method.name}",
|
126
123
|
type: "Method",
|
127
|
-
path: "#{turn_to_path(klass.full_name)}
|
124
|
+
path: "#{turn_to_path(klass.full_name)}##{method.aref}"
|
128
125
|
}
|
129
126
|
end
|
130
127
|
|
@@ -132,7 +129,7 @@ class RDoc::Generator::Markdown
|
|
132
129
|
result << {
|
133
130
|
name: "#{klass.full_name}.#{const.name}",
|
134
131
|
type: "Constant",
|
135
|
-
path: "#{turn_to_path(klass.full_name)}
|
132
|
+
path: "#{turn_to_path(klass.full_name)}##{const.name}"
|
136
133
|
}
|
137
134
|
end
|
138
135
|
|
@@ -140,7 +137,7 @@ class RDoc::Generator::Markdown
|
|
140
137
|
result << {
|
141
138
|
name: "#{klass.full_name}.#{attr.name}",
|
142
139
|
type: "Attribute",
|
143
|
-
path: "#{turn_to_path(klass.full_name)}
|
140
|
+
path: "#{turn_to_path(klass.full_name)}##{attr.aref}"
|
144
141
|
}
|
145
142
|
end
|
146
143
|
end
|
@@ -152,19 +149,6 @@ class RDoc::Generator::Markdown
|
|
152
149
|
|
153
150
|
def emit_classfiles
|
154
151
|
@classes.each do |klass|
|
155
|
-
klass_methods = []
|
156
|
-
instance_methods = []
|
157
|
-
|
158
|
-
klass.method_list.each do |method|
|
159
|
-
next if method.visibility.to_s.eql?("private")
|
160
|
-
|
161
|
-
if method.type == "class"
|
162
|
-
klass_methods << method
|
163
|
-
else
|
164
|
-
instance_methods << method
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
152
|
template = ERB.new File.read(File.join(TEMPLATE_DIR, "classfile.md.erb"))
|
169
153
|
|
170
154
|
out_file = Pathname.new("#{output_dir}/#{turn_to_path klass.full_name}")
|
@@ -187,7 +171,7 @@ class RDoc::Generator::Markdown
|
|
187
171
|
# Converts HTML string into a Markdown string with some cleaning and improvements.
|
188
172
|
|
189
173
|
def markdownify(input)
|
190
|
-
md= ReverseMarkdown.convert input
|
174
|
+
md = ReverseMarkdown.convert input
|
191
175
|
|
192
176
|
# unintent multiline strings
|
193
177
|
md.unindent!
|
@@ -198,14 +182,10 @@ class RDoc::Generator::Markdown
|
|
198
182
|
|
199
183
|
"[#{match[1]}](#{match[2]}.md#{match[3]})"
|
200
184
|
end
|
201
|
-
|
202
|
-
# clean up things, to make it look neat.
|
203
|
-
|
204
|
-
md.gsub("[↑](#top)", "").lstrip
|
205
185
|
end
|
206
186
|
|
207
187
|
# Aliasing a shorter method name for use in templates
|
208
|
-
alias_method
|
188
|
+
alias_method :h, :markdownify
|
209
189
|
|
210
190
|
##
|
211
191
|
# Prepares for document generation, by creating required folders and initializing variables.
|
@@ -215,20 +195,10 @@ class RDoc::Generator::Markdown
|
|
215
195
|
return if instance_variable_defined?(:@output_dir)
|
216
196
|
|
217
197
|
@output_dir = Pathname.new(@options.op_dir).expand_path(@base_dir)
|
198
|
+
@output_dir.mkpath
|
218
199
|
|
219
200
|
return unless @store
|
220
201
|
|
221
202
|
@classes = @store.all_classes_and_modules.sort
|
222
|
-
@modsort = get_sorted_module_list @classes
|
223
|
-
end
|
224
|
-
|
225
|
-
##
|
226
|
-
# Return a list of the documented modules sorted by salience first, then
|
227
|
-
# by name.
|
228
|
-
|
229
|
-
def get_sorted_module_list classes
|
230
|
-
classes.select do |klass|
|
231
|
-
klass.display?
|
232
|
-
end.sort
|
233
203
|
end
|
234
204
|
end
|
@@ -1,24 +1,31 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
<%
|
1
|
+
# <%= klass.type %> <%= klass.full_name.strip %> [](#<%= klass.aref.strip %>) [](#top)
|
2
|
+
<%= h klass.description %>
|
3
|
+
<% klass.each_section do |section, constants, attributes| %>
|
4
|
+
<% if section.title %>## <%= section.title.strip %> <% end %>
|
5
|
+
<% if section.comment %> <%=h section.description %><% end%>
|
6
|
+
<% unless klass.constants.empty? %>
|
4
7
|
## Constants
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
<% end
|
9
|
-
<%
|
8
|
+
<% klass.constants.each do |const| %>
|
9
|
+
### <%= const.name.strip %>[](#<%= const.name.strip %>)
|
10
|
+
<% if const.comment %> <%= h const.description %> <%else%> (Not documented) <% end %>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
13
|
+
<% unless attributes&.empty? %>
|
10
14
|
## Attributes
|
11
|
-
<%
|
12
|
-
|
13
|
-
<%
|
14
|
-
<%
|
15
|
-
|
16
|
-
|
17
|
-
<%
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
15
|
+
<% attributes.each do |attr| %>
|
16
|
+
### <%= attr.rw %><%=h attr.name.strip %>[](#<%= attr.aref.strip %>)
|
17
|
+
<% if attr.comment %> <%= h attr.description %> <%else%> (Not documented) <% end %>
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
20
|
+
<% klass.methods_by_type(section).each do |type, visibilities| %>
|
21
|
+
<% next if visibilities.empty? %>
|
22
|
+
<% visibilities.each do |visibility, methods| %>
|
23
|
+
<% next if methods.empty? %>
|
24
|
+
## <%= visibility.capitalize %> <%= type.capitalize %> Methods
|
25
|
+
<% methods.each do |method|%>
|
26
|
+
### <%= method.name.strip %><%= method.param_seq.strip %> [](#<%= method.aref.strip %>)
|
27
|
+
<% if method.comment %> <%= h method.description %> <% else %> (Not documented) <%end%>
|
28
|
+
<% end %>
|
29
|
+
<% end %>
|
30
|
+
<% end %>
|
31
|
+
<% end %>
|
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.
|
4
|
+
version: '0.3'
|
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-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: activesupport
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '7.0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '7.0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: unindent
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,8 +150,8 @@ dependencies:
|
|
164
150
|
- - "~>"
|
165
151
|
- !ruby/object:Gem::Version
|
166
152
|
version: '2.0'
|
167
|
-
description:
|
168
|
-
|
153
|
+
description: RDoc plugin to generate markdown documentation and search index as sqlite
|
154
|
+
database for entire content.
|
169
155
|
email:
|
170
156
|
- github@skatkov.com
|
171
157
|
executables: []
|
@@ -216,5 +202,5 @@ requirements: []
|
|
216
202
|
rubygems_version: 3.1.6
|
217
203
|
signing_key:
|
218
204
|
specification_version: 4
|
219
|
-
summary:
|
205
|
+
summary: RDoc plugin to generate markdown documentation
|
220
206
|
test_files: []
|