Skip to content

Commit

Permalink
Generate all examples with a single rake command (#23)
Browse files Browse the repository at this point in the history
Co-authored-by: Stanislav (Stas) Katkov <github@skatkov.com>
  • Loading branch information
skatkov and Stanislav (Stas) Katkov authored Dec 27, 2024
1 parent 9edafa6 commit f945f8e
Show file tree
Hide file tree
Showing 12 changed files with 163 additions and 54 deletions.
4 changes: 0 additions & 4 deletions .yardopts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
--load ./lib/yard-markdown.rb
--format markdown
--markup markdown
--output-dir example
--private
--protected
-
example.rb
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,4 @@ This is a successor to [rdoc-mardown gem](https://github.com/skatkov/rdoc-markdo
## Testing
Unit tests can't really test this gem properly. So it's semi-manual process of making changes and reviewing output.

### Testing Rdoc conversion to markdown:
`yardoc example_rdoc.rb` -> outputs everything into example/ folder.

### Testing Yard conversion to markdown:
`yardoc example_yard.rb` -> outputs everything into example/ folder.
Easiest way to test is to run `rake generate_example` and check output in `example` directory.
7 changes: 7 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ Rake::TestTask.new(:test) do |t|
end

task default: %i[test stree:write]


desc "Generate example/rdoc/ documentation using yard-markdown plugin"
task :generate_example do
sh "yardoc --output-dir example/rdoc example_rdoc.rb"
sh "yardoc --output-dir example/yard example_yard.rb"
end
18 changes: 0 additions & 18 deletions example/Aquatic.md

This file was deleted.

32 changes: 32 additions & 0 deletions example/rdoc/Bird.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Class: Bird
**Inherits:** Object


The base class for all birds.



#Instance Methods
## _fly_impl(_direction, _velocity) [](#method-i-_fly_impl)
:nodoc:

## fly(direction, velocity) [](#method-i-fly)
Fly somewhere.

Flying is the most critical feature of birds.

:args: direction, velocity

:call-seq:
Bird.fly(symbol, number) -> bool
Bird.fly(string, number) -> bool

# Example

fly(:south, 70)

## speak() [](#method-i-speak)
Produce some noise. -- FIXME: maybe extract this to a base class `Animal`? ++

**@yield** ["tweet"]

60 changes: 60 additions & 0 deletions example/rdoc/Duck.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Class: Duck
**Inherits:** Object

**Extended by:** Animal

**Includes:** Waterfowl


A duck is a Waterfowl Bird.

Features:

bird::

* speak
* fly

waterfowl::

* swim


# Class Methods
## rubber_ducks() [](#method-c-rubber_ducks)
**@return** [Array<Duck>] list of all rubber ducks

# Attributes
## domestic[RW] [](#attribute-i-domestic)
True for domestic ducks.

## rubber[RW] [](#attribute-i-rubber)
True for rubber ducks.


#Instance Methods
## initialize(domestic, rubber) [](#method-i-initialize)
Creates a new duck.

**@param** [Boolean]

**@param** [Boolean]

**@return** [Duck] a new instance of Duck

## speak() [](#method-i-speak)
Duck overrides generic implementation.

**@yield** [speech]

## swim() [](#method-i-swim)
Swimming helper.

## useful?() [](#method-i-useful?)
Checks if this duck is a useful one.

:call-seq:
Bird.useful? -> bool

**@return** [Boolean]

11 changes: 11 additions & 0 deletions example/rdoc/Waterfowl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Module: Waterfowl


A mixin for waterfowl creatures.



#Instance Methods
## swim() [](#method-i-swim)
Swimming helper.

21 changes: 21 additions & 0 deletions example/rdoc/index.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name,type,path
Waterfowl,Module,Waterfowl.md
Waterfowl.DEFAULT_DUCK_VELOCITY,Constant,Waterfowl.md#constant-DEFAULT_DUCK_VELOCITY
Waterfowl.DEFAULT_SPEED,Constant,Waterfowl.md#constant-DEFAULT_SPEED
Waterfowl.swim,Method,Waterfowl.md#method-i-swim
Bird,Class,Bird.md
Bird.DEFAULT_DUCK_VELOCITY,Constant,Bird.md#constant-DEFAULT_DUCK_VELOCITY
Bird.DEFAULT_SPEED,Constant,Bird.md#constant-DEFAULT_SPEED
Bird._fly_impl,Method,Bird.md#method-i-_fly_impl
Bird.fly,Method,Bird.md#method-i-fly
Bird.speak,Method,Bird.md#method-i-speak
Duck,Class,Duck.md
Duck.DEFAULT_DUCK_VELOCITY,Constant,Duck.md#constant-DEFAULT_DUCK_VELOCITY
Duck.DEFAULT_SPEED,Constant,Duck.md#constant-DEFAULT_SPEED
Duck.initialize,Method,Duck.md#method-i-initialize
Duck.speak,Method,Duck.md#method-i-speak
Duck.swim,Method,Duck.md#method-i-swim
Duck.useful?,Method,Duck.md#method-i-useful?
Duck.rubber_ducks,Method,Duck.md#method-c-rubber_ducks
domestic,Attribute,Duck.md#attribute-i-domestic
rubber,Attribute,Duck.md#attribute-i-rubber
13 changes: 13 additions & 0 deletions example/yard/Aquatic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Module: Aquatic


A mixin for aquatic creatures.



#Instance Methods
## swim() [](#method-i-swim)
Swim in the water.

**@return** [void]

10 changes: 3 additions & 7 deletions example/Fish.md → example/yard/Fish.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# Class: Fish
**Inherits:** Object

**Defined in:** example_yard.rb

The base class for all fish.


| Constants | Default Value |
| --- | --- |
| [DEFAULT_SALMON_SPEED](#constant-DEFAULT_SALMON_SPEED) | 20 |
| [MAX_DEPTH](#constant-MAX_DEPTH) | 500 |
# Public Instance Methods

#Instance Methods
## make_sound() [](#method-i-make_sound)
Make a sound.

Expand All @@ -35,4 +31,4 @@ Swimming is the most critical feature of fish.
**@example**
```ruby
swim(:north, 30)
```
```
35 changes: 15 additions & 20 deletions example/Salmon.md → example/yard/Salmon.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

**Includes:** Aquatic

**Defined in:** example_yard.rb

A salmon is an Aquatic Fish.

Expand All @@ -16,11 +15,21 @@ A salmon is an Aquatic Fish.
* swim (overridden)


| Constants | Default Value |
| --- | --- |
| [DEFAULT_SALMON_SPEED](#constant-DEFAULT_SALMON_SPEED) | 20 |
| [MAX_DEPTH](#constant-MAX_DEPTH) | 500 |
# Public Instance Methods
# Class Methods
## wild_salmon() [](#method-c-wild_salmon)
**@return** [Array<Salmon>] List of all wild salmon

# Attributes
## farmed[RW] [](#attribute-i-farmed)

**@return** [Boolean] True for farmed salmon

## wild[RW] [](#attribute-i-wild)

**@return** [Boolean] True for wild salmon


#Instance Methods
## initialize(farmed, wild) [](#method-i-initialize)
Creates a new salmon.

Expand Down Expand Up @@ -49,17 +58,3 @@ Swim in the water.

**@return** [void]


# Public Class Methods
## wild_salmon() [](#method-c-wild_salmon)
**@return** [Array<Salmon>] List of all wild salmon

# Attributes
## farmed[RW] [](#attribute-i-farmed)

**@return** [Boolean] True for farmed salmon

## wild[RW] [](#attribute-i-wild)

**@return** [Boolean] True for wild salmon

File renamed without changes.

0 comments on commit f945f8e

Please sign in to comment.