yard-markdown 0.5.0 → 0.6.0
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/README.md +31 -3
- data/Rakefile +126 -2
- data/example/rdoc/Bird.md +7 -14
- data/example/rdoc/Duck.md +28 -29
- data/example/rdoc/Waterfowl.md +3 -7
- data/example/rdoc/index.csv +5 -10
- data/example/yard/Aquatic.md +4 -9
- data/example/yard/Fish.md +13 -22
- data/example/yard/Salmon.md +37 -39
- data/example/yard/index.csv +5 -9
- data/templates/default/fulldoc/markdown/setup.rb +67 -187
- data/templates/default/module/markdown/setup.rb +484 -0
- metadata +18 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 92bac83ffe7c1f83b26164adef991efe13678b96096ba61af2626f83e9505991
|
|
4
|
+
data.tar.gz: 7c871bffa551b5acc83e0b954163d933b7289db6542b1485c385ab97fb53e4eb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7d7fb3ae97903f7c61aa0a057cdefd878a562264d15d5e7a3da17a5a2bdd5ea35c63cc47244022ab10fe20356c7adf367eee27e1de5b67281376174645c29b54
|
|
7
|
+
data.tar.gz: 126033d377d8e652a19b33731d57ccfad197731cf819521766dbee5b37d1ee293baf41fc58c7927073ae3cddea9c5a4227b57539023de96ff66740e3d53e88d7
|
data/README.md
CHANGED
|
@@ -33,7 +33,7 @@ It seems important to note, that yard claims to have support for RDoc. That supp
|
|
|
33
33
|
|
|
34
34
|
If you know how to improve that, please get in touch or submit a patch.
|
|
35
35
|
|
|
36
|
-
So in meantime, there is work going on a competing gem for RDoc and it's called [rdoc-
|
|
36
|
+
So in meantime, there is work going on a competing gem for RDoc and it's called [rdoc-markdown gem](https://github.com/skatkov/rdoc-markdown/).
|
|
37
37
|
|
|
38
38
|
## Note on index.csv file
|
|
39
39
|
This gem emits index of all markdown files in a index.csv file.
|
|
@@ -43,6 +43,34 @@ There are decent tools that offer search through structured plain-text files. Bu
|
|
|
43
43
|
In my personal use-case, I use SQLite. All other databases seem to have a good support for CSV imports.
|
|
44
44
|
|
|
45
45
|
## Testing
|
|
46
|
-
Unit tests
|
|
46
|
+
Unit tests verify renderer behavior, index links, and anchor consistency for both YARD-style and RDoc-style sources.
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
Run:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
bundle exec rake test
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Regenerate local sample docs:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
bundle exec rake examples:generate
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Validate generated markdown in sample docs:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
bundle exec rake markdown:validate_examples
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
There is also a real-world validation harness for repositories with substantial YARD documentation (`rspec-core`, `sidekiq`):
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
bundle exec rake markdown:validate_real_world
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
This task validates generated markdown against CommonMark + GFM rendering, and reports unresolved local links found in upstream source comments while still validating local anchor/link structure.
|
|
73
|
+
|
|
74
|
+
GitHub Actions CI now runs this task on every push/PR, so `sidekiq` and other real-world fixture gems are verified continuously.
|
|
75
|
+
|
|
76
|
+
For reproducible checks, the task clones pinned tags (`rspec-core` `v3.13.2`, `sidekiq` `v7.3.10`) into `tmp/real-world/repos` before generating output.
|
data/Rakefile
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "fileutils"
|
|
4
|
+
require "open3"
|
|
5
|
+
require "shellwords"
|
|
6
|
+
|
|
3
7
|
require "bundler/gem_tasks"
|
|
4
8
|
require "rake/testtask"
|
|
5
9
|
|
|
10
|
+
require_relative "test/support/markdown_validator"
|
|
11
|
+
|
|
6
12
|
Rake::TestTask.new(:test) do |t|
|
|
7
13
|
t.libs << "test"
|
|
8
14
|
t.libs << "lib"
|
|
@@ -11,6 +17,73 @@ end
|
|
|
11
17
|
|
|
12
18
|
task default: %i[test stree:write]
|
|
13
19
|
|
|
20
|
+
def shell_escape(path)
|
|
21
|
+
Shellwords.escape(path)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
COMMAND_WARNING_REGEX = /\bwarning:/i
|
|
25
|
+
COMMAND_ERROR_REGEX = /\b(?:error|exception|fatal|loaderror)\b/i
|
|
26
|
+
|
|
27
|
+
def analyze_command_output(text)
|
|
28
|
+
lines = text.each_line.map(&:strip).reject(&:empty?)
|
|
29
|
+
{
|
|
30
|
+
warnings: lines.grep(COMMAND_WARNING_REGEX),
|
|
31
|
+
errors: lines.grep(COMMAND_ERROR_REGEX)
|
|
32
|
+
}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def command_log_path(label)
|
|
36
|
+
safe_label = label.gsub(%r{[^a-zA-Z0-9_-]+}, "_")
|
|
37
|
+
File.join("tmp", "command-logs", "#{safe_label}.log")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def run_command_with_analysis(command, label:)
|
|
41
|
+
puts command
|
|
42
|
+
|
|
43
|
+
stdout, stderr, status = Open3.capture3(command)
|
|
44
|
+
combined_output = [stdout, stderr].reject(&:empty?).join("\n")
|
|
45
|
+
log_path = command_log_path(label)
|
|
46
|
+
|
|
47
|
+
FileUtils.mkdir_p(File.dirname(log_path))
|
|
48
|
+
File.write(log_path, combined_output)
|
|
49
|
+
|
|
50
|
+
puts combined_output unless combined_output.empty?
|
|
51
|
+
|
|
52
|
+
stdout_analysis = analyze_command_output(stdout)
|
|
53
|
+
stderr_analysis = analyze_command_output(stderr)
|
|
54
|
+
combined_analysis = {
|
|
55
|
+
warnings: stdout_analysis[:warnings] + stderr_analysis[:warnings],
|
|
56
|
+
errors: stdout_analysis[:errors] + stderr_analysis[:errors]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
puts "Output analysis for #{label}: warnings=#{combined_analysis[:warnings].size}, errors=#{combined_analysis[:errors].size}"
|
|
60
|
+
|
|
61
|
+
return if status.success? && combined_analysis[:errors].empty?
|
|
62
|
+
|
|
63
|
+
details = ["#{label} failed output checks (log: #{log_path})"]
|
|
64
|
+
details << "exit status: #{status.exitstatus}" unless status.success?
|
|
65
|
+
details << "errors: #{combined_analysis[:errors].first(5).join(' | ')}" unless combined_analysis[:errors].empty?
|
|
66
|
+
raise details.join("\n")
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def generate_markdown_docs(source, output_dir)
|
|
70
|
+
FileUtils.rm_rf(output_dir)
|
|
71
|
+
FileUtils.mkdir_p(output_dir)
|
|
72
|
+
|
|
73
|
+
command = "yardoc --no-stats --quiet --format markdown --load ./lib/yard-markdown.rb --output-dir #{shell_escape(output_dir)} #{shell_escape(source)}"
|
|
74
|
+
run_command_with_analysis(command, label: "yardoc_#{output_dir}")
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def checkout_repo(url, destination, ref: nil)
|
|
78
|
+
FileUtils.rm_rf(destination)
|
|
79
|
+
FileUtils.mkdir_p(File.dirname(destination))
|
|
80
|
+
|
|
81
|
+
command = "git clone --depth 1"
|
|
82
|
+
command += " --branch #{shell_escape(ref)}" if ref
|
|
83
|
+
command += " #{shell_escape(url)} #{shell_escape(destination)}"
|
|
84
|
+
run_command_with_analysis(command, label: "git_clone_#{destination}")
|
|
85
|
+
end
|
|
86
|
+
|
|
14
87
|
|
|
15
88
|
namespace :examples do
|
|
16
89
|
desc "Generate basic example documentation using yard-markdown plugin"
|
|
@@ -21,11 +94,62 @@ namespace :examples do
|
|
|
21
94
|
|
|
22
95
|
desc "Generate example documentation for code annotated with yard"
|
|
23
96
|
task :yard do
|
|
24
|
-
|
|
97
|
+
generate_markdown_docs("example_yard.rb", "example/yard")
|
|
25
98
|
end
|
|
26
99
|
|
|
27
100
|
desc "Generate example documentation for code annotated with rdoc"
|
|
28
101
|
task :rdoc do
|
|
29
|
-
|
|
102
|
+
generate_markdown_docs("example_rdoc.rb", "example/rdoc")
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
namespace :real_world do
|
|
107
|
+
REPOS_DIR = "tmp/real-world/repos"
|
|
108
|
+
RSPEC_REPO = "#{REPOS_DIR}/rspec-core"
|
|
109
|
+
SIDEKIQ_REPO = "#{REPOS_DIR}/sidekiq"
|
|
110
|
+
|
|
111
|
+
desc "Checkout rspec-core repository"
|
|
112
|
+
task :checkout_rspec do
|
|
113
|
+
checkout_repo("https://github.com/rspec/rspec-core.git", RSPEC_REPO, ref: "v3.13.2")
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
desc "Checkout sidekiq repository"
|
|
117
|
+
task :checkout_sidekiq do
|
|
118
|
+
checkout_repo("https://github.com/sidekiq/sidekiq.git", SIDEKIQ_REPO, ref: "v7.3.10")
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
desc "Generate markdown docs for rspec-core"
|
|
122
|
+
task rspec: :checkout_rspec do
|
|
123
|
+
generate_markdown_docs("#{RSPEC_REPO}/lib", "tmp/real-world/rspec-core")
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
desc "Generate markdown docs for sidekiq"
|
|
127
|
+
task sidekiq: :checkout_sidekiq do
|
|
128
|
+
generate_markdown_docs("#{SIDEKIQ_REPO}/lib", "tmp/real-world/sidekiq")
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
desc "Generate markdown docs for rspec-core and sidekiq"
|
|
132
|
+
task :generate do
|
|
133
|
+
Rake::Task["real_world:rspec"].invoke
|
|
134
|
+
Rake::Task["real_world:sidekiq"].invoke
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
namespace :markdown do
|
|
139
|
+
desc "Validate checked-in example markdown output"
|
|
140
|
+
task validate_examples: "examples:generate" do
|
|
141
|
+
["example/yard", "example/rdoc"].each do |dir|
|
|
142
|
+
file_count = MarkdownValidator.new(dir).validate!
|
|
143
|
+
puts "Validated #{file_count} markdown files in #{dir}"
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
desc "Generate and validate markdown output for rspec-core and sidekiq"
|
|
148
|
+
task validate_real_world: "real_world:generate" do
|
|
149
|
+
["tmp/real-world/rspec-core", "tmp/real-world/sidekiq"].each do |dir|
|
|
150
|
+
validator = MarkdownValidator.new(dir, strict_links: false)
|
|
151
|
+
file_count = validator.validate!
|
|
152
|
+
puts "Validated #{file_count} markdown files in #{dir} (unresolved local links: #{validator.unresolved_links})"
|
|
153
|
+
end
|
|
30
154
|
end
|
|
31
155
|
end
|
data/example/rdoc/Bird.md
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
# Class
|
|
2
|
-
**Inherits:** Object
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
The base class for all birds.
|
|
6
|
-
|
|
1
|
+
# Class Bird <a id="class-Bird"></a>
|
|
7
2
|
|
|
3
|
+
**Inherits:** `Object`
|
|
8
4
|
|
|
9
|
-
|
|
10
|
-
## _fly_impl(_direction, _velocity) [](#method-i-_fly_impl)
|
|
11
|
-
:nodoc:
|
|
5
|
+
The base class for all birds.
|
|
12
6
|
|
|
13
|
-
##
|
|
7
|
+
## Public Instance Methods
|
|
8
|
+
### `fly(direction, velocity)` <a id="method-i-fly"></a> <a id="fly-instance_method"></a>
|
|
14
9
|
Fly somewhere.
|
|
15
10
|
|
|
16
11
|
Flying is the most critical feature of birds.
|
|
@@ -25,8 +20,6 @@ Flying is the most critical feature of birds.
|
|
|
25
20
|
|
|
26
21
|
fly(:south, 70)
|
|
27
22
|
|
|
28
|
-
|
|
23
|
+
### `speak()` <a id="method-i-speak"></a> <a id="speak-instance_method"></a>
|
|
29
24
|
Produce some noise. -- FIXME: maybe extract this to a base class `Animal`? ++
|
|
30
|
-
|
|
31
|
-
**@yield** ["tweet"]
|
|
32
|
-
|
|
25
|
+
- **@yield** ["tweet"]
|
data/example/rdoc/Duck.md
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
# Class
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
**Extended by:** Animal
|
|
5
|
-
|
|
6
|
-
**Includes:** Waterfowl
|
|
7
|
-
|
|
1
|
+
# Class Duck <a id="class-Duck"></a>
|
|
2
|
+
|
|
3
|
+
**Inherits:** `Object`
|
|
4
|
+
**Extended by:** `Animal`
|
|
5
|
+
**Includes:** `Waterfowl`
|
|
8
6
|
|
|
9
7
|
A duck is a Waterfowl Bird.
|
|
10
8
|
|
|
@@ -19,42 +17,43 @@ Features:
|
|
|
19
17
|
|
|
20
18
|
* swim
|
|
21
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.
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
**@return** [Array<Duck>] list of all rubber ducks
|
|
26
|
+
### `MAX_VELOCITY` <a id="constant-MAX_VELOCITY"></a> <a id="MAX_VELOCITY-constant"></a>
|
|
27
|
+
Maximum velocity for a flying duck.
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
## Attributes
|
|
30
|
+
### `domestic` [RW] <a id="attribute-i-domestic"></a> <a id="domestic-instance_method"></a>
|
|
29
31
|
True for domestic ducks.
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
### `rubber` [R] <a id="attribute-i-rubber"></a> <a id="rubber-instance_method"></a>
|
|
32
34
|
True for rubber ducks.
|
|
33
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
|
|
34
39
|
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
## Public Instance Methods
|
|
41
|
+
### `initialize(domestic, rubber)` <a id="method-i-initialize"></a> <a id="initialize-instance_method"></a>
|
|
37
42
|
Creates a new duck.
|
|
43
|
+
- **@param** `domestic` [Boolean]
|
|
44
|
+
- **@param** `rubber` [Boolean]
|
|
45
|
+
- **@return** [Duck] a new instance of Duck
|
|
38
46
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
**@param** [Boolean]
|
|
42
|
-
|
|
43
|
-
**@return** [Duck] a new instance of Duck
|
|
44
|
-
|
|
45
|
-
## speak() [](#method-i-speak)
|
|
47
|
+
### `speak()` <a id="method-i-speak"></a> <a id="speak-instance_method"></a>
|
|
46
48
|
Duck overrides generic implementation.
|
|
49
|
+
- **@yield** [speech]
|
|
47
50
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
## swim() [](#method-i-swim)
|
|
51
|
+
### `swim()` <a id="method-i-swim"></a> <a id="swim-instance_method"></a>
|
|
51
52
|
Swimming helper.
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
### `useful?()` <a id="method-i-useful-3F"></a> <a id="useful?-instance_method"></a>
|
|
54
55
|
Checks if this duck is a useful one.
|
|
55
56
|
|
|
56
57
|
:call-seq:
|
|
57
58
|
Bird.useful? -> bool
|
|
58
|
-
|
|
59
|
-
**@return** [Boolean]
|
|
60
|
-
|
|
59
|
+
- **@return** [Boolean]
|
data/example/rdoc/Waterfowl.md
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
# Module
|
|
2
|
-
|
|
1
|
+
# Module Waterfowl <a id="module-Waterfowl"></a>
|
|
3
2
|
|
|
4
3
|
A mixin for waterfowl creatures.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
#Instance Methods
|
|
9
|
-
## swim() [](#method-i-swim)
|
|
5
|
+
## Public Instance Methods
|
|
6
|
+
### `swim()` <a id="method-i-swim"></a> <a id="swim-instance_method"></a>
|
|
10
7
|
Swimming helper.
|
|
11
|
-
|
data/example/rdoc/index.csv
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
name,type,path
|
|
2
2
|
Waterfowl,Module,Waterfowl.md
|
|
3
|
-
Waterfowl.DEFAULT_DUCK_VELOCITY,Constant,Waterfowl.md#constant-DEFAULT_DUCK_VELOCITY
|
|
4
|
-
Waterfowl.DEFAULT_SPEED,Constant,Waterfowl.md#constant-DEFAULT_SPEED
|
|
5
3
|
Waterfowl.swim,Method,Waterfowl.md#method-i-swim
|
|
6
4
|
Bird,Class,Bird.md
|
|
7
|
-
Bird.DEFAULT_DUCK_VELOCITY,Constant,Bird.md#constant-DEFAULT_DUCK_VELOCITY
|
|
8
|
-
Bird.DEFAULT_SPEED,Constant,Bird.md#constant-DEFAULT_SPEED
|
|
9
|
-
Bird._fly_impl,Method,Bird.md#method-i-_fly_impl
|
|
10
5
|
Bird.fly,Method,Bird.md#method-i-fly
|
|
11
6
|
Bird.speak,Method,Bird.md#method-i-speak
|
|
12
7
|
Duck,Class,Duck.md
|
|
13
|
-
Duck.
|
|
14
|
-
Duck
|
|
8
|
+
Duck.MAX_VELOCITY,Constant,Duck.md#constant-MAX_VELOCITY
|
|
9
|
+
Duck.@@rubber_ducks,Constant,Duck.md#classvariable--40-40rubber_ducks
|
|
15
10
|
Duck.initialize,Method,Duck.md#method-i-initialize
|
|
16
11
|
Duck.speak,Method,Duck.md#method-i-speak
|
|
17
12
|
Duck.swim,Method,Duck.md#method-i-swim
|
|
18
|
-
Duck.useful?,Method,Duck.md#method-i-useful
|
|
13
|
+
Duck.useful?,Method,Duck.md#method-i-useful-3F
|
|
19
14
|
Duck.rubber_ducks,Method,Duck.md#method-c-rubber_ducks
|
|
20
|
-
domestic,Attribute,Duck.md#attribute-i-domestic
|
|
21
|
-
rubber,Attribute,Duck.md#attribute-i-rubber
|
|
15
|
+
Duck.domestic,Attribute,Duck.md#attribute-i-domestic
|
|
16
|
+
Duck.rubber,Attribute,Duck.md#attribute-i-rubber
|
data/example/yard/Aquatic.md
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
# Module
|
|
2
|
-
|
|
1
|
+
# Module Aquatic <a id="module-Aquatic"></a>
|
|
3
2
|
|
|
4
3
|
A mixin for aquatic creatures.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
#Instance Methods
|
|
9
|
-
## swim() [](#method-i-swim)
|
|
5
|
+
## Public Instance Methods
|
|
6
|
+
### `swim()` <a id="method-i-swim"></a> <a id="swim-instance_method"></a>
|
|
10
7
|
Swim in the water.
|
|
11
|
-
|
|
12
|
-
**@return** [void]
|
|
13
|
-
|
|
8
|
+
- **@return** [void]
|
data/example/yard/Fish.md
CHANGED
|
@@ -1,34 +1,25 @@
|
|
|
1
|
-
# Class
|
|
2
|
-
**Inherits:** Object
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
The base class for all fish.
|
|
1
|
+
# Class Fish <a id="class-Fish"></a>
|
|
6
2
|
|
|
3
|
+
**Inherits:** `Object`
|
|
7
4
|
|
|
5
|
+
The base class for all fish.
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
## Public Instance Methods
|
|
8
|
+
### `make_sound()` <a id="method-i-make_sound"></a> <a id="make_sound-instance_method"></a>
|
|
11
9
|
Make a sound.
|
|
10
|
+
- **@return** [void]
|
|
11
|
+
- **@yield** [sound] The sound produced by the fish
|
|
12
|
+
- **@yieldparam** `sound` [String] The actual sound
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
**@yield** [sound] The sound produced by the fish
|
|
16
|
-
|
|
17
|
-
**@yieldparam** [String] The actual sound
|
|
18
|
-
|
|
19
|
-
## swim(direction, speed) [](#method-i-swim)
|
|
14
|
+
### `swim(direction, speed)` <a id="method-i-swim"></a> <a id="swim-instance_method"></a>
|
|
20
15
|
Swim in a specific direction.
|
|
21
16
|
|
|
22
17
|
Swimming is the most critical feature of fish.
|
|
23
|
-
|
|
24
|
-
**@param** [
|
|
25
|
-
|
|
26
|
-
**@param** [Integer] The speed at which to swim
|
|
27
|
-
|
|
28
|
-
**@return** [Boolean] Whether the swim was successful
|
|
29
|
-
|
|
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
|
|
30
21
|
|
|
31
22
|
**@example**
|
|
32
23
|
```ruby
|
|
33
24
|
swim(:north, 30)
|
|
34
|
-
```
|
|
25
|
+
```
|
data/example/yard/Salmon.md
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
# Class
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
**Includes:** Aquatic
|
|
5
|
-
|
|
1
|
+
# Class Salmon <a id="class-Salmon"></a>
|
|
2
|
+
|
|
3
|
+
**Inherits:** `Fish`
|
|
4
|
+
**Includes:** `Aquatic`
|
|
6
5
|
|
|
7
6
|
A salmon is an Aquatic Fish.
|
|
8
7
|
|
|
@@ -14,47 +13,46 @@ A salmon is an Aquatic Fish.
|
|
|
14
13
|
* **Aquatic**
|
|
15
14
|
* swim (overridden)
|
|
16
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.
|
|
17
23
|
|
|
18
|
-
|
|
19
|
-
## wild_salmon() [](#method-c-wild_salmon)
|
|
20
|
-
**@return** [Array<Salmon>] List of all wild salmon
|
|
21
|
-
|
|
22
|
-
# Attributes
|
|
23
|
-
## farmed[RW] [](#attribute-i-farmed)
|
|
24
|
-
|
|
25
|
-
**@return** [Boolean] True for farmed salmon
|
|
26
|
-
|
|
27
|
-
## wild[RW] [](#attribute-i-wild)
|
|
28
|
-
|
|
29
|
-
**@return** [Boolean] True for wild salmon
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
#Instance Methods
|
|
33
|
-
## initialize(farmed, wild) [](#method-i-initialize)
|
|
34
|
-
Creates a new salmon.
|
|
24
|
+
Use for conservation efforts.
|
|
35
25
|
|
|
36
|
-
|
|
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
|
|
37
30
|
|
|
38
|
-
|
|
31
|
+
#### `wild` [R] <a id="attribute-i-wild"></a> <a id="wild-instance_method"></a>
|
|
32
|
+
- **@return** [Boolean] True for wild salmon
|
|
39
33
|
|
|
40
|
-
|
|
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
|
|
41
37
|
|
|
42
|
-
##
|
|
38
|
+
## Public Instance Methods
|
|
39
|
+
### Fish overrides
|
|
40
|
+
#### `make_sound()` <a id="method-i-make_sound"></a> <a id="make_sound-instance_method"></a>
|
|
43
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
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
**@yield** [sound] The sound produced by the salmon
|
|
48
|
-
|
|
49
|
-
**@yieldparam** [String] The actual sound
|
|
50
|
-
|
|
51
|
-
## sustainable?() [](#method-i-sustainable?)
|
|
52
|
+
#### `sustainable?()` <a id="method-i-sustainable-3F"></a> <a id="sustainable?-instance_method"></a>
|
|
52
53
|
Checks if this salmon is sustainable.
|
|
54
|
+
- **@return** [Boolean] Whether the salmon is sustainable
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
## swim() [](#method-i-swim)
|
|
56
|
+
#### `swim()` <a id="method-i-swim"></a> <a id="swim-instance_method"></a>
|
|
57
57
|
Swim in the water.
|
|
58
|
-
|
|
59
|
-
**@return** [void]
|
|
60
|
-
|
|
58
|
+
- **@return** [void]
|
data/example/yard/index.csv
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
name,type,path
|
|
2
2
|
Aquatic,Module,Aquatic.md
|
|
3
|
-
Aquatic.DEFAULT_SALMON_SPEED,Constant,Aquatic.md#constant-DEFAULT_SALMON_SPEED
|
|
4
|
-
Aquatic.MAX_DEPTH,Constant,Aquatic.md#constant-MAX_DEPTH
|
|
5
3
|
Aquatic.swim,Method,Aquatic.md#method-i-swim
|
|
6
4
|
Fish,Class,Fish.md
|
|
7
|
-
Fish.DEFAULT_SALMON_SPEED,Constant,Fish.md#constant-DEFAULT_SALMON_SPEED
|
|
8
|
-
Fish.MAX_DEPTH,Constant,Fish.md#constant-MAX_DEPTH
|
|
9
5
|
Fish.make_sound,Method,Fish.md#method-i-make_sound
|
|
10
6
|
Fish.swim,Method,Fish.md#method-i-swim
|
|
11
7
|
Salmon,Class,Salmon.md
|
|
12
|
-
Salmon.
|
|
13
|
-
Salmon
|
|
8
|
+
Salmon.MAX_SPEED,Constant,Salmon.md#constant-MAX_SPEED
|
|
9
|
+
Salmon.@@wild_salmon,Constant,Salmon.md#classvariable--40-40wild_salmon
|
|
14
10
|
Salmon.initialize,Method,Salmon.md#method-i-initialize
|
|
15
11
|
Salmon.make_sound,Method,Salmon.md#method-i-make_sound
|
|
16
|
-
Salmon.sustainable?,Method,Salmon.md#method-i-sustainable
|
|
12
|
+
Salmon.sustainable?,Method,Salmon.md#method-i-sustainable-3F
|
|
17
13
|
Salmon.swim,Method,Salmon.md#method-i-swim
|
|
18
14
|
Salmon.wild_salmon,Method,Salmon.md#method-c-wild_salmon
|
|
19
|
-
farmed,Attribute,Salmon.md#attribute-i-farmed
|
|
20
|
-
wild,Attribute,Salmon.md#attribute-i-wild
|
|
15
|
+
Salmon.farmed,Attribute,Salmon.md#attribute-i-farmed
|
|
16
|
+
Salmon.wild,Attribute,Salmon.md#attribute-i-wild
|