markdown_ruby_documentation 0.4.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e4deabd18fa1afabe6abc4c3a9375341807ef22
4
- data.tar.gz: db358d7299865548126c931f9756f4fff5534c5a
3
+ metadata.gz: 00ade506279b6b5d39ffa42bb4fc50b61d255222
4
+ data.tar.gz: c8426d9d8b851257d312552e13b6c84198b972b5
5
5
  SHA512:
6
- metadata.gz: 1918c0b06612f8d663c2af76471ced722d1b3310f565fe3c4fdc611e8eb73417d58d19e9686238f10a691ef3a545bc871bf09ea250076562ac4d1adbadb24d46
7
- data.tar.gz: 06248e8a5a0cd48486d3e7fd290f412c8ad0be54523d9537474e55d9784da06c75298612c0166c6bb5cc15f361e1255512678f7cd4bbaf83f76ed181d6c001f4
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
- def self.run(
8
- subjects:,
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
- self.output_object = output_object
14
- self.load_path = load_path
15
- erb_methods_class = Class.new
16
- erb_methods_class.extend TemplateParser::CommentMacros
17
- erb_methods_class.extend erb_methods
18
- TemplateParser::CommentMacros.include erb_methods
19
- left_padding = subjects.map(&:name).group_by(&:size).max.first
20
- progressbar = ProgressBar.create(title: "Compiling Markdown".ljust(left_padding), total: subjects.count+ 1)
21
- pages = subjects.map do |subject|
22
- progressbar.title = subject.name.ljust(left_padding)
23
- Page.new(subject: subject,
24
- output_object: output_object,
25
- erb_methods_class: erb_methods_class,
26
- load_path: load_path).call.tap { progressbar.increment }
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
- return_value = pages.each_with_object({}) do |page, hash|
30
- name_parts = page.subject.name.split("::")
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
- class << self
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 = (subject.instance_methods(true) - Object.instance_methods(true)).concat(subject.private_instance_methods(true) - Object.private_instance_methods(true)) - native_instance_methods
83
- klass_m = subject.methods(false).concat(subject.private_methods(false)) - Object.methods
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) }
@@ -1,3 +1,3 @@
1
1
  module MarkdownRubyDocumentation
2
- VERSION = "0.4.4"
2
+ VERSION = "0.5.0"
3
3
  end
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.4
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-05-18 00:00:00.000000000 Z
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: