rdoc-markdown 0.1.14 → 0.2

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
  SHA256:
3
- metadata.gz: 12c1ba51ac28269b904c171a33ced989e93a6ec55cdeb5b07cf1267bb73f288e
4
- data.tar.gz: 816fce30041fc92080f14dfe722e27261b9bc65fbec97b00a9646962a6daa0b6
3
+ metadata.gz: 761747d3a9b32015fca088a58b871d0dbd1ab62b6239d2a4e6f6b3065a0e655e
4
+ data.tar.gz: e8948dfc980ee3a316699579d254fcb43c8f43549c07fd67ea7d4232bf16ae58
5
5
  SHA512:
6
- metadata.gz: 47cae1695d164805c74056118cc2048594281e304fd73952a6e8a0602a89f360beae06f5a6cd01929bfb6b1d094716b59a68a748a9409f4544bb18df2cf8c6d5
7
- data.tar.gz: 544b83ef2a0f8dbccc7fbba8ef046f5fccd160ea0f030f6dba237ee6d061e4a13cae0c04fbd701d650993ec1d966f202ce948330101c9077d160bfdf4ef9c089
6
+ metadata.gz: 4b7cce412555f74e6bb4798cdc1fe03d304f694144608ba20c71e8ea77e4b1caa2d791001ee3b58824d740bc55fe5634f8174a4b54be33a64d12f971ce55da7f
7
+ data.tar.gz: efea582acb0a4012734c1cdd974987c52df2cac297ca4c773cf268e84f6af325ae95e9391a10c0f89bd31e25a990cd64f1c990ba02c35c5d2dc23573c12ed7e9
data/Gemfile.lock CHANGED
@@ -1,12 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rdoc-markdown (0.1.13)
4
+ rdoc-markdown (0.1.14)
5
5
  activesupport (~> 7.0)
6
6
  erb (~> 2.0)
7
7
  extralite-bundle (~> 1.0)
8
8
  rdoc (~> 6.0)
9
9
  reverse_markdown (~> 2.0)
10
+ unindent (~> 1.0)
10
11
 
11
12
  GEM
12
13
  remote: https://rubygems.org/
@@ -68,6 +69,7 @@ GEM
68
69
  tzinfo (2.0.5)
69
70
  concurrent-ruby (~> 1.0)
70
71
  unicode-display_width (2.3.0)
72
+ unindent (1.0)
71
73
 
72
74
  PLATFORMS
73
75
  arm64-darwin-21
@@ -7,10 +7,14 @@ require "erb"
7
7
  require "reverse_markdown"
8
8
  require 'extralite'
9
9
  require 'active_support/core_ext/string/inflections'
10
+ require 'unindent'
10
11
 
11
12
  class RDoc::Generator::Markdown
12
13
  RDoc::RDoc.add_generator self
13
14
 
15
+ ##
16
+ # Defines a constant for directory where templates could be found
17
+
14
18
  TEMPLATE_DIR = File.expand_path(
15
19
  File.join(File.dirname(__FILE__), "..", "..", "templates")
16
20
  )
@@ -43,6 +47,9 @@ class RDoc::Generator::Markdown
43
47
  # this alias is required for rdoc to work
44
48
  alias_method :file_dir, :class_dir
45
49
 
50
+ ##
51
+ # Initializer method for Rdoc::Generator::Markdown
52
+
46
53
  def initialize(store, options)
47
54
  @store = store
48
55
  @options = options
@@ -52,6 +59,9 @@ class RDoc::Generator::Markdown
52
59
  @classes = nil
53
60
  end
54
61
 
62
+ ##
63
+ # Generates markdown files and search index file
64
+
55
65
  def generate
56
66
  setup
57
67
 
@@ -73,6 +83,9 @@ class RDoc::Generator::Markdown
73
83
  attr_reader :options
74
84
  attr_reader :output_dir
75
85
 
86
+ ##
87
+ # This method is used to output debugging information in case rdoc is run with --debug parameter
88
+
76
89
  def debug(str = nil)
77
90
  if $DEBUG_RDOC
78
91
  puts "[rdoc-markdown] #{str}" if str
@@ -80,8 +93,12 @@ class RDoc::Generator::Markdown
80
93
  end
81
94
  end
82
95
 
83
- def emit_sqlite
84
- db = Extralite::Database.new("#{output_dir}/index.db")
96
+ ##
97
+ # This class emits a search index for generated documentation as sqlite database
98
+ #
99
+
100
+ def emit_sqlite(name="index.db")
101
+ db = Extralite::Database.new("#{output_dir}/#{name}")
85
102
 
86
103
  db.execute <<-SQL
87
104
  create table contentIndex (
@@ -159,16 +176,22 @@ class RDoc::Generator::Markdown
159
176
  end
160
177
  end
161
178
 
162
-
163
- private
179
+ ##
180
+ # Takes a class name and converts it into a Pathname
164
181
 
165
182
  def turn_to_path(class_name)
166
183
  "#{class_name.gsub("::", "/")}.md"
167
184
  end
168
185
 
186
+ ##
187
+ # Converts HTML string into a Markdown string with some cleaning and improvements.
188
+
169
189
  def markdownify(input)
170
190
  md= ReverseMarkdown.convert input, github_flavored: true
171
191
 
192
+ # unintent multiline strings
193
+ md.unindent!
194
+
172
195
  # Replace .html to .md extension in all markdown links
173
196
  md = md.gsub(/\[(.+)\]\((.+).html(.*)\)/) do |_|
174
197
  match = Regexp.last_match
@@ -181,8 +204,13 @@ class RDoc::Generator::Markdown
181
204
  md.gsub("[↑](#top)", "").lstrip
182
205
  end
183
206
 
207
+ # Aliasing a shorter method name for use in templates
184
208
  alias_method :h, :markdownify
185
209
 
210
+ ##
211
+ # Prepares for document generation, by creating required folders and initializing variables.
212
+ # Could be called multiple times.
213
+
186
214
  def setup
187
215
  return if instance_variable_defined?(:@output_dir)
188
216
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rdoc
4
4
  module Markdown
5
- VERSION = "0.1.14"
5
+ VERSION = "0.2"
6
6
  end
7
7
  end
@@ -3,22 +3,22 @@
3
3
  <% unless klass.constants.empty? %>
4
4
  ## Constants
5
5
  ***
6
- <% klass.constants.sort_by { |x| x.name }.each do |const| %> **<%= const.name %>**
6
+ <% klass.constants.sort_by { |x| x.name }.each do |const| %> **<%= const.name %>** [[⚓]](#const-<%= ActiveSupport::Inflector.parameterize const.name%>)
7
7
  <%= h const.description %>
8
8
  <% end %><% end %>
9
9
  <% unless klass.attributes.empty? %>
10
10
  ## Attributes
11
11
  <% klass.attributes.sort_by { |x| x.name }.each do |attr| %>
12
- **[<%= attr.rw %>]** <%= attr.name %>
12
+ **[<%= attr.rw %>]** <%= attr.name %> [[⚓]](#attr-<%= ActiveSupport::Inflector.parameterize attr.name %>)
13
13
  <% end %><% end %>
14
14
  <% unless klass_methods.empty? %>
15
15
  ## Public Class Methods
16
16
  ***
17
- <% klass_methods.each do |method| %>### <%= method.name %><%= method.params %>
17
+ <% klass_methods.each do |method| %>### <%= method.name %><%= method.params %> [[⚓]](#meth-<%= ActiveSupport::Inflector.parameterize method.name %>)
18
18
 
19
19
  <%= h method.description %><% end %><% end %>
20
20
  <% unless instance_methods.empty? %>
21
21
  ## Public Instance Methods
22
- <% instance_methods.each do |method| %>### <%= method.name %><%= method.params %>
22
+ <% instance_methods.each do |method| %>### <%= method.name %><%= method.params %> [[⚓]](#meth-<%= ActiveSupport::Inflector.parameterize method.name %>)
23
23
 
24
24
  <%= h method.description %><% end %><% end %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdoc-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislav (Stas) Katkov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-20 00:00:00.000000000 Z
11
+ date: 2022-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '7.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: unindent
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: minitest
85
99
  requirement: !ruby/object:Gem::Requirement