rdoc-markdown 0.2.1 → 0.3.1
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 +1 -12
- data/README.md +13 -10
- data/lib/rdoc/generator/markdown.rb +7 -35
- data/lib/rdoc/markdown/version.rb +1 -1
- data/lib/templates/classfile.md.erb +29 -21
- metadata +2 -21
- data/.DS_Store +0 -0
- data/docs/example.rb +0 -142
- data/lib/.DS_Store +0 -0
- data/lib/rdoc/.DS_Store +0 -0
- data/publish.sh +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99635a266dfc1546b1a4a41750981273801ce18843b28ac988bc3f5c15574bb9
|
4
|
+
data.tar.gz: d57652a1afeeec572a6af5261d05a4873c2a2cf92ab2902a5da43674a62ad6ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 952daaa29c6f9cf001a3e355c311decc519eebe65197f38cdcf997990e6ca1cc6dacd21c999de6b48a7a14fd2d2d770c771f0030c1dacd70981dc9deab116d10
|
7
|
+
data.tar.gz: 18f3c998cb1a7a0ec875c30713fcc63fdbe4d61c762256e9175e96364c9eff4ca8f877a7db0c572e35c12eff4775ef33b097ee108fa78252491fa41db775c403
|
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)
|
@@ -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,9 +1,12 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# RDoc-Markdown
|
2
|
+
RDoc plugin to generate markdown documentation and search index backed by sqlite database.
|
3
|
+
|
4
|
+
## Motivation
|
5
|
+
I'm trying to depend less on software with GUI, instead using software that could be used through console. **Documentation in markdown format allows me to review documentation in console**, instead of browser or GUI software like DevDocs.
|
3
6
|
|
4
7
|
## Installation
|
5
8
|
|
6
|
-
Install
|
9
|
+
Install gem and add to application's Gemfile by executing:
|
7
10
|
|
8
11
|
$ bundle add rdoc-markdown
|
9
12
|
|
@@ -12,10 +15,13 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
12
15
|
$ gem install rdoc-markdown
|
13
16
|
|
14
17
|
## Usage
|
18
|
+
RDoc will auto-detect rdoc-markdown plugin if it was installed. You just need to instruct RDoc to produce markdown output instead of standard HTML through `format` parameter.
|
19
|
+
|
20
|
+
Run following command in directory with ruby source code:
|
15
21
|
|
16
22
|
`rdoc --format=markdown`
|
17
23
|
|
18
|
-
|
24
|
+
This will produce a tree of markdown documents and search index in `/doc` folder. Every class in library will have it's own markdown file.
|
19
25
|
|
20
26
|
## Development
|
21
27
|
Biggest issue is testing this locally, but that's not as hard to do these days.
|
@@ -34,22 +40,19 @@ or you can do the same, but through gemfile:
|
|
34
40
|
gem 'rdoc-markdown`, path: "../rdoc-markdown/`
|
35
41
|
```
|
36
42
|
|
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
43
|
## Testing
|
40
|
-
|
41
|
-
|
44
|
+
Following command should run entire testsuit:
|
42
45
|
```
|
43
46
|
rake test
|
44
47
|
```
|
45
|
-
|
48
|
+
Testing is not excessive, just verifies that basic functionality is operational.
|
46
49
|
## Release
|
47
50
|
```
|
48
51
|
gem build rdoc-markdown.gemspec
|
49
52
|
gem push rdoc-markdown-0.1.2.gem
|
50
53
|
```
|
51
54
|
|
52
|
-
There is `./publish.sh` script that does that. But it assumes, that you have [gum library](https://github.com/charmbracelet/gum) installed.
|
55
|
+
There is `./bin/publish.sh` script that does that. But it assumes, that you have [gum library](https://github.com/charmbracelet/gum) installed.
|
53
56
|
|
54
57
|
## Contributing
|
55
58
|
|
@@ -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
|
@@ -95,7 +94,7 @@ class RDoc::Generator::Markdown
|
|
95
94
|
# This class emits a search index for generated documentation as sqlite database
|
96
95
|
#
|
97
96
|
|
98
|
-
def emit_sqlite(name="index.db")
|
97
|
+
def emit_sqlite(name = "index.db")
|
99
98
|
db = Extralite::Database.new("#{output_dir}/#{name}")
|
100
99
|
|
101
100
|
db.execute <<-SQL
|
@@ -130,7 +129,7 @@ class RDoc::Generator::Markdown
|
|
130
129
|
result << {
|
131
130
|
name: "#{klass.full_name}.#{const.name}",
|
132
131
|
type: "Constant",
|
133
|
-
path: "#{turn_to_path(klass.full_name)}##{
|
132
|
+
path: "#{turn_to_path(klass.full_name)}##{const.name}"
|
134
133
|
}
|
135
134
|
end
|
136
135
|
|
@@ -150,19 +149,6 @@ class RDoc::Generator::Markdown
|
|
150
149
|
|
151
150
|
def emit_classfiles
|
152
151
|
@classes.each do |klass|
|
153
|
-
klass_methods = []
|
154
|
-
instance_methods = []
|
155
|
-
|
156
|
-
klass.method_list.each do |method|
|
157
|
-
next if method.visibility.to_s.eql?("private")
|
158
|
-
|
159
|
-
if method.type == "class"
|
160
|
-
klass_methods << method
|
161
|
-
else
|
162
|
-
instance_methods << method
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
152
|
template = ERB.new File.read(File.join(TEMPLATE_DIR, "classfile.md.erb"))
|
167
153
|
|
168
154
|
out_file = Pathname.new("#{output_dir}/#{turn_to_path klass.full_name}")
|
@@ -185,25 +171,21 @@ class RDoc::Generator::Markdown
|
|
185
171
|
# Converts HTML string into a Markdown string with some cleaning and improvements.
|
186
172
|
|
187
173
|
def markdownify(input)
|
188
|
-
md= ReverseMarkdown.convert input
|
174
|
+
md = ReverseMarkdown.convert input
|
189
175
|
|
190
176
|
# unintent multiline strings
|
191
177
|
md.unindent!
|
192
178
|
|
193
179
|
# Replace .html to .md extension in all markdown links
|
194
|
-
md
|
180
|
+
md.gsub(/\[(.+)\]\((.+).html(.*)\)/) do |_|
|
195
181
|
match = Regexp.last_match
|
196
182
|
|
197
183
|
"[#{match[1]}](#{match[2]}.md#{match[3]})"
|
198
184
|
end
|
199
|
-
|
200
|
-
# clean up things, to make it look neat.
|
201
|
-
|
202
|
-
md.gsub("[↑](#top)", "").lstrip
|
203
185
|
end
|
204
186
|
|
205
187
|
# Aliasing a shorter method name for use in templates
|
206
|
-
alias_method
|
188
|
+
alias_method :h, :markdownify
|
207
189
|
|
208
190
|
##
|
209
191
|
# Prepares for document generation, by creating required folders and initializing variables.
|
@@ -219,14 +201,4 @@ class RDoc::Generator::Markdown
|
|
219
201
|
|
220
202
|
@classes = @store.all_classes_and_modules.sort
|
221
203
|
end
|
222
|
-
|
223
|
-
##
|
224
|
-
# Return a list of the documented modules sorted by salience first, then
|
225
|
-
# by name.
|
226
|
-
|
227
|
-
def get_sorted_module_list classes
|
228
|
-
classes.select do |klass|
|
229
|
-
klass.display?
|
230
|
-
end.sort
|
231
|
-
end
|
232
204
|
end
|
@@ -1,23 +1,31 @@
|
|
1
|
-
#
|
1
|
+
# <%= klass.type %> <%= klass.full_name.strip %> [](#<%= klass.aref.strip %>) [](#top)
|
2
2
|
<%= h klass.description %>
|
3
|
-
<%
|
4
|
-
|
5
|
-
|
6
|
-
<% klass.constants.
|
7
|
-
|
8
|
-
<%
|
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? %>
|
7
|
+
## Constants
|
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? %>
|
9
14
|
## Attributes
|
10
|
-
<%
|
11
|
-
|
12
|
-
<%
|
13
|
-
<%
|
14
|
-
|
15
|
-
|
16
|
-
<%
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
15
|
+
<% attributes.each do |attr| %>
|
16
|
+
### <%= attr.name %>[<%= attr.rw %>] [](#<%= 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.1
|
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-
|
11
|
+
date: 2022-11-05 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
|
@@ -172,7 +158,6 @@ executables: []
|
|
172
158
|
extensions: []
|
173
159
|
extra_rdoc_files: []
|
174
160
|
files:
|
175
|
-
- ".DS_Store"
|
176
161
|
- ".editorconfig"
|
177
162
|
- ".standard.yml"
|
178
163
|
- CODE_OF_CONDUCT.md
|
@@ -181,15 +166,11 @@ files:
|
|
181
166
|
- LICENSE
|
182
167
|
- README.md
|
183
168
|
- Rakefile
|
184
|
-
- docs/example.rb
|
185
|
-
- lib/.DS_Store
|
186
169
|
- lib/markdown.rb
|
187
|
-
- lib/rdoc/.DS_Store
|
188
170
|
- lib/rdoc/discover.rb
|
189
171
|
- lib/rdoc/generator/markdown.rb
|
190
172
|
- lib/rdoc/markdown/version.rb
|
191
173
|
- lib/templates/classfile.md.erb
|
192
|
-
- publish.sh
|
193
174
|
- sig/rdoc/markdown.rbs
|
194
175
|
homepage: https://poshtui.com
|
195
176
|
licenses:
|
data/.DS_Store
DELETED
Binary file
|
data/docs/example.rb
DELETED
@@ -1,142 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# === RDoc::Generator::Markdown example.
|
3
|
-
#
|
4
|
-
# This example employs various RDoc features to demonstrate
|
5
|
-
# generator output.
|
6
|
-
#
|
7
|
-
# ---
|
8
|
-
#
|
9
|
-
# Links:
|
10
|
-
#
|
11
|
-
# 1. {Project Home Page}[https://github.com/skatkov/rdoc-markdown)
|
12
|
-
# 2. {RDoc Documentation}[http://ruby-doc.org/stdlib-2.0.0/libdoc/rdoc/rdoc/RDoc/Markup.html]
|
13
|
-
#
|
14
|
-
|
15
|
-
##
|
16
|
-
# A mixin for waterfowl creatures.
|
17
|
-
module Waterfowl
|
18
|
-
# Swimming helper.
|
19
|
-
def swim
|
20
|
-
puts 'swimming around'
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
##
|
25
|
-
# The base class for all birds.
|
26
|
-
class Bird
|
27
|
-
##
|
28
|
-
# Produce some noise.
|
29
|
-
#--
|
30
|
-
# FIXME: maybe extract this to a base class +Animal+?
|
31
|
-
#++
|
32
|
-
def speak # :yields: text
|
33
|
-
puts 'generic tweeting'
|
34
|
-
yield 'tweet'
|
35
|
-
yield 'tweet'
|
36
|
-
end
|
37
|
-
|
38
|
-
# Fly somewhere.
|
39
|
-
#
|
40
|
-
# Flying is the most critical feature of birds.
|
41
|
-
#
|
42
|
-
# :args: direction, velocity
|
43
|
-
#
|
44
|
-
# :call-seq:
|
45
|
-
# Bird.fly(symbol, number) -> bool
|
46
|
-
# Bird.fly(string, number) -> bool
|
47
|
-
#
|
48
|
-
# = Example
|
49
|
-
#
|
50
|
-
# fly(:south, 70)
|
51
|
-
def fly(direction, velocity)
|
52
|
-
_fly_impl(direction, velocity)
|
53
|
-
end
|
54
|
-
|
55
|
-
def _fly_impl(_direction, _velocity) # :nodoc:
|
56
|
-
puts "flying away: direction=#{direction}, velocity=#{velocity}"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
##
|
61
|
-
# A duck is a Waterfowl Bird.
|
62
|
-
#
|
63
|
-
# Features:
|
64
|
-
#
|
65
|
-
# bird::
|
66
|
-
#
|
67
|
-
# * speak
|
68
|
-
# * fly
|
69
|
-
#
|
70
|
-
# waterfowl::
|
71
|
-
#
|
72
|
-
# * swim
|
73
|
-
class Duck
|
74
|
-
extend Animal
|
75
|
-
include Waterfowl
|
76
|
-
|
77
|
-
# :section: Bird overrides
|
78
|
-
|
79
|
-
# Duck overrides generic implementation.
|
80
|
-
def speak
|
81
|
-
speech = quack
|
82
|
-
yield speech
|
83
|
-
end
|
84
|
-
|
85
|
-
# Implements quacking
|
86
|
-
def quack
|
87
|
-
'quack'
|
88
|
-
end
|
89
|
-
|
90
|
-
private :quack
|
91
|
-
|
92
|
-
# :section: Duck extensions
|
93
|
-
|
94
|
-
# True for domestic ducks.
|
95
|
-
attr_accessor :domestic
|
96
|
-
|
97
|
-
# True for rubber ducks.
|
98
|
-
attr_reader :rubber
|
99
|
-
|
100
|
-
MAX_VELOCITY = 130 # Maximum velocity for a flying duck.
|
101
|
-
|
102
|
-
##
|
103
|
-
# Global list of all rubber ducks.
|
104
|
-
#
|
105
|
-
# Use when in trouble.
|
106
|
-
@@rubber_ducks = []
|
107
|
-
|
108
|
-
# Returns list of all rubber ducks.
|
109
|
-
def self.rubber_ducks
|
110
|
-
@@rubber_ducks
|
111
|
-
end
|
112
|
-
|
113
|
-
# Creates a new duck.
|
114
|
-
def initialize(domestic, rubber)
|
115
|
-
@domestic = domestic
|
116
|
-
@rubber = rubber
|
117
|
-
@@rubber_ducks << self if rubber
|
118
|
-
end
|
119
|
-
|
120
|
-
# Checks if this duck is a useful one.
|
121
|
-
#
|
122
|
-
# :call-seq:
|
123
|
-
# Bird.useful? -> bool
|
124
|
-
def useful?
|
125
|
-
@domestic || @rubber
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
# Default velocity for a flying duck.
|
130
|
-
DEFAULT_DUCK_VELOCITY = 70
|
131
|
-
|
132
|
-
# Default rubber duck.
|
133
|
-
#
|
134
|
-
# *Note:*
|
135
|
-
# Global variables are evil, but rubber ducks are worth it.
|
136
|
-
$default_rubber_duck = Duck.new(false, true)
|
137
|
-
|
138
|
-
# Domestic rubber duck.
|
139
|
-
#
|
140
|
-
# *Note:*
|
141
|
-
# This is weird... Thus not making it global.
|
142
|
-
domestic_rubber_duck = Duck.new(true, true)
|
data/lib/.DS_Store
DELETED
Binary file
|
data/lib/rdoc/.DS_Store
DELETED
Binary file
|