markdown_ruby_documentation 0.17.0 → 0.18.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 +4 -4
- data/README.md +1 -0
- data/lib/markdown_ruby_documentation/template_parser.rb +12 -4
- data/lib/markdown_ruby_documentation/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5484a31074ad298be30096b5729d76e4a2a7c611
|
4
|
+
data.tar.gz: 53dc2af956510bf4bf3cab3becf41e06f3fbba33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbf4b4d5c3e3d4ec5716106a3ce681b750e6955ba689abba45c22dff162e1e5a0004000115cb03e2abc205e5df2aa03bf67bc9c404e6a11082e92b767c729056
|
7
|
+
data.tar.gz: 3a52f13a3efca8829128addabb9f7a3edc519a4ab93cc3d417d9a4833be9354ef7068b14421b622aee06e939f3f0ecb050854a2a819711d05d4d0efd4439ae1c
|
data/README.md
CHANGED
@@ -119,6 +119,7 @@ Converts case statements and if statements to bulleted markdown
|
|
119
119
|
* constants_with_name_and_value, options: proc(replacement, match, opt={})
|
120
120
|
* remove_memoized_vars, options: proc(replacement, match)
|
121
121
|
* rescue_format, options: proc(replacement, match)
|
122
|
+
* boolean_blocks, options: proc(replacement, match)
|
122
123
|
|
123
124
|
|
124
125
|
#### `format_link`
|
@@ -124,6 +124,7 @@ module MarkdownRubyDocumentation
|
|
124
124
|
:ruby_case_statement_to_md,
|
125
125
|
:ruby_operators_to_english,
|
126
126
|
:nil_check_readable,
|
127
|
+
:boolean_blocks,
|
127
128
|
:question_mark_method_format,
|
128
129
|
:symbol_to_proc,
|
129
130
|
:methods_as_local_links,
|
@@ -131,7 +132,7 @@ module MarkdownRubyDocumentation
|
|
131
132
|
:constants_with_name_and_value,
|
132
133
|
:remove_memoized_vars,
|
133
134
|
:comment_format,
|
134
|
-
:rescue_format
|
135
|
+
:rescue_format,
|
135
136
|
]
|
136
137
|
|
137
138
|
def ruby_to_markdown(*args)
|
@@ -159,6 +160,13 @@ module MarkdownRubyDocumentation
|
|
159
160
|
ruby_source
|
160
161
|
end
|
161
162
|
|
163
|
+
def boolean_blocks(source_code=print_method_source, proc: false)
|
164
|
+
gsub_replacement(source_code, {
|
165
|
+
/(.*)\.any\?\s*do\s\|.*\|/ => "Are there any \\1 where\n",
|
166
|
+
/(.*)\.all\?\s*do\s\|.*\|/ => "Do all \\1 have\n",
|
167
|
+
}, proc: proc)
|
168
|
+
end
|
169
|
+
|
162
170
|
def rescue_format(source_code=print_method_source, proc: false)
|
163
171
|
gsub_replacement(source_code, {
|
164
172
|
/=>\s.*/ => "",
|
@@ -376,7 +384,7 @@ module MarkdownRubyDocumentation
|
|
376
384
|
method_to_class: {},
|
377
385
|
proc: false)
|
378
386
|
ruby_source.gsub(MethodLink::RUBY_METHOD_REGEX) do |match|
|
379
|
-
if is_a_method_on_ruby_class?(match)
|
387
|
+
if is_a_method_on_ruby_class?(match, method_to_class[match.to_sym] || ruby_class)
|
380
388
|
replacement = MethodLink.new(match: match,
|
381
389
|
ruby_class: ruby_class,
|
382
390
|
call_on_title: call_on_title,
|
@@ -488,8 +496,8 @@ module MarkdownRubyDocumentation
|
|
488
496
|
source_code = source_code.gsub(/[a-z_?!0-9]+:/, &block)
|
489
497
|
end
|
490
498
|
|
491
|
-
def is_a_method_on_ruby_class?(method)
|
492
|
-
[*
|
499
|
+
def is_a_method_on_ruby_class?(method, klass=ruby_class)
|
500
|
+
[*klass.public_instance_methods, *klass.private_instance_methods].include?(remove_quotes(method).to_sym)
|
493
501
|
end
|
494
502
|
|
495
503
|
def remove_quotes(string)
|