yard-markdown 0.2.0 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9c561fb4adb1a813dee7cc4f1793ecee708627115f85aab396933822e4886cb0
4
- data.tar.gz: 17e36c633008becd1b8ead5af645e58182d5be5959736cfb34280f4c7a077848
3
+ metadata.gz: 336637063b30cdb36819afce2e0380f467c1763ebbb022b006317488edebe134
4
+ data.tar.gz: 73692c82e184b6e3b7259af0ba1ce74fea209b71a56ed089c611ac0035415bbd
5
5
  SHA512:
6
- metadata.gz: 1c472b473610259d5067deceacbdc08ba3e2f68b00e07947d9b0aa55657623d28fccaf65237f213fc01f03b1f5d4674094fdfbe825f1829d17dadcc6c6efec69
7
- data.tar.gz: abd879a66a9334c633120f9a1ee486cffa42dd4d08b184fe321bbea27a6f002a626b9adb76c46efc5637a3d489e3f365bdbea6b75f9901b3a22f8694bd73fbcc
6
+ metadata.gz: e9b0c05b3cfef30f77040ea8542091dd99231cece58f912079c0e356042bfe99fbfd4aad80e509bdad0390f07cc23d0a4be133db8d4c67e33981556cea87bbfd
7
+ data.tar.gz: c32c66c335f301dcaec541401b7d1276267aa5054b29574f70d8d1697680dddae6d649b044ce934df88ee4372efbbe2cb45e9eb6570aea6b0a465f77c91e57a4
data/.streerc ADDED
@@ -0,0 +1,2 @@
1
+ --print-width=100
2
+ --plugins=plugin/trailing_comma,disable_ternary
data/README.md CHANGED
@@ -1,25 +1,32 @@
1
1
  # Yard::Markdown
2
2
 
3
- Yard theme plugin that generates markdown documentation for gems
3
+ Yard plugin to generate markdown documentation
4
4
 
5
5
  ## Goals:
6
6
  - Compatible with Github Flavored Markdown
7
- - Mimick yard html layout in markdown format as much as possible
7
+ - Mimick yard html layout where it makes sense to maintain familiarity
8
8
  - Produce .csv index file alonside markdown documentation to act as file index
9
+ - Include markdown files that are already present in source code.
9
10
 
10
11
  ## Usage
11
- Add these lines:
12
+ Yard doesn't load plugin by default, so you need to load plugin through `~/.yard/config`:
13
+
14
+ ```yaml
15
+ !!!yaml
16
+ load_plugins: true
17
+ autoload_plugins:
18
+ - markdown
19
+ ```
20
+
21
+ Install a plugin
12
22
  ```
13
- gem 'yard-markdown'
23
+ gem install yard-markdown
14
24
  ```
15
- And run `bundle install`
16
25
 
17
- Run yardoc with `--format=markdown --plugin=markdown` parameters.
26
+ Run `yardoc --format=markdown` to generate markdown documentation.
18
27
 
19
28
  ## Backstory
20
- Successor to rdoc-mardown gem that was authored by me. So there is a lot of similarities between two - [example](https://github.com/skatkov/rdoc-markdown/tree/main/example).
21
-
22
- This gem is used by documentation reviewing tool called [POSH TUI](https://poshtui.com)
29
+ This is a successor to [rdoc-mardown gem](https://github.com/skatkov/rdoc-markdown/tree/main/example) with small differences in implementation. This gem was written to power API documentation browser CLI app for ruby developers called [POSH TUI](https://poshtui.com).
23
30
 
24
31
  ## Testing
25
32
  Unit tests can't really test this gem properly. So it's semi-manual process of making changes and reviewing output.
data/Rakefile CHANGED
@@ -9,6 +9,8 @@ Rake::TestTask.new(:test) do |t|
9
9
  t.test_files = FileList["test/**/test_*.rb"]
10
10
  end
11
11
 
12
- require "standard/rake"
12
+ require "syntax_tree/rake_tasks"
13
+ SyntaxTree::Rake::CheckTask.new
14
+ SyntaxTree::Rake::WriteTask.new
13
15
 
14
- task default: %i[test standard]
16
+ task default: %i[test stree:write]
data/example/Bird.md CHANGED
@@ -4,18 +4,17 @@
4
4
  | **Inherits:** | Object |
5
5
  | **Defined in:** | example.rb |
6
6
 
7
-
8
7
  The base class for all birds.
9
-
10
8
  # Constants
11
- ## DEFAULT_DUCK_VELOCITY = [](#constant-DEFAULT_DUCK_VELOCITY)
12
- (70) Default velocity for a flying duck.
13
-
9
+ ## DEFAULT_DUCK_VELOCITY [](#constant-DEFAULT_DUCK_VELOCITY)
10
+ Default velocity for a flying duck.
11
+ ## DEFAULT_SPEED [](#constant-DEFAULT_SPEED)
12
+ Maximum speed for a swimming duck.
14
13
 
15
14
  # Public Instance Methods
16
- ## _fly_impl(_direction , _velocity ) [](#method-i-_fly_impl)
15
+ ## _fly_impl(_direction, _velocity) [](#method-i-_fly_impl)
17
16
  :nodoc:
18
- ## fly(direction , velocity ) [](#method-i-fly)
17
+ ## fly(direction, velocity) [](#method-i-fly)
19
18
  Fly somewhere.
20
19
 
21
20
  Flying is the most critical feature of birds.
data/example/Duck.md CHANGED
@@ -6,7 +6,6 @@
6
6
  | **Includes:** | Waterfowl |
7
7
  | **Defined in:** | example.rb |
8
8
 
9
-
10
9
  A duck is a Waterfowl Bird.
11
10
 
12
11
  Features:
@@ -19,14 +18,14 @@ Features:
19
18
  waterfowl::
20
19
 
21
20
  * swim
22
-
23
21
  # Constants
24
- ## DEFAULT_DUCK_VELOCITY = [](#constant-DEFAULT_DUCK_VELOCITY)
25
- (70) Default velocity for a flying duck.
26
-
22
+ ## DEFAULT_DUCK_VELOCITY [](#constant-DEFAULT_DUCK_VELOCITY)
23
+ Default velocity for a flying duck.
24
+ ## DEFAULT_SPEED [](#constant-DEFAULT_SPEED)
25
+ Maximum speed for a swimming duck.
27
26
 
28
27
  # Public Instance Methods
29
- ## initialize(domestic , rubber ) [](#method-i-initialize)
28
+ ## initialize(domestic, rubber) [](#method-i-initialize)
30
29
  Creates a new duck.
31
30
  ## speak() [](#method-i-speak)
32
31
  Duck overrides generic implementation.
data/example/Waterfowl.md CHANGED
@@ -3,13 +3,12 @@
3
3
  | -----------------: | :----- |
4
4
  | **Defined in:** | example.rb |
5
5
 
6
-
7
6
  A mixin for waterfowl creatures.
8
-
9
7
  # Constants
10
- ## DEFAULT_DUCK_VELOCITY = [](#constant-DEFAULT_DUCK_VELOCITY)
11
- (70) Default velocity for a flying duck.
12
-
8
+ ## DEFAULT_DUCK_VELOCITY [](#constant-DEFAULT_DUCK_VELOCITY)
9
+ Default velocity for a flying duck.
10
+ ## DEFAULT_SPEED [](#constant-DEFAULT_SPEED)
11
+ Maximum speed for a swimming duck.
13
12
 
14
13
  # Public Instance Methods
15
14
  ## swim() [](#method-i-swim)
data/example/index.csv CHANGED
@@ -1,14 +1,17 @@
1
1
  name,type,path
2
2
  Waterfowl,Module,Waterfowl.md
3
3
  DEFAULT_DUCK_VELOCITY,Constant,Waterfowl.md#constant-DEFAULT_DUCK_VELOCITY
4
+ DEFAULT_SPEED,Constant,Waterfowl.md#constant-DEFAULT_SPEED
4
5
  swim,Method,Waterfowl.md#method-i-swim
5
6
  Bird,Class,Bird.md
6
7
  DEFAULT_DUCK_VELOCITY,Constant,Bird.md#constant-DEFAULT_DUCK_VELOCITY
8
+ DEFAULT_SPEED,Constant,Bird.md#constant-DEFAULT_SPEED
7
9
  _fly_impl,Method,Bird.md#method-i-_fly_impl
8
10
  fly,Method,Bird.md#method-i-fly
9
11
  speak,Method,Bird.md#method-i-speak
10
12
  Duck,Class,Duck.md
11
13
  DEFAULT_DUCK_VELOCITY,Constant,Duck.md#constant-DEFAULT_DUCK_VELOCITY
14
+ DEFAULT_SPEED,Constant,Duck.md#constant-DEFAULT_SPEED
12
15
  initialize,Method,Duck.md#method-i-initialize
13
16
  speak,Method,Duck.md#method-i-speak
14
17
  swim,Method,Duck.md#method-i-swim
data/example.rb CHANGED
@@ -131,6 +131,8 @@ end
131
131
 
132
132
  # Default velocity for a flying duck.
133
133
  DEFAULT_DUCK_VELOCITY = 70
134
+ DEFAULT_SPEED = 10 # Maximum speed for a swimming duck.
135
+
134
136
 
135
137
  # Default rubber duck.
136
138
  #
data/lib/yard-markdown.rb CHANGED
@@ -7,4 +7,4 @@ module YARD
7
7
  end
8
8
  end
9
9
 
10
- YARD::Templates::Engine.register_template_path File.dirname(__FILE__) + '/../templates'
10
+ YARD::Templates::Engine.register_template_path File.dirname(__FILE__) + "/../templates"
@@ -3,11 +3,11 @@
3
3
  # https://github.com/lsegal/yard/blob/2d197a381c5d4cc5c55b2c60fff992b31c986361/docs/CodeObjects.md
4
4
 
5
5
  require "erb"
6
+ require "csv"
6
7
 
7
- def init
8
- # here I need to copy README.md if there is one.
9
- # I also need to write index.md files
8
+ include Helpers::ModuleHelper
10
9
 
10
+ def init
11
11
  options.objects = objects = run_verifier(options.objects)
12
12
 
13
13
  options.delete(:objects)
@@ -21,9 +21,7 @@ def init
21
21
  next if object.name == :root
22
22
 
23
23
  begin
24
- Templates::Engine.with_serializer(object, options.serializer) do
25
- serialize(object)
26
- end
24
+ Templates::Engine.with_serializer(object, options.serializer) { serialize(object) }
27
25
  rescue => e
28
26
  path = options.serializer.serialized_path(object)
29
27
  log.error "Exception occurred while generating '#{path}'"
@@ -34,45 +32,68 @@ def init
34
32
  serialize_index(objects)
35
33
  end
36
34
 
37
-
38
- require 'csv'
39
-
40
35
  def serialize_index(objects)
41
36
  filepath = "#{options.serializer.basepath}/index.csv"
42
37
 
43
- CSV.open(filepath, 'wb') do |csv|
38
+ CSV.open(filepath, "wb") do |csv|
44
39
  csv << %w[name type path]
45
40
 
46
41
  objects.each do |object|
47
42
  next if object.name == :root
48
43
 
49
44
  if object.type == :class
50
- csv << [object.name, 'Class', options.serializer.serialized_path(object)]
45
+ csv << [object.name, "Class", options.serializer.serialized_path(object)]
51
46
  elsif object.type == :module
52
- csv << [object.name, 'Module', options.serializer.serialized_path(object)]
47
+ csv << [object.name, "Module", options.serializer.serialized_path(object)]
53
48
  end
54
49
 
55
50
  if constant_listing.size.positive?
56
- constant_listing.each { |cnst| csv << [cnst.name(false), 'Constant', (options.serializer.serialized_path(object) + "#" +aref(cnst))] }
51
+ constant_listing.each do |cnst|
52
+ csv << [
53
+ cnst.name(false),
54
+ "Constant",
55
+ (options.serializer.serialized_path(object) + "#" + aref(cnst)),
56
+ ]
57
+ end
57
58
  end
58
59
 
59
60
  if (insmeths = public_instance_methods(object)).size > 0
60
- insmeths.each { |item| csv << [item.name(false), 'Method', options.serializer.serialized_path(object) + "#" + aref(item)] }
61
+ insmeths.each do |item|
62
+ csv << [
63
+ item.name(false),
64
+ "Method",
65
+ options.serializer.serialized_path(object) + "#" + aref(item),
66
+ ]
67
+ end
61
68
  end
62
69
 
63
70
  if (pubmeths = public_class_methods(object)).size > 0
64
- pubmeths.each { |item| csv << [item.name(false), 'Method', options.serializer.serialized_path(object) + '#' + aref(item)]}
71
+ pubmeths.each do |item|
72
+ csv << [
73
+ item.name(false),
74
+ "Method",
75
+ options.serializer.serialized_path(object) + "#" + aref(item),
76
+ ]
77
+ end
65
78
  end
66
79
 
67
80
  if (attrs = attr_listing(object)).size > 0
68
- attrs.each { |item| csv << [item.name(false), 'Attribute', options.serializer.serialized_path(object) + "#" + aref(item)]}
81
+ attrs.each do |item|
82
+ csv << [
83
+ item.name(false),
84
+ "Attribute",
85
+ options.serializer.serialized_path(object) + "#" + aref(item),
86
+ ]
87
+ end
69
88
  end
70
89
  end
71
90
  end
72
91
  end
73
92
 
74
93
  def serialize(object)
75
- template = ERB.new('# <%= format_object_title object %>
94
+ template =
95
+ ERB.new(
96
+ '# <%= format_object_title object %>
76
97
  | | |
77
98
  | -----------------: | :----- |
78
99
  <% if CodeObjects::ClassObject === object && object.superclass %>
@@ -87,25 +108,23 @@ def serialize(object)
87
108
  | **Defined in:** | <%= object.file ? object.file : "(unknown)" %> |
88
109
  <% end %>
89
110
 
90
-
91
111
  <%= object.docstring %>
92
112
 
93
-
94
113
  <% if constant_listing.size > 0 %>
95
114
  <% groups(constant_listing, "Constants") do |list, name| %>
96
115
  # <%= name %>
97
116
  <% list.each do |cnst| %>
98
- ## <%= cnst.name %> = [](#<%=aref(cnst)%>)
99
- (<%= cnst.value %>) <%= cnst.docstring %>
117
+ ## <%= cnst.name %> [](#<%=aref(cnst)%>)
118
+ <%= cnst.docstring %>
119
+
100
120
  <% end %>
101
121
  <% end %>
102
-
103
122
  <% end %>
104
123
 
105
124
  <% if (insmeths = public_instance_methods(object)).size > 0 %>
106
125
  # Public Instance Methods
107
126
  <% insmeths.each do |item| %>
108
- ## <%= item.name(false) %>(<%= item.parameters.map {|p| p.join(" ") }.join(", ")%>) [](#<%=aref(item)%>)
127
+ ## <%= item.name(false) %>(<%= item.parameters.map {|p| p.join("") }.join(", ")%>) [](#<%=aref(item)%>)
109
128
  <%= item.docstring %>
110
129
 
111
130
  <% end %>
@@ -127,7 +146,9 @@ def serialize(object)
127
146
 
128
147
  <% end %>
129
148
  <% end %>
130
- '.gsub(/^ /, ''), trim_mode: '%<>')
149
+ '.gsub(/^ /, ""),
150
+ trim_mode: "%<>",
151
+ )
131
152
 
132
153
  template.result(binding)
133
154
  end
@@ -150,10 +171,11 @@ def constant_listing
150
171
  @constants
151
172
  end
152
173
 
153
- include Helpers::ModuleHelper
154
-
155
174
  def public_method_list(object)
156
- prune_method_listing(object.meths(inherited: false, visibility: [:public]), included: false).sort_by { |m| m.name.to_s }
175
+ prune_method_listing(
176
+ object.meths(inherited: false, visibility: [:public]),
177
+ included: false,
178
+ ).sort_by { |m| m.name.to_s }
157
179
  end
158
180
 
159
181
  def public_class_methods(object)
@@ -166,18 +188,19 @@ end
166
188
 
167
189
  def attr_listing(object)
168
190
  @attrs = []
169
- object.inheritance_tree(true).each do |superclass|
170
- next if superclass.is_a?(CodeObjects::Proxy)
171
- next if !options.embed_mixins.empty? &&
172
- !options.embed_mixins_match?(superclass)
173
- [:class, :instance].each do |scope|
174
- superclass.attributes[scope].each do |_name, rw|
175
- attr = prune_method_listing([rw[:read], rw[:write]].compact, false).first
176
- @attrs << attr if attr
191
+ object
192
+ .inheritance_tree(true)
193
+ .each do |superclass|
194
+ next if superclass.is_a?(CodeObjects::Proxy)
195
+ next if !options.embed_mixins.empty? && !options.embed_mixins_match?(superclass)
196
+ %i[class instance].each do |scope|
197
+ superclass.attributes[scope].each do |_name, rw|
198
+ attr = prune_method_listing([rw[:read], rw[:write]].compact, false).first
199
+ @attrs << attr if attr
200
+ end
177
201
  end
202
+ break if options.embed_mixins.empty?
178
203
  end
179
- break if options.embed_mixins.empty?
180
- end
181
204
  sort_listing @attrs
182
205
  end
183
206
 
@@ -193,7 +216,7 @@ def generate_method_list
193
216
  end
194
217
 
195
218
  def sort_listing(list)
196
- list.sort_by {|o| [o.scope.to_s, o.name.to_s.downcase] }
219
+ list.sort_by { |o| [o.scope.to_s, o.name.to_s.downcase] }
197
220
  end
198
221
 
199
222
  def groups(list, type = "Method")
@@ -208,13 +231,7 @@ def groups(list, type = "Method")
208
231
  else
209
232
  others = []
210
233
  group_data = {}
211
- list.each do |itm|
212
- if itm.group
213
- (group_data[itm.group] ||= []) << itm
214
- else
215
- others << itm
216
- end
217
- end
234
+ list.each { |itm| itm.group ? (group_data[itm.group] ||= []) << itm : others << itm }
218
235
  group_data.each { |group, items| yield(items, group) unless items.empty? }
219
236
  end
220
237
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.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: 2023-12-05 00:00:00.000000000 Z
11
+ date: 2024-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard
@@ -32,7 +32,7 @@ extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
34
  - ".editorconfig"
35
- - ".standard.yml"
35
+ - ".streerc"
36
36
  - ".yardopts"
37
37
  - LICENSE.txt
38
38
  - README.md
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  - !ruby/object:Gem::Version
67
67
  version: '0'
68
68
  requirements: []
69
- rubygems_version: 3.4.22
69
+ rubygems_version: 3.5.4
70
70
  signing_key:
71
71
  specification_version: 4
72
72
  summary: yard plugin to generate markdown documentation
data/.standard.yml DELETED
@@ -1,3 +0,0 @@
1
- # For available configuration options, see:
2
- # https://github.com/testdouble/standard
3
- ruby_version: 2.6