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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -1
- data/README.md +14 -19
- data/lib/yard/markdown/aref_helper.rb +14 -4
- data/lib/yard/markdown/collection_rendering_helper.rb +19 -53
- data/lib/yard/markdown/documentation_helper.rb +16 -4
- data/lib/yard/markdown/heading_helper.rb +1 -1
- data/lib/yard/markdown/link_normalization_helper.rb +13 -15
- data/lib/yard/markdown/method_presentation_helper.rb +8 -12
- data/lib/yard/markdown/object_listing_helper.rb +1 -1
- data/lib/yard/markdown/relationship_section_helper.rb +3 -3
- data/lib/yard/markdown/section_assembly_helper.rb +6 -17
- data/lib/yard/markdown/tag_formatting_helper.rb +9 -33
- data/lib/yard-markdown.rb +0 -1
- data/templates/default/fulldoc/markdown/setup.rb +17 -44
- data/templates/default/module/markdown/setup.rb +15 -30
- metadata +2 -21
- data/.editorconfig +0 -13
- data/.streerc +0 -2
- data/.yard-lint.yml +0 -317
- data/.yardopts +0 -1
- data/AGENTS.md +0 -54
- data/Rakefile +0 -196
- data/config/mutant.yml +0 -25
- 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 -147
- data/example_yard.rb +0 -145
- data/lib/yard/markdown/anchor_component_helper.rb +0 -20
- data/sig/yard/markdown.rbs +0 -348
data/Rakefile
DELETED
|
@@ -1,196 +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
|
-
|
|
117
|
-
namespace :examples do
|
|
118
|
-
desc "Generate basic example documentation using yard-markdown plugin"
|
|
119
|
-
task :generate do
|
|
120
|
-
Rake::Task["examples:yard"].invoke
|
|
121
|
-
Rake::Task["examples:rdoc"].invoke
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
desc "Generate example documentation for code annotated with yard"
|
|
125
|
-
task :yard do
|
|
126
|
-
generate_markdown_docs("example_yard.rb", "example/yard")
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
desc "Generate example documentation for code annotated with rdoc"
|
|
130
|
-
task :rdoc do
|
|
131
|
-
generate_markdown_docs("example_rdoc.rb", "example/rdoc")
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
namespace :real_world do
|
|
136
|
-
REPOS_DIR = "tmp/real-world/repos"
|
|
137
|
-
RSPEC_REPO = "#{REPOS_DIR}/rspec-core"
|
|
138
|
-
SIDEKIQ_REPO = "#{REPOS_DIR}/sidekiq"
|
|
139
|
-
|
|
140
|
-
desc "Checkout rspec-core repository"
|
|
141
|
-
task :checkout_rspec do
|
|
142
|
-
checkout_repo("https://github.com/rspec/rspec-core.git", RSPEC_REPO, ref: "v3.13.2")
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
desc "Checkout sidekiq repository"
|
|
146
|
-
task :checkout_sidekiq do
|
|
147
|
-
checkout_repo("https://github.com/sidekiq/sidekiq.git", SIDEKIQ_REPO, ref: "v7.3.10")
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
desc "Generate markdown docs for rspec-core"
|
|
151
|
-
task rspec: :checkout_rspec do
|
|
152
|
-
generate_markdown_docs("#{RSPEC_REPO}/lib", "tmp/real-world/rspec-core")
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
desc "Generate markdown docs for sidekiq"
|
|
156
|
-
task sidekiq: :checkout_sidekiq do
|
|
157
|
-
generate_markdown_docs("#{SIDEKIQ_REPO}/lib", "tmp/real-world/sidekiq")
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
desc "Generate markdown docs for rspec-core and sidekiq"
|
|
161
|
-
task :generate do
|
|
162
|
-
Rake::Task["real_world:rspec"].invoke
|
|
163
|
-
Rake::Task["real_world:sidekiq"].invoke
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
namespace :markdown do
|
|
168
|
-
desc "Validate checked-in example markdown output"
|
|
169
|
-
task validate_examples: "examples:generate" do
|
|
170
|
-
["example/yard", "example/rdoc"].each do |dir|
|
|
171
|
-
file_count = MarkdownValidator.new(dir).validate!
|
|
172
|
-
puts "Validated #{file_count} markdown files in #{dir}"
|
|
173
|
-
end
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
desc "Generate and validate markdown output for rspec-core and sidekiq"
|
|
177
|
-
task validate_real_world: "real_world:generate" do
|
|
178
|
-
["tmp/real-world/rspec-core", "tmp/real-world/sidekiq"].each do |dir|
|
|
179
|
-
validator = MarkdownValidator.new(dir, strict_links: false)
|
|
180
|
-
file_count = validator.validate!
|
|
181
|
-
puts "Validated #{file_count} markdown files in #{dir} (unresolved local links: #{validator.unresolved_links})"
|
|
182
|
-
end
|
|
183
|
-
end
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
namespace :types do
|
|
187
|
-
desc "Generate checked-in RBS types from YARD documentation"
|
|
188
|
-
task :generate do
|
|
189
|
-
generate_types
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
desc "Verify checked-in RBS types are up to date"
|
|
193
|
-
task check: :generate do
|
|
194
|
-
ensure_clean_generated_file(TYPES_OUTPUT_PATH)
|
|
195
|
-
end
|
|
196
|
-
end
|
data/config/mutant.yml
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
usage: opensource
|
|
2
|
-
|
|
3
|
-
integration:
|
|
4
|
-
name: minitest
|
|
5
|
-
|
|
6
|
-
includes:
|
|
7
|
-
- lib
|
|
8
|
-
- test
|
|
9
|
-
|
|
10
|
-
requires:
|
|
11
|
-
- ./test/support/mutant_setup.rb
|
|
12
|
-
|
|
13
|
-
matcher:
|
|
14
|
-
subjects:
|
|
15
|
-
- YARD::Markdown::AnchorComponentHelper#
|
|
16
|
-
- YARD::Markdown::ArefHelper#
|
|
17
|
-
- YARD::Markdown::CollectionRenderingHelper#
|
|
18
|
-
- YARD::Markdown::DocumentationHelper#
|
|
19
|
-
- YARD::Markdown::HeadingHelper#
|
|
20
|
-
- YARD::Markdown::LinkNormalizationHelper#
|
|
21
|
-
- YARD::Markdown::MethodPresentationHelper#
|
|
22
|
-
- YARD::Markdown::ObjectListingHelper#
|
|
23
|
-
- YARD::Markdown::RelationshipSectionHelper#
|
|
24
|
-
- YARD::Markdown::SectionAssemblyHelper#
|
|
25
|
-
- YARD::Markdown::TagFormattingHelper#
|
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
data/example/yard/Fish.md
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Class Fish <a id="class-Fish"></a>
|
|
2
|
-
|
|
3
|
-
**Inherits:** `Object`
|
|
4
|
-
|
|
5
|
-
The base class for all fish.
|
|
6
|
-
|
|
7
|
-
## Public Instance Methods
|
|
8
|
-
### `make_sound()` <a id="method-i-make_sound"></a> <a id="make_sound-instance_method"></a>
|
|
9
|
-
Make a sound.
|
|
10
|
-
- **@return** [void]
|
|
11
|
-
- **@yield** [sound] The sound produced by the fish
|
|
12
|
-
- **@yieldparam** `sound` [String] The actual sound
|
|
13
|
-
|
|
14
|
-
### `swim(direction, speed)` <a id="method-i-swim"></a> <a id="swim-instance_method"></a>
|
|
15
|
-
Swim in a specific direction.
|
|
16
|
-
|
|
17
|
-
Swimming is the most critical feature of fish.
|
|
18
|
-
- **@param** `direction` [Symbol, String] The direction to swim
|
|
19
|
-
- **@param** `speed` [Integer] The speed at which to swim
|
|
20
|
-
- **@return** [Boolean] Whether the swim was successful
|
|
21
|
-
|
|
22
|
-
**@example**
|
|
23
|
-
```ruby
|
|
24
|
-
swim(:north, 30)
|
|
25
|
-
```
|
data/example/yard/Salmon.md
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# Class Salmon <a id="class-Salmon"></a>
|
|
2
|
-
|
|
3
|
-
**Inherits:** `Fish`
|
|
4
|
-
**Includes:** `Aquatic`
|
|
5
|
-
|
|
6
|
-
A salmon is an Aquatic Fish.
|
|
7
|
-
|
|
8
|
-
## Features
|
|
9
|
-
|
|
10
|
-
* **Fish**
|
|
11
|
-
* make_sound
|
|
12
|
-
* swim
|
|
13
|
-
* **Aquatic**
|
|
14
|
-
* swim (overridden)
|
|
15
|
-
|
|
16
|
-
## Constants
|
|
17
|
-
### Salmon specific attributes
|
|
18
|
-
#### `MAX_SPEED` <a id="constant-MAX_SPEED"></a> <a id="MAX_SPEED-constant"></a>
|
|
19
|
-
- **@return** [Integer] Maximum speed for a swimming salmon
|
|
20
|
-
### General
|
|
21
|
-
#### `@@wild_salmon` <a id="classvariable--40-40wild_salmon"></a> <a id="@@wild_salmon-classvariable"></a>
|
|
22
|
-
Global list of all wild salmon.
|
|
23
|
-
|
|
24
|
-
Use for conservation efforts.
|
|
25
|
-
|
|
26
|
-
## Attributes
|
|
27
|
-
### Salmon specific attributes
|
|
28
|
-
#### `farmed` [RW] <a id="attribute-i-farmed"></a> <a id="farmed-instance_method"></a>
|
|
29
|
-
- **@return** [Boolean] True for farmed salmon
|
|
30
|
-
|
|
31
|
-
#### `wild` [R] <a id="attribute-i-wild"></a> <a id="wild-instance_method"></a>
|
|
32
|
-
- **@return** [Boolean] True for wild salmon
|
|
33
|
-
|
|
34
|
-
## Public Class Methods
|
|
35
|
-
### `wild_salmon()` <a id="method-c-wild_salmon"></a> <a id="wild_salmon-class_method"></a>
|
|
36
|
-
- **@return** [Array<Salmon>] List of all wild salmon
|
|
37
|
-
|
|
38
|
-
## Public Instance Methods
|
|
39
|
-
### Fish overrides
|
|
40
|
-
#### `make_sound()` <a id="method-i-make_sound"></a> <a id="make_sound-instance_method"></a>
|
|
41
|
-
Salmon overrides generic implementation.
|
|
42
|
-
- **@return** [void]
|
|
43
|
-
- **@yield** [sound] The sound produced by the salmon
|
|
44
|
-
- **@yieldparam** `sound` [String] The actual sound
|
|
45
|
-
### General
|
|
46
|
-
#### `initialize(farmed, wild)` <a id="method-i-initialize"></a> <a id="initialize-instance_method"></a>
|
|
47
|
-
Creates a new salmon.
|
|
48
|
-
- **@param** `farmed` [Boolean] Whether the salmon is farmed
|
|
49
|
-
- **@param** `wild` [Boolean] Whether the salmon is wild
|
|
50
|
-
- **@return** [Salmon] a new instance of Salmon
|
|
51
|
-
|
|
52
|
-
#### `sustainable?()` <a id="method-i-sustainable-3F"></a> <a id="sustainable?-instance_method"></a>
|
|
53
|
-
Checks if this salmon is sustainable.
|
|
54
|
-
- **@return** [Boolean] Whether the salmon is sustainable
|
|
55
|
-
|
|
56
|
-
#### `swim()` <a id="method-i-swim"></a> <a id="swim-instance_method"></a>
|
|
57
|
-
Swim in the water.
|
|
58
|
-
- **@return** [void]
|
data/example/yard/index.csv
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
name,type,path
|
|
2
|
-
Aquatic,Module,Aquatic.md
|
|
3
|
-
Aquatic.swim,Method,Aquatic.md#method-i-swim
|
|
4
|
-
Fish,Class,Fish.md
|
|
5
|
-
Fish.make_sound,Method,Fish.md#method-i-make_sound
|
|
6
|
-
Fish.swim,Method,Fish.md#method-i-swim
|
|
7
|
-
Salmon,Class,Salmon.md
|
|
8
|
-
Salmon.MAX_SPEED,Constant,Salmon.md#constant-MAX_SPEED
|
|
9
|
-
Salmon.@@wild_salmon,Constant,Salmon.md#classvariable--40-40wild_salmon
|
|
10
|
-
Salmon.initialize,Method,Salmon.md#method-i-initialize
|
|
11
|
-
Salmon.make_sound,Method,Salmon.md#method-i-make_sound
|
|
12
|
-
Salmon.sustainable?,Method,Salmon.md#method-i-sustainable-3F
|
|
13
|
-
Salmon.swim,Method,Salmon.md#method-i-swim
|
|
14
|
-
Salmon.wild_salmon,Method,Salmon.md#method-c-wild_salmon
|
|
15
|
-
Salmon.farmed,Attribute,Salmon.md#attribute-i-farmed
|
|
16
|
-
Salmon.wild,Attribute,Salmon.md#attribute-i-wild
|
data/example_rdoc.rb
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
##
|
|
2
|
-
# === RDoc::Generator::Markdown example.
|
|
3
|
-
#
|
|
4
|
-
# This example employs various RDoc features to demonstrate
|
|
5
|
-
# generator output.
|
|
6
|
-
#
|
|
7
|
-
# ---
|
|
8
|
-
#
|
|
9
|
-
# Links:
|
|
10
|
-
#
|
|
11
|
-
# 1. {Project Home Page}[https://github.com/skatkov/rdoc-markdown)
|
|
12
|
-
# 2. {RDoc Documentation}[http://ruby-doc.org/stdlib-2.0.0/libdoc/rdoc/rdoc/RDoc/Markup.html]
|
|
13
|
-
#
|
|
14
|
-
|
|
15
|
-
##
|
|
16
|
-
# A mixin for waterfowl creatures.
|
|
17
|
-
module Waterfowl
|
|
18
|
-
# Swimming helper.
|
|
19
|
-
def swim
|
|
20
|
-
puts "swimming around"
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
##
|
|
25
|
-
# The base class for all birds.
|
|
26
|
-
class Bird
|
|
27
|
-
##
|
|
28
|
-
# Produce some noise.
|
|
29
|
-
#--
|
|
30
|
-
# FIXME: maybe extract this to a base class +Animal+?
|
|
31
|
-
#++
|
|
32
|
-
def speak # :yields: text
|
|
33
|
-
puts "generic tweeting"
|
|
34
|
-
yield "tweet"
|
|
35
|
-
yield "tweet"
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# Fly somewhere.
|
|
39
|
-
#
|
|
40
|
-
# Flying is the most critical feature of birds.
|
|
41
|
-
#
|
|
42
|
-
# :args: direction, velocity
|
|
43
|
-
#
|
|
44
|
-
# :call-seq:
|
|
45
|
-
# Bird.fly(symbol, number) -> bool
|
|
46
|
-
# Bird.fly(string, number) -> bool
|
|
47
|
-
#
|
|
48
|
-
# = Example
|
|
49
|
-
#
|
|
50
|
-
# fly(:south, 70)
|
|
51
|
-
def fly(direction, velocity)
|
|
52
|
-
_fly_impl(direction, velocity)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def _fly_impl(_direction, _velocity) # :nodoc:
|
|
56
|
-
puts "flying away: direction=#{direction}, velocity=#{velocity}"
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
##
|
|
61
|
-
# A duck is a Waterfowl Bird.
|
|
62
|
-
#
|
|
63
|
-
# Features:
|
|
64
|
-
#
|
|
65
|
-
# bird::
|
|
66
|
-
#
|
|
67
|
-
# * speak
|
|
68
|
-
# * fly
|
|
69
|
-
#
|
|
70
|
-
# waterfowl::
|
|
71
|
-
#
|
|
72
|
-
# * swim
|
|
73
|
-
class Duck
|
|
74
|
-
extend Animal
|
|
75
|
-
include Waterfowl
|
|
76
|
-
|
|
77
|
-
# :section: Bird overrides
|
|
78
|
-
|
|
79
|
-
# Duck overrides generic implementation.
|
|
80
|
-
def speak
|
|
81
|
-
speech = quack
|
|
82
|
-
yield speech
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
# Implements quacking
|
|
86
|
-
def quack
|
|
87
|
-
"quack"
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
private :quack
|
|
91
|
-
|
|
92
|
-
# :section: Duck extensions
|
|
93
|
-
|
|
94
|
-
# True for domestic ducks.
|
|
95
|
-
attr_accessor :domestic
|
|
96
|
-
|
|
97
|
-
# True for rubber ducks.
|
|
98
|
-
attr_reader :rubber
|
|
99
|
-
|
|
100
|
-
MAX_VELOCITY = 130 # Maximum velocity for a flying duck.
|
|
101
|
-
|
|
102
|
-
##
|
|
103
|
-
# Global list of all rubber ducks.
|
|
104
|
-
#
|
|
105
|
-
# Use when in trouble.
|
|
106
|
-
@@rubber_ducks = []
|
|
107
|
-
|
|
108
|
-
# @return [Array<Duck>] list of all rubber ducks
|
|
109
|
-
def self.rubber_ducks
|
|
110
|
-
@@rubber_ducks
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
# Creates a new duck.
|
|
114
|
-
#
|
|
115
|
-
# @param [Boolean] domestic
|
|
116
|
-
# @param [Boolean] rubber
|
|
117
|
-
def initialize(domestic, rubber)
|
|
118
|
-
@domestic = domestic
|
|
119
|
-
@rubber = rubber
|
|
120
|
-
@@rubber_ducks << self if rubber
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
# Checks if this duck is a useful one.
|
|
124
|
-
#
|
|
125
|
-
# :call-seq:
|
|
126
|
-
# Bird.useful? -> bool
|
|
127
|
-
def useful?
|
|
128
|
-
@domestic || @rubber
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
# Default velocity for a flying duck.
|
|
133
|
-
DEFAULT_DUCK_VELOCITY = 70
|
|
134
|
-
DEFAULT_SPEED = 10 # Maximum speed for a swimming duck.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
# Default rubber duck.
|
|
138
|
-
#
|
|
139
|
-
# *Note:*
|
|
140
|
-
# Global variables are evil, but rubber ducks are worth it.
|
|
141
|
-
$default_rubber_duck = Duck.new(false, true)
|
|
142
|
-
|
|
143
|
-
# Domestic rubber duck.
|
|
144
|
-
#
|
|
145
|
-
# *Note:*
|
|
146
|
-
# This is weird... Thus not making it global.
|
|
147
|
-
domestic_rubber_duck = Duck.new(true, true) # rubocop:disable Lint/UselessAssignment
|