rdoc-markdown 0.1.14 → 0.2.1

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: 16494339df3b522fae317e9010c0a9ee8cae1a7f4452595c8fde01e238421c64
4
+ data.tar.gz: 1dec9b05ccdea281811213800b2301a4f89097dcaacbf72ac59fa7c85aeff676
5
5
  SHA512:
6
- metadata.gz: 47cae1695d164805c74056118cc2048594281e304fd73952a6e8a0602a89f360beae06f5a6cd01929bfb6b1d094716b59a68a748a9409f4544bb18df2cf8c6d5
7
- data.tar.gz: 544b83ef2a0f8dbccc7fbba8ef046f5fccd160ea0f030f6dba237ee6d061e4a13cae0c04fbd701d650993ec1d966f202ce948330101c9077d160bfdf4ef9c089
6
+ metadata.gz: 30b4a879efd549f01f627558c390b34b05aece87ce14fe46293770e342c90fdaf176457b50fad52f215de6aa91b7477607601530d8874f60869570e9990b043d
7
+ data.tar.gz: 76947d62302a58b3ceeb41d78be86dcbe7d6032fa41579e9287567aecda5bf23c7271bfb453c8125d9dd6d6b934bd5de996637145a2ba377f068f8198909c82a
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.2.1)
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/
@@ -55,7 +56,7 @@ GEM
55
56
  rubocop-ast (>= 1.20.1, < 2.0)
56
57
  ruby-progressbar (~> 1.7)
57
58
  unicode-display_width (>= 1.4.0, < 3.0)
58
- rubocop-ast (1.22.0)
59
+ rubocop-ast (1.23.0)
59
60
  parser (>= 3.1.1.0)
60
61
  rubocop-performance (1.14.3)
61
62
  rubocop (>= 1.7.0, < 2.0)
@@ -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
data/README.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # Rdoc::Markdown
2
- This gem is focused on spitting readable markdown files based on rdoc documentation. It should also come with sqlite database as an index (but this is so far only in plans).
3
-
4
- It is still actively in development and while works as proof of concept, still has some quirks here and there.
2
+ Rdoc Generator plugin to generate markdown documentation and search index as sqlite database that goes along with it.
5
3
 
6
4
  ## Installation
7
5
 
@@ -14,15 +12,10 @@ If bundler is not being used to manage dependencies, install the gem by executin
14
12
  $ gem install rdoc-markdown
15
13
 
16
14
  ## Usage
17
- First thing to do, is to install a gem
18
-
19
- `gem install rdoc-markdown`
20
-
21
- Then proceed to directory where you want to generate documentation:
22
15
 
23
16
  `rdoc --format=markdown`
24
17
 
25
- Don't forget to append `--debug` to have a bit more information in case thing fail (and they will probably do, because this entire thing is experimental).
18
+ No additional parameters are currently available, but that may change.
26
19
 
27
20
  ## Development
28
21
  Biggest issue is testing this locally, but that's not as hard to do these days.
@@ -41,11 +34,23 @@ or you can do the same, but through gemfile:
41
34
  gem 'rdoc-markdown`, path: "../rdoc-markdown/`
42
35
  ```
43
36
 
37
+ I have scripted entire process in [rm-reload.sh script](https://github.com/skatkov/gum/blob/master/rm-reload.sh). But it assumes, that you have [gum library](https://github.com/charmbracelet/gum) installed.
38
+
39
+ ## Testing
40
+ Testing is not excessive, just verifies that basic functionality is operational. Following command should run entire testsuit:
41
+
42
+ ```
43
+ rake test
44
+ ```
45
+
44
46
  ## Release
45
47
  ```
46
48
  gem build rdoc-markdown.gemspec
47
49
  gem push rdoc-markdown-0.1.2.gem
48
50
  ```
51
+
52
+ There is `./publish.sh` script that does that. But it assumes, that you have [gum library](https://github.com/charmbracelet/gum) installed.
53
+
49
54
  ## Contributing
50
55
 
51
56
  Bug reports and pull requests are welcome on GitHub at https://github.com/skatkov/rdoc-markdown. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/skatkov/rdoc-markdown/blob/master/CODE_OF_CONDUCT.md).
@@ -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
  )
@@ -28,7 +32,7 @@ class RDoc::Generator::Markdown
28
32
 
29
33
  ##
30
34
  # Classes and modules to be used by this generator, not necessarily
31
- # displayed. See also #modsort
35
+ # displayed.
32
36
 
33
37
  attr_reader :classes
34
38
 
@@ -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,12 +59,13 @@ class RDoc::Generator::Markdown
52
59
  @classes = nil
53
60
  end
54
61
 
55
- def generate
56
- setup
62
+ ##
63
+ # Generates markdown files and search index file
57
64
 
58
- debug("Create directory #{@output_dir}")
65
+ def generate
66
+ debug("Setting things up #{@output_dir}")
59
67
 
60
- output_dir.mkpath
68
+ setup
61
69
 
62
70
  debug("Generate documentation in #{@output_dir}")
63
71
 
@@ -73,6 +81,9 @@ class RDoc::Generator::Markdown
73
81
  attr_reader :options
74
82
  attr_reader :output_dir
75
83
 
84
+ ##
85
+ # This method is used to output debugging information in case rdoc is run with --debug parameter
86
+
76
87
  def debug(str = nil)
77
88
  if $DEBUG_RDOC
78
89
  puts "[rdoc-markdown] #{str}" if str
@@ -80,8 +91,12 @@ class RDoc::Generator::Markdown
80
91
  end
81
92
  end
82
93
 
83
- def emit_sqlite
84
- db = Extralite::Database.new("#{output_dir}/index.db")
94
+ ##
95
+ # This class emits a search index for generated documentation as sqlite database
96
+ #
97
+
98
+ def emit_sqlite(name="index.db")
99
+ db = Extralite::Database.new("#{output_dir}/#{name}")
85
100
 
86
101
  db.execute <<-SQL
87
102
  create table contentIndex (
@@ -107,7 +122,7 @@ class RDoc::Generator::Markdown
107
122
  result << {
108
123
  name: "#{klass.full_name}.#{method.name}",
109
124
  type: "Method",
110
- path: "#{turn_to_path(klass.full_name)}#meth-#{ActiveSupport::Inflector.parameterize method.name}"
125
+ path: "#{turn_to_path(klass.full_name)}##{method.aref}"
111
126
  }
112
127
  end
113
128
 
@@ -115,7 +130,7 @@ class RDoc::Generator::Markdown
115
130
  result << {
116
131
  name: "#{klass.full_name}.#{const.name}",
117
132
  type: "Constant",
118
- path: "#{turn_to_path(klass.full_name)}#const-#{ActiveSupport::Inflector.parameterize const.name}"
133
+ path: "#{turn_to_path(klass.full_name)}##{ActiveSupport::Inflector.parameterize const.name}"
119
134
  }
120
135
  end
121
136
 
@@ -123,7 +138,7 @@ class RDoc::Generator::Markdown
123
138
  result << {
124
139
  name: "#{klass.full_name}.#{attr.name}",
125
140
  type: "Attribute",
126
- path: "#{turn_to_path(klass.full_name)}#attr-#{ActiveSupport::Inflector.parameterize attr.name}"
141
+ path: "#{turn_to_path(klass.full_name)}##{attr.aref}"
127
142
  }
128
143
  end
129
144
  end
@@ -159,16 +174,22 @@ class RDoc::Generator::Markdown
159
174
  end
160
175
  end
161
176
 
162
-
163
- private
177
+ ##
178
+ # Takes a class name and converts it into a Pathname
164
179
 
165
180
  def turn_to_path(class_name)
166
181
  "#{class_name.gsub("::", "/")}.md"
167
182
  end
168
183
 
184
+ ##
185
+ # Converts HTML string into a Markdown string with some cleaning and improvements.
186
+
169
187
  def markdownify(input)
170
188
  md= ReverseMarkdown.convert input, github_flavored: true
171
189
 
190
+ # unintent multiline strings
191
+ md.unindent!
192
+
172
193
  # Replace .html to .md extension in all markdown links
173
194
  md = md.gsub(/\[(.+)\]\((.+).html(.*)\)/) do |_|
174
195
  match = Regexp.last_match
@@ -181,17 +202,22 @@ class RDoc::Generator::Markdown
181
202
  md.gsub("[↑](#top)", "").lstrip
182
203
  end
183
204
 
205
+ # Aliasing a shorter method name for use in templates
184
206
  alias_method :h, :markdownify
185
207
 
208
+ ##
209
+ # Prepares for document generation, by creating required folders and initializing variables.
210
+ # Could be called multiple times.
211
+
186
212
  def setup
187
213
  return if instance_variable_defined?(:@output_dir)
188
214
 
189
215
  @output_dir = Pathname.new(@options.op_dir).expand_path(@base_dir)
216
+ @output_dir.mkpath
190
217
 
191
218
  return unless @store
192
219
 
193
220
  @classes = @store.all_classes_and_modules.sort
194
- @modsort = get_sorted_module_list @classes
195
221
  end
196
222
 
197
223
  ##
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rdoc
4
4
  module Markdown
5
- VERSION = "0.1.14"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
@@ -1,24 +1,23 @@
1
1
  # <% if klass.type == 'class' %><%= klass.type.capitalize %>: **<%= klass.full_name %>**<% if klass.superclass %> < <% end %><% unless String === klass.superclass %><%= klass.superclass&.name %> <% else %> <%= klass.superclass %> <% end %> <% else %> <%= klass.type.capitalize %>: <%= klass&.name %> <% end %>
2
- <% if klass.description && !klass.description.empty? %><%= h klass.description %><% end %>
2
+ <%= h klass.description %>
3
3
  <% unless klass.constants.empty? %>
4
- ## Constants
5
- ***
6
- <% klass.constants.sort_by { |x| x.name }.each do |const| %> **<%= const.name %>**
7
- <%= h const.description %>
4
+ | Constants | Description |
5
+ | ------------- | ------------- |
6
+ <% klass.constants.sort_by { |x| x.name }.each do |const| %> |**[<%= const.name %>](#<%= ActiveSupport::Inflector.parameterize const.name%>)** | <%= h const.description %> |
8
7
  <% end %><% end %>
9
8
  <% unless klass.attributes.empty? %>
10
9
  ## Attributes
11
10
  <% klass.attributes.sort_by { |x| x.name }.each do |attr| %>
12
- **[<%= attr.rw %>]** <%= attr.name %>
11
+ [[**<%= attr.rw %>**] <%= attr.name %>](#<%= attr.aref %>)
13
12
  <% end %><% end %>
14
13
  <% unless klass_methods.empty? %>
15
14
  ## Public Class Methods
16
15
  ***
17
- <% klass_methods.each do |method| %>### <%= method.name %><%= method.params %>
16
+ <% klass_methods.each do |method| %>### [<%= method.name %><%= method.params %>](#<%= method.aref %>)
18
17
 
19
18
  <%= h method.description %><% end %><% end %>
20
19
  <% unless instance_methods.empty? %>
21
20
  ## Public Instance Methods
22
- <% instance_methods.each do |method| %>### <%= method.name %><%= method.params %>
21
+ <% instance_methods.each do |method| %>### [<%= method.name %><%= method.params %>](#<%= method.aref %>)
23
22
 
24
23
  <%= 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.1
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-23 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
@@ -150,8 +164,8 @@ dependencies:
150
164
  - - "~>"
151
165
  - !ruby/object:Gem::Version
152
166
  version: '2.0'
153
- description: rdoc generator that produces markdown files and sqlite database with
154
- index of all file
167
+ description: RDoc plugin to generate markdown documentation and search index as sqlite
168
+ database for entire content.
155
169
  email:
156
170
  - github@skatkov.com
157
171
  executables: []
@@ -202,5 +216,5 @@ requirements: []
202
216
  rubygems_version: 3.1.6
203
217
  signing_key:
204
218
  specification_version: 4
205
- summary: rdoc generator that produces markdown files
219
+ summary: RDoc plugin to generate markdown documentation
206
220
  test_files: []