rdoc-markdown 0.1.7 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/lib/rdoc/generator/markdown.rb +20 -26
- data/lib/rdoc/markdown/version.rb +1 -1
- data/lib/templates/classfile.md.erb +4 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d08a05e31cacde411267507404584cf8b83a715e2001290e84f4b0ae3494106
|
4
|
+
data.tar.gz: cf679c7121051ed3c3dfe7615e9ef559d2ec8b023e2b1efd9666d9caa2de5ae7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cbbf2f3f6fc21e199d426ed08d71c734f09daf155bb5bc9b37a65662094c735047f76cfe8d84e3ee92a3b998e21e3cbbf643b6f0702ab14a67467773b028ead
|
7
|
+
data.tar.gz: 4a9e28997fd4cda40d0510f29f9bc04a78a30140e5631dd0be4a38b7bfc9ae4a65d3fbae14de8d4d1853cac2c60b8ddf4a399653a171c757b605397368e193fc
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
!!! This is just experimental gem
|
2
|
-
|
3
1
|
# Rdoc::Markdown
|
4
2
|
This gem is focused on spitting readable markdown files based on rdoc documentation. It should also come with sqlite database as an index (but this is so far only in plans).
|
5
3
|
|
4
|
+
It is still actively in development and while works as proof of concept, still has some quirks here and there.
|
5
|
+
|
6
6
|
## Installation
|
7
7
|
|
8
8
|
Install the gem and add to the application's Gemfile by executing:
|
@@ -20,7 +20,7 @@ First thing to do, is to install a gem
|
|
20
20
|
|
21
21
|
Then proceed to directory where you want to generate documentation:
|
22
22
|
|
23
|
-
`rdoc --format=markdown
|
23
|
+
`rdoc --format=markdown`
|
24
24
|
|
25
25
|
Don't forget to append `--debug` to have a bit more information in case thing fail (and they will probably do, because this entire thing is experimental).
|
26
26
|
|
@@ -48,8 +48,8 @@ gem push rdoc-markdown-0.1.2.gem
|
|
48
48
|
```
|
49
49
|
## Contributing
|
50
50
|
|
51
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
51
|
+
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).
|
52
52
|
|
53
53
|
## Code of Conduct
|
54
54
|
|
55
|
-
Everyone interacting in the Rdoc::Markdown project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
55
|
+
Everyone interacting in the Rdoc::Markdown project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/skatkov/rdoc-markdown/blob/master/CODE_OF_CONDUCT.md).
|
@@ -6,9 +6,6 @@ require "pathname"
|
|
6
6
|
require "erb"
|
7
7
|
require "reverse_markdown"
|
8
8
|
|
9
|
-
# Markdown generator.
|
10
|
-
# Registers command line options and generates markdown files
|
11
|
-
# RDoc documentation and options.
|
12
9
|
class RDoc::Generator::Markdown
|
13
10
|
RDoc::RDoc.add_generator self
|
14
11
|
|
@@ -33,21 +30,6 @@ class RDoc::Generator::Markdown
|
|
33
30
|
|
34
31
|
attr_reader :classes
|
35
32
|
|
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
33
|
##
|
52
34
|
# Directory where generated class HTML files live relative to the output
|
53
35
|
# dir.
|
@@ -66,9 +48,6 @@ class RDoc::Generator::Markdown
|
|
66
48
|
@base_dir = Pathname.pwd.expand_path
|
67
49
|
|
68
50
|
@classes = nil
|
69
|
-
@files = nil
|
70
|
-
@methods = nil
|
71
|
-
@modsort = nil
|
72
51
|
end
|
73
52
|
|
74
53
|
def generate
|
@@ -112,7 +91,7 @@ class RDoc::Generator::Markdown
|
|
112
91
|
|
113
92
|
template = ERB.new File.read(File.join(TEMPLATE_DIR, "classfile.md.erb"))
|
114
93
|
|
115
|
-
out_file = Pathname.new("#{output_dir}/#{klass.full_name}.md")
|
94
|
+
out_file = Pathname.new("#{output_dir}/#{turn_to_path klass.full_name}.md")
|
116
95
|
out_file.dirname.mkpath
|
117
96
|
|
118
97
|
result = template.result(binding)
|
@@ -124,10 +103,27 @@ class RDoc::Generator::Markdown
|
|
124
103
|
|
125
104
|
private
|
126
105
|
|
127
|
-
def
|
128
|
-
|
106
|
+
def turn_to_path(class_name)
|
107
|
+
class_name.gsub("::", "/")
|
129
108
|
end
|
130
109
|
|
110
|
+
def markdownify(input)
|
111
|
+
md= ReverseMarkdown.convert input, github_flavored: true
|
112
|
+
|
113
|
+
# Replace .html to .md extension in all markdown links
|
114
|
+
md = md.gsub(/\[(.+)\]\((.+).html(.*)\)/) do |_|
|
115
|
+
match = Regexp.last_match
|
116
|
+
|
117
|
+
"[#{match[1]}](#{match[2]}.md#{match[3]})"
|
118
|
+
end
|
119
|
+
|
120
|
+
# clean up things, to make it look neat.
|
121
|
+
|
122
|
+
md.gsub("[↑](#top)", "").lstrip
|
123
|
+
end
|
124
|
+
|
125
|
+
alias_method :h, :markdownify
|
126
|
+
|
131
127
|
def setup
|
132
128
|
return if instance_variable_defined?(:@output_dir)
|
133
129
|
|
@@ -136,8 +132,6 @@ class RDoc::Generator::Markdown
|
|
136
132
|
return unless @store
|
137
133
|
|
138
134
|
@classes = @store.all_classes_and_modules.sort
|
139
|
-
@files = @store.all_files.sort
|
140
|
-
@methods = @classes.map(&:method_list).flatten.sort
|
141
135
|
@modsort = get_sorted_module_list @classes
|
142
136
|
end
|
143
137
|
|
@@ -1,27 +1,24 @@
|
|
1
|
-
# <% if klass.type == 'class' %><%= klass.type.capitalize %>: **<%= klass.full_name
|
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
|
***
|
6
|
-
|
7
6
|
<% klass.constants.sort_by { |x| x.name }.each do |const| %> **<%= const.name %>**
|
8
7
|
<%= h const.description %>
|
9
8
|
<% end %><% end %>
|
10
9
|
<% unless klass.attributes.empty? %>
|
11
10
|
## Attributes
|
12
|
-
|
13
11
|
<% klass.attributes.sort_by { |x| x.name }.each do |attr| %>
|
14
12
|
**[<%= attr.rw %>]** <%= attr.name %>
|
15
13
|
<% end %><% end %>
|
16
14
|
<% unless klass_methods.empty? %>
|
17
15
|
## Public Class Methods
|
18
16
|
***
|
19
|
-
|
20
|
-
<% klass_methods.each do |method| %> ### <%= method.name %><%= method.params %>
|
17
|
+
<% klass_methods.each do |method| %>### <%= method.name %><%= method.params %>
|
21
18
|
|
22
19
|
<%= h method.description %><% end %><% end %>
|
23
20
|
<% unless instance_methods.empty? %>
|
24
21
|
## Public Instance Methods
|
25
|
-
<% instance_methods.each do |method|
|
22
|
+
<% instance_methods.each do |method| %>### <%= method.name %><%= method.params %>
|
26
23
|
|
27
24
|
<%= h method.description %><% end %><% end %>
|