yard-markdown 0.7.1 → 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +0 -8
- data/lib/yard/markdown/aref_helper.rb +11 -1
- data/lib/yard/markdown/collection_rendering_helper.rb +19 -53
- data/lib/yard/markdown/method_presentation_helper.rb +3 -7
- data/lib/yard/markdown/section_assembly_helper.rb +5 -16
- data/lib/yard/markdown/tag_formatting_helper.rb +4 -28
- data/lib/yard-markdown.rb +0 -1
- data/templates/default/fulldoc/markdown/setup.rb +11 -39
- data/templates/default/module/markdown/setup.rb +11 -27
- metadata +2 -22
- data/.editorconfig +0 -13
- data/.standard.yml +0 -3
- data/.streerc +0 -2
- data/.yard-lint.yml +0 -317
- data/.yardopts +0 -1
- data/AGENTS.md +0 -54
- data/Rakefile +0 -195
- data/config/mutant.yml +0 -15
- data/example/rdoc/Bird.md +0 -25
- data/example/rdoc/Duck.md +0 -59
- data/example/rdoc/Waterfowl.md +0 -7
- data/example/rdoc/index.csv +0 -16
- data/example/yard/Aquatic.md +0 -8
- data/example/yard/Fish.md +0 -25
- data/example/yard/Salmon.md +0 -58
- data/example/yard/index.csv +0 -16
- data/example_rdoc.rb +0 -146
- data/example_yard.rb +0 -145
- data/lib/yard/markdown/anchor_component_helper.rb +0 -20
- data/sig/yard/markdown.rbs +0 -348
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.
|
|
44
|
-
|
|
45
|
-
## Done
|
|
46
|
-
|
|
47
|
-
You are done when all of these commands 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
|
|
54
|
-
```
|
data/Rakefile
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "fileutils"
|
|
4
|
-
require "open3"
|
|
5
|
-
require "shellwords"
|
|
6
|
-
|
|
7
|
-
require "bundler/gem_tasks"
|
|
8
|
-
require "rake/testtask"
|
|
9
|
-
|
|
10
|
-
require_relative "test/support/markdown_validator"
|
|
11
|
-
|
|
12
|
-
Rake::TestTask.new(:test) do |t|
|
|
13
|
-
t.libs << "test"
|
|
14
|
-
t.libs << "lib"
|
|
15
|
-
t.test_files = FileList["test/**/test_*.rb"]
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
task default: %i[test stree:write]
|
|
19
|
-
|
|
20
|
-
TYPES_OUTPUT_PATH = "sig/yard/markdown.rbs"
|
|
21
|
-
|
|
22
|
-
def shell_escape(path)
|
|
23
|
-
Shellwords.escape(path)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
COMMAND_WARNING_REGEX = /\bwarning:/i
|
|
27
|
-
COMMAND_ERROR_REGEX = /\b(?:error|exception|fatal|loaderror)\b/i
|
|
28
|
-
|
|
29
|
-
def analyze_command_output(text)
|
|
30
|
-
lines = text.each_line.map(&:strip).reject(&:empty?)
|
|
31
|
-
{
|
|
32
|
-
warnings: lines.grep(COMMAND_WARNING_REGEX),
|
|
33
|
-
errors: lines.grep(COMMAND_ERROR_REGEX)
|
|
34
|
-
}
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def command_log_path(label)
|
|
38
|
-
safe_label = label.gsub(%r{[^a-zA-Z0-9_-]+}, "_")
|
|
39
|
-
File.join("tmp", "command-logs", "#{safe_label}.log")
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def run_command_with_analysis(command, label:)
|
|
43
|
-
puts command
|
|
44
|
-
|
|
45
|
-
stdout, stderr, status = Open3.capture3(command)
|
|
46
|
-
combined_output = [stdout, stderr].reject(&:empty?).join("\n")
|
|
47
|
-
log_path = command_log_path(label)
|
|
48
|
-
|
|
49
|
-
FileUtils.mkdir_p(File.dirname(log_path))
|
|
50
|
-
File.write(log_path, combined_output)
|
|
51
|
-
|
|
52
|
-
puts combined_output unless combined_output.empty?
|
|
53
|
-
|
|
54
|
-
stdout_analysis = analyze_command_output(stdout)
|
|
55
|
-
stderr_analysis = analyze_command_output(stderr)
|
|
56
|
-
combined_analysis = {
|
|
57
|
-
warnings: stdout_analysis[:warnings] + stderr_analysis[:warnings],
|
|
58
|
-
errors: stdout_analysis[:errors] + stderr_analysis[:errors]
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
puts "Output analysis for #{label}: warnings=#{combined_analysis[:warnings].size}, errors=#{combined_analysis[:errors].size}"
|
|
62
|
-
|
|
63
|
-
return if status.success? && combined_analysis[:errors].empty?
|
|
64
|
-
|
|
65
|
-
details = ["#{label} failed output checks (log: #{log_path})"]
|
|
66
|
-
details << "exit status: #{status.exitstatus}" unless status.success?
|
|
67
|
-
details << "errors: #{combined_analysis[:errors].first(5).join(" | ")}" unless combined_analysis[:errors].empty?
|
|
68
|
-
raise details.join("\n")
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def generate_markdown_docs(source, output_dir)
|
|
72
|
-
FileUtils.rm_rf(output_dir)
|
|
73
|
-
FileUtils.mkdir_p(output_dir)
|
|
74
|
-
|
|
75
|
-
command = "yardoc --no-stats --quiet --format markdown --load ./lib/yard-markdown.rb --output-dir #{shell_escape(output_dir)} #{shell_escape(source)}"
|
|
76
|
-
run_command_with_analysis(command, label: "yardoc_#{output_dir}")
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def checkout_repo(url, destination, ref: nil)
|
|
80
|
-
FileUtils.rm_rf(destination)
|
|
81
|
-
FileUtils.mkdir_p(File.dirname(destination))
|
|
82
|
-
|
|
83
|
-
command = "git clone --depth 1"
|
|
84
|
-
command += " --branch #{shell_escape(ref)}" if ref
|
|
85
|
-
command += " #{shell_escape(url)} #{shell_escape(destination)}"
|
|
86
|
-
run_command_with_analysis(command, label: "git_clone_#{destination}")
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
def generate_types(output_path = TYPES_OUTPUT_PATH)
|
|
90
|
-
FileUtils.mkdir_p(File.dirname(output_path))
|
|
91
|
-
|
|
92
|
-
command = [
|
|
93
|
-
"sord gen",
|
|
94
|
-
"--rbs",
|
|
95
|
-
"--no-sord-comments",
|
|
96
|
-
"--replace-unresolved-with-untyped",
|
|
97
|
-
"--replace-errors-with-untyped",
|
|
98
|
-
shell_escape(output_path)
|
|
99
|
-
].join(" ")
|
|
100
|
-
|
|
101
|
-
run_command_with_analysis(command, label: "sord_generate")
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def ensure_clean_generated_file(path)
|
|
105
|
-
command = "git status --short -- #{shell_escape(path)}"
|
|
106
|
-
stdout, stderr, status = Open3.capture3(command)
|
|
107
|
-
combined_output = [stdout, stderr].reject(&:empty?).join("\n")
|
|
108
|
-
|
|
109
|
-
raise "Unable to verify generated types for #{path}" unless status.success?
|
|
110
|
-
return if combined_output.strip.empty?
|
|
111
|
-
|
|
112
|
-
puts combined_output
|
|
113
|
-
raise "#{path} is out of date. Run `bundle exec rake types:generate` and commit the updated file."
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
namespace :examples do
|
|
117
|
-
desc "Generate basic example documentation using yard-markdown plugin"
|
|
118
|
-
task :generate do
|
|
119
|
-
Rake::Task["examples:yard"].invoke
|
|
120
|
-
Rake::Task["examples:rdoc"].invoke
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
desc "Generate example documentation for code annotated with yard"
|
|
124
|
-
task :yard do
|
|
125
|
-
generate_markdown_docs("example_yard.rb", "example/yard")
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
desc "Generate example documentation for code annotated with rdoc"
|
|
129
|
-
task :rdoc do
|
|
130
|
-
generate_markdown_docs("example_rdoc.rb", "example/rdoc")
|
|
131
|
-
end
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
namespace :real_world do
|
|
135
|
-
repos_dir = "tmp/real-world/repos"
|
|
136
|
-
rspec_repo = "#{repos_dir}/rspec-core"
|
|
137
|
-
sidekiq_repo = "#{repos_dir}/sidekiq"
|
|
138
|
-
|
|
139
|
-
desc "Checkout rspec-core repository"
|
|
140
|
-
task :checkout_rspec do
|
|
141
|
-
checkout_repo("https://github.com/rspec/rspec-core.git", rspec_repo, ref: "v3.13.2")
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
desc "Checkout sidekiq repository"
|
|
145
|
-
task :checkout_sidekiq do
|
|
146
|
-
checkout_repo("https://github.com/sidekiq/sidekiq.git", sidekiq_repo, ref: "v7.3.10")
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
desc "Generate markdown docs for rspec-core"
|
|
150
|
-
task rspec: :checkout_rspec do
|
|
151
|
-
generate_markdown_docs("#{rspec_repo}/lib", "tmp/real-world/rspec-core")
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
desc "Generate markdown docs for sidekiq"
|
|
155
|
-
task sidekiq: :checkout_sidekiq do
|
|
156
|
-
generate_markdown_docs("#{sidekiq_repo}/lib", "tmp/real-world/sidekiq")
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
desc "Generate markdown docs for rspec-core and sidekiq"
|
|
160
|
-
task :generate do
|
|
161
|
-
Rake::Task["real_world:rspec"].invoke
|
|
162
|
-
Rake::Task["real_world:sidekiq"].invoke
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
namespace :markdown do
|
|
167
|
-
desc "Validate checked-in example markdown output"
|
|
168
|
-
task validate_examples: "examples:generate" do
|
|
169
|
-
["example/yard", "example/rdoc"].each do |dir|
|
|
170
|
-
file_count = MarkdownValidator.new(dir).validate!
|
|
171
|
-
puts "Validated #{file_count} markdown files in #{dir}"
|
|
172
|
-
end
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
desc "Generate and validate markdown output for rspec-core and sidekiq"
|
|
176
|
-
task validate_real_world: "real_world:generate" do
|
|
177
|
-
["tmp/real-world/rspec-core", "tmp/real-world/sidekiq"].each do |dir|
|
|
178
|
-
validator = MarkdownValidator.new(dir, strict_links: false)
|
|
179
|
-
file_count = validator.validate!
|
|
180
|
-
puts "Validated #{file_count} markdown files in #{dir} (unresolved local links: #{validator.unresolved_links})"
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
namespace :types do
|
|
186
|
-
desc "Generate checked-in RBS types from YARD documentation"
|
|
187
|
-
task :generate do
|
|
188
|
-
generate_types
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
desc "Verify checked-in RBS types are up to date"
|
|
192
|
-
task check: :generate do
|
|
193
|
-
ensure_clean_generated_file(TYPES_OUTPUT_PATH)
|
|
194
|
-
end
|
|
195
|
-
end
|
data/config/mutant.yml
DELETED
data/example/rdoc/Bird.md
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Class Bird <a id="class-Bird"></a>
|
|
2
|
-
|
|
3
|
-
**Inherits:** `Object`
|
|
4
|
-
|
|
5
|
-
The base class for all birds.
|
|
6
|
-
|
|
7
|
-
## Public Instance Methods
|
|
8
|
-
### `fly(direction, velocity)` <a id="method-i-fly"></a> <a id="fly-instance_method"></a>
|
|
9
|
-
Fly somewhere.
|
|
10
|
-
|
|
11
|
-
Flying is the most critical feature of birds.
|
|
12
|
-
|
|
13
|
-
:args: direction, velocity
|
|
14
|
-
|
|
15
|
-
:call-seq:
|
|
16
|
-
Bird.fly(symbol, number) -> bool
|
|
17
|
-
Bird.fly(string, number) -> bool
|
|
18
|
-
|
|
19
|
-
# Example
|
|
20
|
-
|
|
21
|
-
fly(:south, 70)
|
|
22
|
-
|
|
23
|
-
### `speak()` <a id="method-i-speak"></a> <a id="speak-instance_method"></a>
|
|
24
|
-
Produce some noise. -- FIXME: maybe extract this to a base class `Animal`? ++
|
|
25
|
-
- **@yield** ["tweet"]
|
data/example/rdoc/Duck.md
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# Class Duck <a id="class-Duck"></a>
|
|
2
|
-
|
|
3
|
-
**Inherits:** `Object`
|
|
4
|
-
**Extended by:** `Animal`
|
|
5
|
-
**Includes:** `Waterfowl`
|
|
6
|
-
|
|
7
|
-
A duck is a Waterfowl Bird.
|
|
8
|
-
|
|
9
|
-
Features:
|
|
10
|
-
|
|
11
|
-
bird::
|
|
12
|
-
|
|
13
|
-
* speak
|
|
14
|
-
* fly
|
|
15
|
-
|
|
16
|
-
waterfowl::
|
|
17
|
-
|
|
18
|
-
* swim
|
|
19
|
-
|
|
20
|
-
## Constants
|
|
21
|
-
### `@@rubber_ducks` <a id="classvariable--40-40rubber_ducks"></a> <a id="@@rubber_ducks-classvariable"></a>
|
|
22
|
-
Global list of all rubber ducks.
|
|
23
|
-
|
|
24
|
-
Use when in trouble.
|
|
25
|
-
|
|
26
|
-
### `MAX_VELOCITY` <a id="constant-MAX_VELOCITY"></a> <a id="MAX_VELOCITY-constant"></a>
|
|
27
|
-
Maximum velocity for a flying duck.
|
|
28
|
-
|
|
29
|
-
## Attributes
|
|
30
|
-
### `domestic` [RW] <a id="attribute-i-domestic"></a> <a id="domestic-instance_method"></a>
|
|
31
|
-
True for domestic ducks.
|
|
32
|
-
|
|
33
|
-
### `rubber` [R] <a id="attribute-i-rubber"></a> <a id="rubber-instance_method"></a>
|
|
34
|
-
True for rubber ducks.
|
|
35
|
-
|
|
36
|
-
## Public Class Methods
|
|
37
|
-
### `rubber_ducks()` <a id="method-c-rubber_ducks"></a> <a id="rubber_ducks-class_method"></a>
|
|
38
|
-
- **@return** [Array<Duck>] list of all rubber ducks
|
|
39
|
-
|
|
40
|
-
## Public Instance Methods
|
|
41
|
-
### `initialize(domestic, rubber)` <a id="method-i-initialize"></a> <a id="initialize-instance_method"></a>
|
|
42
|
-
Creates a new duck.
|
|
43
|
-
- **@param** `domestic` [Boolean]
|
|
44
|
-
- **@param** `rubber` [Boolean]
|
|
45
|
-
- **@return** [Duck] a new instance of Duck
|
|
46
|
-
|
|
47
|
-
### `speak()` <a id="method-i-speak"></a> <a id="speak-instance_method"></a>
|
|
48
|
-
Duck overrides generic implementation.
|
|
49
|
-
- **@yield** [speech]
|
|
50
|
-
|
|
51
|
-
### `swim()` <a id="method-i-swim"></a> <a id="swim-instance_method"></a>
|
|
52
|
-
Swimming helper.
|
|
53
|
-
|
|
54
|
-
### `useful?()` <a id="method-i-useful-3F"></a> <a id="useful?-instance_method"></a>
|
|
55
|
-
Checks if this duck is a useful one.
|
|
56
|
-
|
|
57
|
-
:call-seq:
|
|
58
|
-
Bird.useful? -> bool
|
|
59
|
-
- **@return** [Boolean]
|
data/example/rdoc/Waterfowl.md
DELETED
data/example/rdoc/index.csv
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
name,type,path
|
|
2
|
-
Waterfowl,Module,Waterfowl.md
|
|
3
|
-
Waterfowl.swim,Method,Waterfowl.md#method-i-swim
|
|
4
|
-
Bird,Class,Bird.md
|
|
5
|
-
Bird.fly,Method,Bird.md#method-i-fly
|
|
6
|
-
Bird.speak,Method,Bird.md#method-i-speak
|
|
7
|
-
Duck,Class,Duck.md
|
|
8
|
-
Duck.MAX_VELOCITY,Constant,Duck.md#constant-MAX_VELOCITY
|
|
9
|
-
Duck.@@rubber_ducks,Constant,Duck.md#classvariable--40-40rubber_ducks
|
|
10
|
-
Duck.initialize,Method,Duck.md#method-i-initialize
|
|
11
|
-
Duck.speak,Method,Duck.md#method-i-speak
|
|
12
|
-
Duck.swim,Method,Duck.md#method-i-swim
|
|
13
|
-
Duck.useful?,Method,Duck.md#method-i-useful-3F
|
|
14
|
-
Duck.rubber_ducks,Method,Duck.md#method-c-rubber_ducks
|
|
15
|
-
Duck.domestic,Attribute,Duck.md#attribute-i-domestic
|
|
16
|
-
Duck.rubber,Attribute,Duck.md#attribute-i-rubber
|
data/example/yard/Aquatic.md
DELETED