markdown_ruby_documentation 0.20.2 → 0.21.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: a6dfcca51c06892aecf2b21ed0ebc2990b5ecf9a
4
- data.tar.gz: f33ca187bb9c49faf504ff50b21f118183b6a8d3
3
+ metadata.gz: 94cf45206406b64001109a7c6d3ab7ae25558135
4
+ data.tar.gz: 45986afae8718ada4c88ca45f6aa8c3985c505dd
5
5
  SHA512:
6
- metadata.gz: e1b8645d4b2178ea543083bd72dfba5390de5e48e0331949bf188c5d014d9fa848fec25949d61da79a38379d370da3e9b79775157e87ba8ca3a2aab593e96634
7
- data.tar.gz: f213dc69ceb6592eda622c7b2560e6179ef61faa444fcb3baffe421ce595d3e4be3a55fc0d49df6cb661f586cd20a81dcf4b98b862d16937239c77bae506da3f
6
+ metadata.gz: 18f90760acfe91488781e2a1a06d4b7f4b1deb83c7839bd81d6be1e91626ff8a24470dde8d59e883d6fb4de42ec1e47de011cec15114808eb1ac374ff4c6f94d
7
+ data.tar.gz: d2c99a00987c550646e368e1e84399a860c3bf416b816c865496c7a903bf6d1f1f5d596c8c944e55ae2ed2a70c28b198aa15950d23c9b227dd80d266fb3a4fb4
data/README.md CHANGED
@@ -1,6 +1,12 @@
1
1
  # MarkdownRubyDocumentation
2
+ Documentation DSL that provides method level comments and links or imports to other comments.
3
+ Comments can be written in MarkDown format and the current method can be transformed from Ruby code into a MarkDown readable format.
4
+ Static instance, class methods, and constants can be called and used inside of ERB tags.
5
+ All defined areas are generated into markdown file per class.
2
6
 
3
- Gem provides the ability to use markdown and ruby ERB with some helper methods inside of comments. The comment area then can be generated into a markdown file.
7
+ ## Why should you use this?
8
+
9
+ Allows creating business or technical documentation that can stays automatically in sync with Ruby Logic and available data.
4
10
 
5
11
  ## Installation
6
12
 
@@ -27,7 +33,7 @@ class RubyClassToBeInspected
27
33
  #=mark_doc
28
34
  # **I am Documentation**
29
35
  # <%= print_method_source "#i_am_a_documented_method" %>
30
- # ^`MY_VALUE`
36
+ # <%= MY_VALUE %>
31
37
  #=mark_end
32
38
  def i_am_a_documented_method
33
39
  "Hello"
@@ -53,17 +59,22 @@ MarkdownRubyDocumentation::Generate.run(
53
59
 
54
60
  **I am Documentation**
55
61
  "Hello"
56
- [MY_VALUE](/ruby_class_to_be_inspected#my_value)
62
+ 10
57
63
 
58
64
  ```
59
65
 
60
66
  ### ERB Methods
61
67
 
68
+ ### String Method Reference (method)
69
+ * Call an instance method in the current context with `"#method_name"` (Limitations: methods cannot take any arguments or depend on any uninitialized state, they may call other methods that follow this same requirements.)
70
+ * Call an class method in the current context with `".method_name"`
71
+ * Call an instance method from another class `"OtherClass#method_name"`
72
+
62
73
  #### `print_method_source(method)`
63
74
  The source of a method block returned as text.
64
75
 
65
76
  #### `eval_method(method)`
66
- The result of evaluating a method.
77
+ The result of evaluating a method.
67
78
 
68
79
  #### `print_mark_doc_from(method)`
69
80
  Prints out the mark doc from another method.
@@ -79,7 +90,7 @@ Creates a url to the file on GitHub based on the current sha or it defaults to m
79
90
 
80
91
  ##### `link_to_markdown` or `link_to`(klass_or_path, title: String)
81
92
  @param [Class, String, Pathname] klass_or_path
82
- 1. String or Class representing a method reference
93
+ 1. String or Class representing a method reference ie. MyObject#call, MyObject.name
83
94
  2. Pathname representing the full path of the file location a method is defined
84
95
  @param [String] title is the link display value
85
96
  @return [String, Symbol] Creates link to a given generated markdown file or returns :non_project_location message.
@@ -1,3 +1,3 @@
1
1
  module MarkdownRubyDocumentation
2
- VERSION = "0.20.2"
2
+ VERSION = "0.21.0"
3
3
  end
@@ -6,24 +6,33 @@ module MarkdownRubyDocumentation
6
6
  def initialize(dir:, skip_if_blank: false, relative_dir:)
7
7
  @dir = dir
8
8
  @skip_if_blank = skip_if_blank
9
- @relative_dir = relative_dir
9
+ @relative_dir = relative_dir
10
10
  end
11
11
 
12
12
  def call(name:, text:)
13
13
  return if skip_save?(text, name)
14
14
  name = name.gsub(dir, "").underscore
15
- path = File.join(dir, name)
16
- FileUtils.mkdir_p(path.split("/").tap { |p| p.pop }.join("/"))
17
- File.open("#{path}.md", "w").write(text)
15
+ file = "#{name}.md"
16
+ path = File.join(dir, file)
17
+
18
+ return if file_exists_with?(text, path)
19
+ write_file(path, text)
18
20
  end
19
21
 
20
22
  private
21
23
 
22
- def skip_save?(text, name)
24
+ def file_exists_with?(text, path)
25
+ File.exist?(path) && Digest::MD5.new.update(File.open(path).read) == Digest::MD5.new.update(text)
26
+ end
27
+
28
+ def write_file(path, text)
29
+ FileUtils.mkdir_p(path.split("/").tap { |p| p.pop }.join("/"))
30
+ File.open(path, "w").write(text)
31
+ end
32
+
33
+ def skip_save?(text, _name)
23
34
  if skip_if_blank
24
- if Array(text.split("\n")[2..-1]).all? { |line| line.blank? }
25
- return true
26
- end
35
+ return true if Array(text.split("\n")[2..-1]).all?(&:blank?)
27
36
  end
28
37
  end
29
38
  end
@@ -9,8 +9,11 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Dustin Zeisler"]
10
10
  spec.email = ["dustin@zeisler.net"]
11
11
 
12
- spec.summary = %q{Gem provides the ability to use markdown and ruby ERB with some helper methods inside of comments}
13
- spec.description = %q{Gem provides the ability to use markdown and ruby ERB with some helper methods inside of comments. The comment area then can be generated into a markdown file.}
12
+ spec.summary = %q{Allows creating business or technical documentation that can stays automatically in sync with Ruby Logic and available data.}
13
+ spec.description = %q{Documentation DSL that provides method level comments and links or imports to other comments.
14
+ Comments can be written in MarkDown format and the current method can be transformed from Ruby code into a MarkDown readable format.
15
+ Static instance, class methods, and constants can be called and used inside of ERB tags.
16
+ All defined areas are generated into markdown file per class.}
14
17
  spec.homepage = "https://github.com/zeisler/markdown_ruby_documentation"
15
18
  spec.license = "MIT"
16
19
 
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.20.2
4
+ version: 0.21.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: 2017-05-25 00:00:00.000000000 Z
11
+ date: 2017-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: method_source
@@ -94,9 +94,11 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.4'
97
- description: Gem provides the ability to use markdown and ruby ERB with some helper
98
- methods inside of comments. The comment area then can be generated into a markdown
99
- file.
97
+ description: |-
98
+ Documentation DSL that provides method level comments and links or imports to other comments.
99
+ Comments can be written in MarkDown format and the current method can be transformed from Ruby code into a MarkDown readable format.
100
+ Static instance, class methods, and constants can be called and used inside of ERB tags.
101
+ All defined areas are generated into markdown file per class.
100
102
  email:
101
103
  - dustin@zeisler.net
102
104
  executables: []
@@ -161,6 +163,6 @@ rubyforge_project:
161
163
  rubygems_version: 2.5.1
162
164
  signing_key:
163
165
  specification_version: 4
164
- summary: Gem provides the ability to use markdown and ruby ERB with some helper methods
165
- inside of comments
166
+ summary: Allows creating business or technical documentation that can stays automatically
167
+ in sync with Ruby Logic and available data.
166
168
  test_files: []