Skip to content

Commit

Permalink
Adding Yard Tags into a template (#20)
Browse files Browse the repository at this point in the history
Yard object have tags linked to them

https://rubydoc.info/gems/yard/file/docs/TagsArch.md

These tags contain a lot of useful information - returned type, accepted attributes, deprecation notices, links to more documentation and etc. 

It's a pity that yard-markdown doesn't include that information, this is a PR that resolves that. I'm going through all possible tags that CodeObject has associated and adding them to output.

## Technical part
I added `example_yard.rb` file that we can use to generate yard example, that has these yard tags. `example.rb` go renamed to `example_rdoc.rb` to align with this naming.

---------

Co-authored-by: Stanislav (Stas) Katkov <github@skatkov.com>
  • Loading branch information
skatkov and Stanislav (Stas) Katkov authored Dec 16, 2024
1 parent 30ae843 commit 90288af
Show file tree
Hide file tree
Showing 13 changed files with 343 additions and 137 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
yard-markdown (0.3.6)
yard-markdown (0.4)
csv
yard

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ 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.

`yardoc example.rb` -> outputs everything into example/ folder.
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.
20 changes: 20 additions & 0 deletions example/Aquatic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Module: Aquatic

**Defined in:** example_yard.rb

A mixin for aquatic creatures.

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

**return** [void]


# Constants
## DEFAULT_SALMON_SPEED [](#constant-DEFAULT_SALMON_SPEED)


## MAX_DEPTH [](#constant-MAX_DEPTH)


38 changes: 0 additions & 38 deletions example/Bird.md

This file was deleted.

57 changes: 0 additions & 57 deletions example/Duck.md

This file was deleted.

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

**Defined in:** example_yard.rb

The base class for all fish.

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

**return** [void]
**yield** [sound] The sound produced by the fish
**yieldparam** [String] The actual sound
## swim(direction, speed) [](#method-i-swim)
Swim in a specific direction.

Swimming is the most critical feature of fish.

**param** [Symbol, String] The direction to swim
**param** [Integer] The speed at which to swim
**return** [Boolean] Whether the swim was successful

**example**
```ruby
swim(:north, 30)
```

# Constants
## DEFAULT_SALMON_SPEED [](#constant-DEFAULT_SALMON_SPEED)


## MAX_DEPTH [](#constant-MAX_DEPTH)


58 changes: 58 additions & 0 deletions example/Salmon.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Class: Salmon
**Inherits:** Fish

**Includes:** Aquatic

**Defined in:** example_yard.rb

A salmon is an Aquatic Fish.

## Features

* **Fish**
* make_sound
* swim
* **Aquatic**
* swim (overridden)

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

**param** [Boolean] Whether the salmon is farmed
**param** [Boolean] Whether the salmon is wild
**return** [Salmon] a new instance of Salmon
## make_sound() [](#method-i-make_sound)
Salmon overrides generic implementation.

**return** [void]
**yield** [sound] The sound produced by the salmon
**yieldparam** [String] The actual sound
## sustainable?() [](#method-i-sustainable?)
Checks if this salmon is sustainable.

**return** [Boolean] Whether the salmon is sustainable
## swim() [](#method-i-swim)
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

# Constants
## DEFAULT_SALMON_SPEED [](#constant-DEFAULT_SALMON_SPEED)


## MAX_DEPTH [](#constant-MAX_DEPTH)


19 changes: 0 additions & 19 deletions example/Waterfowl.md

This file was deleted.

39 changes: 19 additions & 20 deletions example/index.csv
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
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
Aquatic,Module,Aquatic.md
Aquatic.DEFAULT_SALMON_SPEED,Constant,Aquatic.md#constant-DEFAULT_SALMON_SPEED
Aquatic.MAX_DEPTH,Constant,Aquatic.md#constant-MAX_DEPTH
Aquatic.swim,Method,Aquatic.md#method-i-swim
Fish,Class,Fish.md
Fish.DEFAULT_SALMON_SPEED,Constant,Fish.md#constant-DEFAULT_SALMON_SPEED
Fish.MAX_DEPTH,Constant,Fish.md#constant-MAX_DEPTH
Fish.make_sound,Method,Fish.md#method-i-make_sound
Fish.swim,Method,Fish.md#method-i-swim
Salmon,Class,Salmon.md
Salmon.DEFAULT_SALMON_SPEED,Constant,Salmon.md#constant-DEFAULT_SALMON_SPEED
Salmon.MAX_DEPTH,Constant,Salmon.md#constant-MAX_DEPTH
Salmon.initialize,Method,Salmon.md#method-i-initialize
Salmon.make_sound,Method,Salmon.md#method-i-make_sound
Salmon.sustainable?,Method,Salmon.md#method-i-sustainable?
Salmon.swim,Method,Salmon.md#method-i-swim
Salmon.wild_salmon,Method,Salmon.md#method-c-wild_salmon
farmed,Attribute,Salmon.md#attribute-i-farmed
wild,Attribute,Salmon.md#attribute-i-wild
File renamed without changes.
Loading

0 comments on commit 90288af

Please sign in to comment.