yard-markdown 0.7.0 → 0.7.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.
@@ -1,9 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'csv'
4
-
5
- include Helpers::ModuleHelper
3
+ require "csv"
6
4
 
5
+ include YARD::Templates::Helpers::ModuleHelper
7
6
  include YARD::Markdown::ArefHelper
8
7
  include YARD::Markdown::ObjectListingHelper
9
8
 
@@ -16,11 +15,11 @@ def init
16
15
  options.delete(:objects)
17
16
  options.delete(:files)
18
17
 
19
- options.serializer.extension = 'md'
18
+ options.serializer.extension = "md"
20
19
 
21
20
  objects.each do |object|
22
21
  Templates::Engine.with_serializer(object, options.serializer) { serialize(object) }
23
- rescue StandardError => e
22
+ rescue => e
24
23
  path = options.serializer.serialized_path(object)
25
24
  log.error "Exception occurred while generating '#{path}'"
26
25
  log.backtrace(e)
@@ -34,7 +33,7 @@ end
34
33
  # @param object [YARD::CodeObjects::NamespaceObject] Object whose page will be serialized.
35
34
  # @return [String] Rendered markdown for the object.
36
35
  def serialize(object)
37
- T('module').run(options.merge(object: object))
36
+ T("module").run(options.merge(object: object))
38
37
  end
39
38
 
40
39
  # Writes the CSV search index for all rendered objects.
@@ -44,58 +43,32 @@ end
44
43
  def serialize_index(objects)
45
44
  filepath = "#{options.serializer.basepath}/index.csv"
46
45
 
47
- CSV.open(filepath, 'wb') do |csv|
46
+ CSV.open(filepath, "wb") do |csv|
48
47
  csv << %w[name type path]
49
48
 
50
49
  objects.each do |object|
51
50
  next if object.name == :root
52
51
 
53
52
  if object.type == :class
54
- csv << [object.path, 'Class', options.serializer.serialized_path(object)]
53
+ csv << [object.path, "Class", options.serializer.serialized_path(object)]
55
54
  elsif object.type == :module
56
- csv << [object.path, 'Module', options.serializer.serialized_path(object)]
57
- end
58
-
59
- constants = constant_listing(object)
60
- if constants.size.positive?
61
- constants.each do |cnst|
62
- csv << [
63
- "#{object.path}.#{cnst.name(false)}",
64
- 'Constant',
65
- (options.serializer.serialized_path(object) + '#' + aref(cnst))
66
- ]
67
- end
55
+ csv << [object.path, "Module", options.serializer.serialized_path(object)]
68
56
  end
69
57
 
70
- if (insmeths = public_instance_methods(object)).size > 0
71
- insmeths.each do |item|
58
+ [
59
+ ["Constant", constant_listing(object)],
60
+ ["Method", public_instance_methods(object)],
61
+ ["Method", public_class_methods(object)],
62
+ ["Attribute", attr_listing(object)]
63
+ ].each do |type, items|
64
+ items.each do |item|
72
65
  csv << [
73
66
  "#{object.path}.#{item.name(false)}",
74
- 'Method',
75
- options.serializer.serialized_path(object) + '#' + aref(item)
67
+ type,
68
+ options.serializer.serialized_path(object) + "#" + aref(item)
76
69
  ]
77
70
  end
78
71
  end
79
-
80
- if (pubmeths = public_class_methods(object)).size > 0
81
- pubmeths.each do |item|
82
- csv << [
83
- "#{object.path}.#{item.name(false)}",
84
- 'Method',
85
- options.serializer.serialized_path(object) + '#' + aref(item)
86
- ]
87
- end
88
- end
89
-
90
- next unless (attrs = attr_listing(object)).size > 0
91
-
92
- attrs.each do |item|
93
- csv << [
94
- "#{object.path}.#{item.name(false)}",
95
- 'Attribute',
96
- options.serializer.serialized_path(object) + '#' + aref(item)
97
- ]
98
- end
99
72
  end
100
73
  end
101
74
  end
@@ -1,11 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'pathname'
4
- require 'rdoc'
5
-
6
- include Helpers::ModuleHelper
7
- include YARD::Markdown::AnchorComponentHelper
8
- include YARD::Markdown::ArefHelper
3
+ include YARD::Templates::Helpers::ModuleHelper
9
4
  include YARD::Markdown::CollectionRenderingHelper
10
5
  include YARD::Markdown::DocumentationHelper
11
6
  include YARD::Markdown::HeadingHelper
@@ -21,13 +16,13 @@ include YARD::Markdown::TagFormattingHelper
21
16
  # @return [void]
22
17
  def init
23
18
  sections :header,
24
- :relationships,
25
- :docstring_section,
26
- :tags_section,
27
- :constants_section,
28
- :attributes_section,
29
- :public_class_methods_section,
30
- :public_instance_methods_section
19
+ :relationships,
20
+ :docstring_section,
21
+ :tags_section,
22
+ :constants_section,
23
+ :attributes_section,
24
+ :public_class_methods_section,
25
+ :public_instance_methods_section
31
26
  end
32
27
 
33
28
  # Renders the template and normalizes markdown for top-level page output.
@@ -41,21 +36,11 @@ end
41
36
  # @return [String] Rendered markdown output.
42
37
  def run(opts = nil, sects = sections, start_at = 0, break_first = false, &block)
43
38
  output = super
44
- return output unless top_level_render?(sects, start_at, break_first)
39
+ return output unless !break_first && start_at.zero? && sects == sections
45
40
 
46
41
  finalize_markdown(output, options.serializer.serialized_path(object))
47
42
  end
48
43
 
49
- # Returns whether this invocation is rendering the full top-level page.
50
- #
51
- # @param sects [Array<Symbol>] Section names requested for rendering.
52
- # @param start_at [Integer] Starting index within `sects`.
53
- # @param break_first [Boolean] Whether rendering stops after the first section.
54
- # @return [Boolean] True when the whole page is being rendered in one pass.
55
- def top_level_render?(sects, start_at, break_first)
56
- !break_first && start_at.zero? && sects == sections
57
- end
58
-
59
44
  # Renders the page heading for the current object.
60
45
  #
61
46
  # @return [String] Markdown heading section.
@@ -89,7 +74,7 @@ end
89
74
  # @return [String] Markdown constants section, or an empty string.
90
75
  def constants_section
91
76
  constants = constant_listing(object).reject { |item| hidden_object?(item) }
92
- return '' unless constants.any?
77
+ return "" unless constants.any?
93
78
 
94
79
  render_section_content(render_constants(constants, Array(object.groups)))
95
80
  end
@@ -99,7 +84,7 @@ end
99
84
  # @return [String] Markdown attributes section, or an empty string.
100
85
  def attributes_section
101
86
  attrs = attr_listing(object).reject { |item| hidden_object?(item) }
102
- return '' unless attrs.any?
87
+ return "" unless attrs.any?
103
88
 
104
89
  render_section_content(render_attributes(attrs, Array(object.groups)))
105
90
  end
@@ -109,9 +94,9 @@ end
109
94
  # @return [String] Markdown public class methods section, or an empty string.
110
95
  def public_class_methods_section
111
96
  methods = public_class_methods(object)
112
- return '' unless methods.any?
97
+ return "" unless methods.any?
113
98
 
114
- render_section_content(render_methods('Public Class Methods', methods, Array(object.groups)))
99
+ render_section_content(render_methods("Public Class Methods", methods, Array(object.groups)))
115
100
  end
116
101
 
117
102
  # Renders the public instance methods section when methods are present.
@@ -119,7 +104,7 @@ end
119
104
  # @return [String] Markdown public instance methods section, or an empty string.
120
105
  def public_instance_methods_section
121
106
  methods = public_instance_methods(object)
122
- return '' unless methods.any?
107
+ return "" unless methods.any?
123
108
 
124
- render_section_content(render_methods('Public Instance Methods', methods, Array(object.groups)))
109
+ render_section_content(render_methods("Public Instance Methods", methods, Array(object.groups)))
125
110
  end
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislav (Stas) Katkov
8
- bindir: exe
8
+ bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
@@ -58,28 +58,10 @@ executables: []
58
58
  extensions: []
59
59
  extra_rdoc_files: []
60
60
  files:
61
- - ".editorconfig"
62
- - ".streerc"
63
- - ".yard-lint.yml"
64
- - ".yardopts"
65
- - AGENTS.md
66
61
  - CHANGELOG.md
67
62
  - LICENSE.txt
68
63
  - README.md
69
- - Rakefile
70
- - config/mutant.yml
71
- - example/rdoc/Bird.md
72
- - example/rdoc/Duck.md
73
- - example/rdoc/Waterfowl.md
74
- - example/rdoc/index.csv
75
- - example/yard/Aquatic.md
76
- - example/yard/Fish.md
77
- - example/yard/Salmon.md
78
- - example/yard/index.csv
79
- - example_rdoc.rb
80
- - example_yard.rb
81
64
  - lib/yard-markdown.rb
82
- - lib/yard/markdown/anchor_component_helper.rb
83
65
  - lib/yard/markdown/aref_helper.rb
84
66
  - lib/yard/markdown/collection_rendering_helper.rb
85
67
  - lib/yard/markdown/documentation_helper.rb
@@ -90,7 +72,6 @@ files:
90
72
  - lib/yard/markdown/relationship_section_helper.rb
91
73
  - lib/yard/markdown/section_assembly_helper.rb
92
74
  - lib/yard/markdown/tag_formatting_helper.rb
93
- - sig/yard/markdown.rbs
94
75
  - templates/default/fulldoc/markdown/setup.rb
95
76
  - templates/default/module/markdown/setup.rb
96
77
  homepage: https://poshtui.com
data/.editorconfig DELETED
@@ -1,13 +0,0 @@
1
- # top-most EditorConfig file
2
- root = true
3
-
4
- # Unix-style newlines with a newline ending every file
5
- # Two spaces for indenting
6
- [*]
7
- end_of_line = lf
8
- insert_final_newline = true
9
- indent_style = space
10
- indent_size = 2
11
- charset = utf-8
12
- trim_trailing_whitespace = true
13
- max_line_length = 120
data/.streerc DELETED
@@ -1,2 +0,0 @@
1
- --print-width=100
2
- --plugins=plugin/trailing_comma,disable_ternary
data/.yard-lint.yml DELETED
@@ -1,317 +0,0 @@
1
- # YARD-Lint Configuration (Strict Mode)
2
- # See https://github.com/mensfeld/yard-lint for documentation
3
- #
4
- # This is a strict configuration suitable for new projects with high documentation standards.
5
- # All validators are set to 'error' severity (no warnings or conventions).
6
- # Minimum coverage is set to 100%.
7
-
8
- # Global settings for all validators
9
- AllValidators:
10
- # YARD command-line options (applied to all validators by default)
11
- YardOptions:
12
- - --private
13
- - --protected
14
-
15
- # Global file exclusion patterns
16
- Exclude:
17
- - '\.git'
18
- - "vendor/**/*"
19
- - "node_modules/**/*"
20
- - "spec/**/*"
21
- - "test/**/*"
22
- - "tmp/**/*"
23
- - "example_rdoc.rb"
24
- - "example_yard.rb"
25
-
26
- # Exit code behavior (error, warning, convention, never)
27
- FailOnSeverity: error
28
-
29
- # Minimum documentation coverage percentage (0-100)
30
- # Fails if coverage is below this threshold
31
- MinCoverage: 100.0
32
-
33
- # Diff mode settings
34
- DiffMode:
35
- # Default base ref for --diff (auto-detects main/master if not specified)
36
- DefaultBaseRef: ~
37
-
38
- # Documentation validators
39
- Documentation/UndocumentedObjects:
40
- Description: "Checks for classes, modules, and methods without documentation."
41
- Enabled: true
42
- Severity: error
43
- ExcludedMethods:
44
- - "initialize/0" # Exclude parameter-less initialize
45
- - "/^_/" # Exclude private methods (by convention)
46
-
47
- Documentation/UndocumentedMethodArguments:
48
- Description: "Checks for method parameters without @param tags."
49
- Enabled: true
50
- Severity: error
51
-
52
- Documentation/UndocumentedBooleanMethods:
53
- Description: "Checks that question mark methods document their boolean return."
54
- Enabled: true
55
- Severity: error
56
-
57
- Documentation/UndocumentedOptions:
58
- Description: "Detects methods with options hash parameters but no @option tags."
59
- Enabled: true
60
- Severity: error
61
-
62
- Documentation/MissingReturn:
63
- Description: "Requires @return tags on all methods (opt-in for strict documentation)."
64
- Enabled: true # Enabled in strict mode
65
- Severity: error
66
- ExcludedMethods:
67
- - "initialize" # Exclude all initialize methods
68
- # - '/^_/' # Uncomment to exclude private methods (by convention)
69
-
70
- Documentation/MarkdownSyntax:
71
- Description: "Detects common markdown syntax errors in documentation."
72
- Enabled: true
73
- Severity: error
74
-
75
- Documentation/EmptyCommentLine:
76
- Description: "Detects empty comment lines at the start or end of documentation blocks."
77
- Enabled: true
78
- Severity: error
79
- EnabledPatterns:
80
- Leading: true
81
- Trailing: true
82
-
83
- Documentation/BlankLineBeforeDefinition:
84
- Description: "Detects blank lines between YARD documentation and method definition."
85
- Enabled: true
86
- Severity: error
87
- OrphanedSeverity: error
88
- EnabledPatterns:
89
- SingleBlankLine: true
90
- OrphanedDocs: true
91
-
92
- # Tags validators
93
- Tags/Order:
94
- Description: "Enforces consistent ordering of YARD tags."
95
- Enabled: true
96
- Severity: error
97
- EnforcedOrder:
98
- - param
99
- - option
100
- - yield
101
- - yieldparam
102
- - yieldreturn
103
- - return
104
- - raise
105
- - see
106
- - example
107
- - note
108
- - todo
109
-
110
- Tags/InvalidTypes:
111
- Description: "Validates type definitions in @param, @return, @option tags."
112
- Enabled: true
113
- Severity: error
114
- ValidatedTags:
115
- - param
116
- - option
117
- - return
118
-
119
- Tags/TypeSyntax:
120
- Description: "Validates YARD type syntax using YARD parser."
121
- Enabled: true
122
- Severity: error
123
- ValidatedTags:
124
- - param
125
- - option
126
- - return
127
- - yieldreturn
128
-
129
- Tags/MeaninglessTag:
130
- Description: "Detects @param/@option tags on classes, modules, or constants."
131
- Enabled: true
132
- Severity: error
133
- CheckedTags:
134
- - param
135
- - option
136
- InvalidObjectTypes:
137
- - class
138
- - module
139
- - constant
140
-
141
- Tags/CollectionType:
142
- Description: "Validates Hash collection syntax consistency."
143
- Enabled: true
144
- Severity: error
145
- EnforcedStyle: long # 'long' for Hash{K => V} (YARD standard), 'short' for {K => V}
146
- ValidatedTags:
147
- - param
148
- - option
149
- - return
150
- - yieldreturn
151
-
152
- Tags/TagTypePosition:
153
- Description: "Validates type annotation position in tags."
154
- Enabled: true
155
- Severity: error
156
- CheckedTags:
157
- - param
158
- - option
159
- # EnforcedStyle: 'type_after_name' (YARD standard: @param name [Type])
160
- # or 'type_first' (@param [Type] name)
161
- EnforcedStyle: type_after_name
162
-
163
- Tags/ApiTags:
164
- Description: "Enforces @api tags on public objects."
165
- Enabled: false # Opt-in validator
166
- Severity: error
167
- AllowedApis:
168
- - public
169
- - private
170
- - internal
171
-
172
- Tags/OptionTags:
173
- Description: "Requires @option tags for methods with options parameters."
174
- Enabled: true
175
- Severity: error
176
-
177
- Tags/ExampleSyntax:
178
- Description: "Validates Ruby syntax in @example tags."
179
- Enabled: true
180
- Severity: error
181
-
182
- Tags/ExampleStyle:
183
- Description: "Validates code style in @example tags using RuboCop/StandardRB."
184
- Enabled: false # Opt-in validator (requires RuboCop or StandardRB)
185
- Severity: convention
186
- # Linter: auto # Uncomment to explicitly configure: 'auto', 'rubocop', 'standard', 'none'
187
- # SkipPatterns: # Uncomment to skip examples matching patterns
188
- # - '/skip-lint/i'
189
- # - '/bad code/i'
190
-
191
- Tags/RedundantParamDescription:
192
- Description: "Detects meaningless parameter descriptions that add no value."
193
- Enabled: true
194
- Severity: error
195
- CheckedTags:
196
- - param
197
- - option
198
- Articles:
199
- - The
200
- - the
201
- - A
202
- - a
203
- - An
204
- - an
205
- MaxRedundantWords: 6
206
- GenericTerms:
207
- - object
208
- - instance
209
- - value
210
- - data
211
- - item
212
- - element
213
- EnabledPatterns:
214
- ArticleParam: true
215
- PossessiveParam: true
216
- TypeRestatement: true
217
- ParamToVerb: true
218
- IdPattern: true
219
- DirectionalDate: true
220
- TypeGeneric: true
221
-
222
- Tags/InformalNotation:
223
- Description: 'Detects informal tag notation patterns like "Note:" instead of @note.'
224
- Enabled: true
225
- Severity: error
226
- CaseSensitive: false
227
- RequireStartOfLine: true
228
- Patterns:
229
- Note: "@note"
230
- Todo: "@todo"
231
- TODO: "@todo"
232
- FIXME: "@todo"
233
- See: "@see"
234
- See also: "@see"
235
- Warning: "@deprecated"
236
- Deprecated: "@deprecated"
237
- Author: "@author"
238
- Version: "@version"
239
- Since: "@since"
240
- Returns: "@return"
241
- Raises: "@raise"
242
- Example: "@example"
243
-
244
- Tags/NonAsciiType:
245
- Description: "Detects non-ASCII characters in type annotations."
246
- Enabled: true
247
- Severity: error
248
- ValidatedTags:
249
- - param
250
- - option
251
- - return
252
- - yieldreturn
253
- - yieldparam
254
-
255
- Tags/TagGroupSeparator:
256
- Description: "Enforces blank line separators between different YARD tag groups."
257
- Enabled: false # Opt-in validator
258
- Severity: error
259
- TagGroups:
260
- param: [param, option]
261
- return: [return]
262
- error: [raise, throws]
263
- example: [example]
264
- meta: [see, note, todo, deprecated, since, version, api]
265
- yield: [yield, yieldparam, yieldreturn]
266
- RequireAfterDescription: false
267
-
268
- Tags/ForbiddenTags:
269
- Description: "Detects forbidden tag and type combinations."
270
- Enabled: false # Opt-in validator
271
- Severity: error
272
- ForbiddenPatterns: []
273
- # Example patterns:
274
- # - Tag: return
275
- # Types:
276
- # - void
277
- # - Tag: param
278
- # Types:
279
- # - Object
280
- # - Tag: api # Forbids @api tag entirely (no Types = any occurrence)
281
-
282
- # Warnings validators - catches YARD parser errors
283
- Warnings/UnknownTag:
284
- Description: "Detects unknown YARD tags."
285
- Enabled: true
286
- Severity: error
287
-
288
- Warnings/UnknownDirective:
289
- Description: "Detects unknown YARD directives."
290
- Enabled: true
291
- Severity: error
292
-
293
- Warnings/InvalidTagFormat:
294
- Description: "Detects malformed tag syntax."
295
- Enabled: true
296
- Severity: error
297
-
298
- Warnings/InvalidDirectiveFormat:
299
- Description: "Detects malformed directive syntax."
300
- Enabled: true
301
- Severity: error
302
-
303
- Warnings/DuplicatedParameterName:
304
- Description: "Detects duplicate @param tags."
305
- Enabled: true
306
- Severity: error
307
-
308
- Warnings/UnknownParameterName:
309
- Description: "Detects @param tags for non-existent parameters."
310
- Enabled: true
311
- Severity: error
312
-
313
- # Semantic validators
314
- Semantic/AbstractMethods:
315
- Description: "Ensures @abstract methods do not have real implementations."
316
- Enabled: true
317
- Severity: error
data/.yardopts DELETED
@@ -1 +0,0 @@
1
- --load ./lib/yard-markdown.rb
data/AGENTS.md DELETED
@@ -1,54 +0,0 @@
1
- You are working in a Ruby project that uses mutation testing.
2
-
3
- ## Goal
4
-
5
- Achieve 100% mutation coverage. Verify with:
6
-
7
- ```
8
- bundle exec mutant run
9
- ```
10
-
11
- When iterating, prefer `--fail-fast` so you address one surviving
12
- mutant at a time:
13
-
14
- ```
15
- bundle exec mutant run --fail-fast
16
- ```
17
-
18
- ## When you find an alive mutation
19
-
20
- Decide which bucket it falls into:
21
-
22
- - **A) The code does too much** for what the tests ask for. The
23
- surviving mutation reveals behavior that no test requires. The
24
- fix is to simplify the implementation.
25
- - **B) A test is missing.** The behavior is intentional but no test
26
- observes it. The fix is to add a test.
27
-
28
- Decide between A) and B) before changing anything. If unsure, ask
29
- the user.
30
-
31
- ## Constraints
32
-
33
- - Line coverage must stay at 100%. Verify with:
34
-
35
- ```
36
- SIMPLECOV=1 bundle exec rake test
37
- ```
38
-
39
- - You may not skip mutants by configuring mutant to ignore them.
40
- No `expressions:` filters, no `coverage_criteria:` tweaks.
41
- - You may not use `send` or `__send__` to invoke private methods
42
- in tests just to satisfy mutant.
43
- - You may not stub or mock the system under test (`Age`).
44
-
45
- ## Done
46
-
47
- You are done when both of these are green and don't return any offenses:
48
-
49
- ```
50
- SIMPLECOV=1 bundle exec rake test
51
- bundle exec mutant run
52
- bundle exec rake markdown:validate_real_world
53
- yard-lint lib/
54
- ```