markdown_ruby_documentation 0.4.4 → 0.5.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00ade506279b6b5d39ffa42bb4fc50b61d255222
|
4
|
+
data.tar.gz: c8426d9d8b851257d312552e13b6c84198b972b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1473d3b33e26b1b26b818281d8d9c15112aa63840bad2c0e1b56de1413ddad1166c3f954acf2b41f1ab402d865c5bb6616943ad1609b1df69c2cfc0106b896ac
|
7
|
+
data.tar.gz: c41fc56eee17895ec7ee5f156ab3481b0ea6557aea8ddec81f55116fe67de990f099e684f2f1a5010f7b661c285a61b46a478e5b89a078c30dab190b71d2cc76
|
@@ -4,42 +4,57 @@ module MarkdownRubyDocumentation
|
|
4
4
|
# @param [Module] erb_methods must contain #link_to_markdown and contain any additional methods for comment ERB
|
5
5
|
# @param [Proc] output_object given name: and text: for use in saving the the files.
|
6
6
|
# @param [String] load_path
|
7
|
-
|
8
|
-
|
7
|
+
# @param [Hash] parallel_config - example { in_threads: 7 } - defaults to 2
|
8
|
+
class << self
|
9
|
+
def run(
|
10
|
+
subjects:,
|
9
11
|
erb_methods: DefaultErbMethods,
|
10
12
|
output_object:,
|
11
|
-
load_path
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
13
|
+
load_path:,
|
14
|
+
parallel_config: {})
|
15
|
+
self.output_object = output_object
|
16
|
+
self.load_path = load_path
|
17
|
+
erb_methods_class = Class.new
|
18
|
+
erb_methods_class.extend TemplateParser::CommentMacros
|
19
|
+
erb_methods_class.extend erb_methods
|
20
|
+
TemplateParser::CommentMacros.include erb_methods
|
21
|
+
left_padding(subjects)
|
22
|
+
progressbar(subjects)
|
23
|
+
progressbar.title = "Compiling Markdown".ljust(left_padding)
|
24
|
+
batches = subjects.each_slice(parallel_config.fetch(:in_threads, 2))
|
25
|
+
threads = []
|
26
|
+
batches.each do |batch|
|
27
|
+
threads << Thread.new(batch) do |(_batch)|
|
28
|
+
Array[_batch].flatten.map do |subject|
|
29
|
+
progressbar.title = subject.name.ljust(left_padding)
|
30
|
+
Page.new(subject: subject,
|
31
|
+
output_object: output_object,
|
32
|
+
erb_methods_class: erb_methods_class,
|
33
|
+
load_path: load_path).call.tap { progressbar.increment }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
pages = threads.flat_map(&:value)
|
38
|
+
return_value = pages.each_with_object({}) do |page, hash|
|
39
|
+
name_parts = page.subject.name.split("::")
|
40
|
+
name = name_parts.pop
|
41
|
+
namespace = name_parts.join("::")
|
42
|
+
hash[namespace] ||= {}
|
43
|
+
hash[namespace].merge!({ name => page })
|
44
|
+
hash
|
45
|
+
end
|
46
|
+
progressbar.title = "Markdown Documentation Compilation Complete".ljust(left_padding)
|
47
|
+
progressbar.finish
|
48
|
+
return_value
|
27
49
|
end
|
28
50
|
|
29
|
-
|
30
|
-
|
31
|
-
name = name_parts.pop
|
32
|
-
namespace = name_parts.join("::")
|
33
|
-
hash[namespace] ||= {}
|
34
|
-
hash[namespace].merge!({ name => page })
|
35
|
-
hash
|
51
|
+
def progressbar(subjects=nil)
|
52
|
+
@progressbar ||= ProgressBar.create(title: "Compiling Markdown".ljust(left_padding(subjects)), total: subjects.count+ 1)
|
36
53
|
end
|
37
|
-
progressbar.title = "Markdown Documentation Compilation Complete".ljust(left_padding)
|
38
|
-
progressbar.finish
|
39
|
-
return_value
|
40
|
-
end
|
41
54
|
|
42
|
-
|
55
|
+
def left_padding(subjects=nil)
|
56
|
+
@left_padding ||= subjects.map(&:name).group_by(&:size).max.first
|
57
|
+
end
|
43
58
|
attr_accessor :load_path, :output_object
|
44
59
|
end
|
45
60
|
|
@@ -79,8 +94,8 @@ module MarkdownRubyDocumentation
|
|
79
94
|
|
80
95
|
def all_instance_and_class_methods(methods, subject)
|
81
96
|
native_instance_methods = (subject.instance_methods(false) - Object.instance_methods(false)).concat(subject.private_instance_methods(false) - Object.private_instance_methods(false))
|
82
|
-
super_instance_methods
|
83
|
-
|
97
|
+
super_instance_methods = (subject.instance_methods(true) - Object.instance_methods(true)).concat(subject.private_instance_methods(true) - Object.private_instance_methods(true)) - native_instance_methods
|
98
|
+
klass_m = subject.methods(false).concat(subject.private_methods(false)) - Object.methods
|
84
99
|
methods.concat super_instance_methods.reverse.map { |method| InstanceMethod.new("#{subject.name}##{method}", context: subject, visibility: :super) }
|
85
100
|
methods.concat native_instance_methods.map { |method| InstanceMethod.new("#{subject.name}##{method}", context: subject, visibility: :native) }
|
86
101
|
methods.concat klass_m.map { |method| ClassMethod.new("#{subject.name}.#{method}", context: subject) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markdown_ruby_documentation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin Zeisler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: method_source
|
@@ -163,3 +163,4 @@ specification_version: 4
|
|
163
163
|
summary: Gem provides the ability to use markdown and ruby ERB with some helper methods
|
164
164
|
inside of comments
|
165
165
|
test_files: []
|
166
|
+
has_rdoc:
|