yard-markdown 0.4.2 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1c4368b70ec91bff1a8f9bf1aaefc79578a34251b879d800f59c466b611dd5a
4
- data.tar.gz: 917397c1e9df43930d699fe0258dd124260b5168222fc28c5d0a84ded9f21d1e
3
+ metadata.gz: b3bf19f52aa053b77b3bdfa88b447e7db00c746135a47b77e81e2a08ceb4367a
4
+ data.tar.gz: 8a141a935807d808abec2fa5f2e6d690cfb0c9ec70e89fc0709e7a39f60fb697
5
5
  SHA512:
6
- metadata.gz: 932de039cf4fbd5fadd8bf012f7663f6cda4b270100b7930a28d6e182949628b727705a47893daebb5b39cf4c630f5c3a4e2f7a8ff3e7609e2aa2a43172db00f
7
- data.tar.gz: 1d8191d7f0e0db8eea07842025a3dea14a924a67924464df8053ad00d337c9efb71ca832cafd3b83c2e6d150fa897c3ca08527744e86e043d4f3bd059db54898
6
+ metadata.gz: d53e7cd3f76693122642ec6196bf8e49f11b2b5457ebb0942be702e33efe25348141580188bb00dfc9846b5766ee412e14c9c059e119358ab79c1a0f828e30c1
7
+ data.tar.gz: 02d47f00d6408f1d645ac0d46936e2734c89f1c853632d88b4217d0bb2985993ddcd6d99dbe38de18ee40a858b1441a35b44c3ce7e6ea2161b4a6705e2dcb540
data/.yardopts CHANGED
@@ -1,8 +1 @@
1
1
  --load ./lib/yard-markdown.rb
2
- --format markdown
3
- --markup markdown
4
- --output-dir example
5
- --private
6
- --protected
7
- -
8
- example.rb
data/README.md CHANGED
@@ -1,11 +1,15 @@
1
1
  # Yard::Markdown
2
2
 
3
- Yard plugin to generate markdown documentation
3
+ Yard plugin to output markdown documentation.
4
+
5
+ ## Motivation
6
+ Markdown has become the de-facto documentation standard. I heavily rely on Obsidian to render my storage of markdown notes. But markdown is used not just for scribbles, supported is far and wide. We can render markdown file on any device, probably even on thermometer with a screen. But also everyone knows enough markdown to be dangerous (or productive).
7
+ It's a pitty that rdoc and yard can't output a proper markdown file. I would like to change that.
4
8
 
5
9
  ## Goals:
6
10
  - Compatible with Github Flavored Markdown
11
+ - Produce .csv index file
7
12
  - Mimick yard html layout where it makes sense to maintain familiarity
8
- - Produce .csv index file alonside markdown documentation to act as file index
9
13
 
10
14
  ## Usage
11
15
  Yard doesn't load plugin by default, so you need to load plugin through `~/.yard/config`:
@@ -24,14 +28,21 @@ gem install yard-markdown
24
28
 
25
29
  Run `yardoc --format=markdown` to generate markdown documentation.
26
30
 
27
- ## Backstory
28
- This is a successor to [rdoc-mardown gem](https://github.com/skatkov/rdoc-markdown/tree/main/example). These docsets are used in [POSH TUI](https://poshtui.com).
31
+ ## Note on RDoc support
32
+ It seems important to note, that yard claims to have support for RDoc. That support is certainly present, but output for rdoc is dramatically different. A lot of useful information seems lost in the process.
33
+
34
+ If you know how to improve that, please get in touch or submit a patch.
35
+
36
+ So in meantime, there is work going on a competing gem for RDoc and it's called [rdoc-mardown gem](https://github.com/skatkov/rdoc-markdown/).
37
+
38
+ ## Note on index.csv file
39
+ This gem emits index of all markdown files in a index.csv file.
40
+
41
+ There are decent tools that offer search through structured plain-text files. But my expectation is that nobody will use CSV as an actual search index, but rather import it into something that performs this function better.
42
+
43
+ In my personal use-case, I use SQLite. All other databases seem to have a good support for CSV imports.
29
44
 
30
45
  ## Testing
31
46
  Unit tests can't really test this gem properly. So it's semi-manual process of making changes and reviewing output.
32
47
 
33
- ### Testing Rdoc conversion to markdown:
34
- `yardoc example_rdoc.rb` -> outputs everything into example/ folder.
35
-
36
- ### Testing Yard conversion to markdown:
37
- `yardoc example_yard.rb` -> outputs everything into example/ folder.
48
+ Easiest way to test is to run `rake generate_example` and check output in `example` directory.
data/Rakefile CHANGED
@@ -10,3 +10,22 @@ Rake::TestTask.new(:test) do |t|
10
10
  end
11
11
 
12
12
  task default: %i[test stree:write]
13
+
14
+
15
+ namespace :examples do
16
+ desc "Generate basic example documentation using yard-markdown plugin"
17
+ task :generate do
18
+ Rake::Task["examples:yard"].invoke
19
+ Rake::Task["examples:rdoc"].invoke
20
+ end
21
+
22
+ desc "Generate example documentation for code annotated with yard"
23
+ task :yard do
24
+ sh "yardoc --output-dir example/yard example_yard.rb"
25
+ end
26
+
27
+ desc "Generate example documentation for code annotated with rdoc"
28
+ task :rdoc do
29
+ sh "yardoc --output-dir example/rdoc example_rdoc.rb"
30
+ end
31
+ end
@@ -0,0 +1,32 @@
1
+ # Class: Bird
2
+ **Inherits:** Object
3
+
4
+
5
+ The base class for all birds.
6
+
7
+
8
+
9
+ #Instance Methods
10
+ ## _fly_impl(_direction, _velocity) [](#method-i-_fly_impl)
11
+ :nodoc:
12
+
13
+ ## fly(direction, velocity) [](#method-i-fly)
14
+ Fly somewhere.
15
+
16
+ Flying is the most critical feature of birds.
17
+
18
+ :args: direction, velocity
19
+
20
+ :call-seq:
21
+ Bird.fly(symbol, number) -> bool
22
+ Bird.fly(string, number) -> bool
23
+
24
+ # Example
25
+
26
+ fly(:south, 70)
27
+
28
+ ## speak() [](#method-i-speak)
29
+ Produce some noise. -- FIXME: maybe extract this to a base class `Animal`? ++
30
+
31
+ **@yield** ["tweet"]
32
+
@@ -0,0 +1,60 @@
1
+ # Class: Duck
2
+ **Inherits:** Object
3
+
4
+ **Extended by:** Animal
5
+
6
+ **Includes:** Waterfowl
7
+
8
+
9
+ A duck is a Waterfowl Bird.
10
+
11
+ Features:
12
+
13
+ bird::
14
+
15
+ * speak
16
+ * fly
17
+
18
+ waterfowl::
19
+
20
+ * swim
21
+
22
+
23
+ # Class Methods
24
+ ## rubber_ducks() [](#method-c-rubber_ducks)
25
+ **@return** [Array<Duck>] list of all rubber ducks
26
+
27
+ # Attributes
28
+ ## domestic[RW] [](#attribute-i-domestic)
29
+ True for domestic ducks.
30
+
31
+ ## rubber[RW] [](#attribute-i-rubber)
32
+ True for rubber ducks.
33
+
34
+
35
+ #Instance Methods
36
+ ## initialize(domestic, rubber) [](#method-i-initialize)
37
+ Creates a new duck.
38
+
39
+ **@param** [Boolean]
40
+
41
+ **@param** [Boolean]
42
+
43
+ **@return** [Duck] a new instance of Duck
44
+
45
+ ## speak() [](#method-i-speak)
46
+ Duck overrides generic implementation.
47
+
48
+ **@yield** [speech]
49
+
50
+ ## swim() [](#method-i-swim)
51
+ Swimming helper.
52
+
53
+ ## useful?() [](#method-i-useful?)
54
+ Checks if this duck is a useful one.
55
+
56
+ :call-seq:
57
+ Bird.useful? -> bool
58
+
59
+ **@return** [Boolean]
60
+
@@ -0,0 +1,11 @@
1
+ # Module: Waterfowl
2
+
3
+
4
+ A mixin for waterfowl creatures.
5
+
6
+
7
+
8
+ #Instance Methods
9
+ ## swim() [](#method-i-swim)
10
+ Swimming helper.
11
+
@@ -0,0 +1,21 @@
1
+ name,type,path
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
+ Waterfowl.swim,Method,Waterfowl.md#method-i-swim
6
+ 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
+ Bird.fly,Method,Bird.md#method-i-fly
11
+ Bird.speak,Method,Bird.md#method-i-speak
12
+ Duck,Class,Duck.md
13
+ Duck.DEFAULT_DUCK_VELOCITY,Constant,Duck.md#constant-DEFAULT_DUCK_VELOCITY
14
+ Duck.DEFAULT_SPEED,Constant,Duck.md#constant-DEFAULT_SPEED
15
+ Duck.initialize,Method,Duck.md#method-i-initialize
16
+ Duck.speak,Method,Duck.md#method-i-speak
17
+ Duck.swim,Method,Duck.md#method-i-swim
18
+ Duck.useful?,Method,Duck.md#method-i-useful?
19
+ 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
@@ -0,0 +1,13 @@
1
+ # Module: Aquatic
2
+
3
+
4
+ A mixin for aquatic creatures.
5
+
6
+
7
+
8
+ #Instance Methods
9
+ ## swim() [](#method-i-swim)
10
+ Swim in the water.
11
+
12
+ **@return** [void]
13
+
@@ -1,16 +1,12 @@
1
1
  # Class: Fish
2
2
  **Inherits:** Object
3
3
 
4
- **Defined in:** example_yard.rb
5
4
 
6
5
  The base class for all fish.
7
6
 
8
7
 
9
- | Constants | Default Value |
10
- | --- | --- |
11
- | [DEFAULT_SALMON_SPEED](#constant-DEFAULT_SALMON_SPEED) | 20 |
12
- | [MAX_DEPTH](#constant-MAX_DEPTH) | 500 |
13
- # Public Instance Methods
8
+
9
+ #Instance Methods
14
10
  ## make_sound() [](#method-i-make_sound)
15
11
  Make a sound.
16
12
 
@@ -35,4 +31,4 @@ Swimming is the most critical feature of fish.
35
31
  **@example**
36
32
  ```ruby
37
33
  swim(:north, 30)
38
- ```
34
+ ```
@@ -3,7 +3,6 @@
3
3
 
4
4
  **Includes:** Aquatic
5
5
 
6
- **Defined in:** example_yard.rb
7
6
 
8
7
  A salmon is an Aquatic Fish.
9
8
 
@@ -16,11 +15,21 @@ A salmon is an Aquatic Fish.
16
15
  * swim (overridden)
17
16
 
18
17
 
19
- | Constants | Default Value |
20
- | --- | --- |
21
- | [DEFAULT_SALMON_SPEED](#constant-DEFAULT_SALMON_SPEED) | 20 |
22
- | [MAX_DEPTH](#constant-MAX_DEPTH) | 500 |
23
- # Public Instance Methods
18
+ # Class Methods
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
24
33
  ## initialize(farmed, wild) [](#method-i-initialize)
25
34
  Creates a new salmon.
26
35
 
@@ -49,17 +58,3 @@ Swim in the water.
49
58
 
50
59
  **@return** [void]
51
60
 
52
-
53
- # Public Class Methods
54
- ## wild_salmon() [](#method-c-wild_salmon)
55
- **@return** [Array<Salmon>] List of all wild salmon
56
-
57
- # Attributes
58
- ## farmed[RW] [](#attribute-i-farmed)
59
-
60
- **@return** [Boolean] True for farmed salmon
61
-
62
- ## wild[RW] [](#attribute-i-wild)
63
-
64
- **@return** [Boolean] True for wild salmon
65
-
@@ -104,33 +104,13 @@ def serialize(object)
104
104
  <% if (mix = run_verifier(object.mixins(scope))).size > 0 %>
105
105
  **<%= name %>:** <%= mix.sort_by {|o| o.path }.join(", ") %>
106
106
  <% end %><% end %>
107
- <% unless object.root? %>
108
- **Defined in:** <%= object.file ? object.file.sub(Dir.pwd, "") : "(unknown)" %>
109
- <% end %>
110
107
 
111
108
  <%= rdoc_to_md object.docstring %>
112
109
 
113
110
  <%= render_tags object %>
114
111
 
115
- <% if constant_listing.size > 0 %>
116
- <% groups(constant_listing, "Constants") do |list, name| %>
117
- <% if list.size > 0 %>
118
- | <%= name %> | Default Value |
119
- | --- | --- |
120
- <% list.each do |cnst| %>
121
- | [<%= cnst.name %>](#<%=aref(cnst)%>) | <%= cnst.value %> |
122
- <% end %><% end %><% end %><% end %>
123
- <% if (insmeths = public_instance_methods(object)).size > 0 %>
124
- # Public Instance Methods
125
- <% insmeths.each do |item| %>
126
- ## <%= item.name(false) %>(<%= item.parameters.map {|p| p.join("") }.join(", ")%>) [](#<%=aref(item)%>)
127
- <%= rdoc_to_md item.docstring %>
128
-
129
- <%= render_tags item %>
130
- <% end %><% end %>
131
-
132
112
  <% if (pubmeths = public_class_methods(object)).size > 0 %>
133
- # Public Class Methods
113
+ # Class Methods
134
114
  <% pubmeths.each do |item| %>
135
115
  ## <%= item.name(false) %>(<%= item.parameters.map {|p| p.join(" ") }.join(", ") %>) [](#<%=aref(item)%>)
136
116
  <%= rdoc_to_md item.docstring %>
@@ -142,6 +122,15 @@ def serialize(object)
142
122
  ## <%= item.name %><%= item.reader? ? "[RW]" : "[R]" %> [](#<%=aref(item)%>)
143
123
  <%= rdoc_to_md item.docstring %>
144
124
 
125
+ <%= render_tags item %>
126
+ <% end %><% end %>
127
+
128
+ <% if (insmeths = public_instance_methods(object)).size > 0 %>
129
+ # Instance Methods
130
+ <% insmeths.each do |item| %>
131
+ ## <%= item.name(false) %>(<%= item.parameters.map {|p| p.join("") }.join(", ")%>) [](#<%=aref(item)%>)
132
+ <%= rdoc_to_md item.docstring %>
133
+
145
134
  <%= render_tags item %>
146
135
  <% end %><% end %>',
147
136
  trim_mode: "<>",
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislav (Stas) Katkov
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2024-12-16 00:00:00.000000000 Z
10
+ date: 2024-12-28 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: yard
@@ -51,10 +50,14 @@ files:
51
50
  - LICENSE.txt
52
51
  - README.md
53
52
  - Rakefile
54
- - example/Aquatic.md
55
- - example/Fish.md
56
- - example/Salmon.md
57
- - example/index.csv
53
+ - example/rdoc/Bird.md
54
+ - example/rdoc/Duck.md
55
+ - example/rdoc/Waterfowl.md
56
+ - example/rdoc/index.csv
57
+ - example/yard/Aquatic.md
58
+ - example/yard/Fish.md
59
+ - example/yard/Salmon.md
60
+ - example/yard/index.csv
58
61
  - example_rdoc.rb
59
62
  - example_yard.rb
60
63
  - lib/yard-markdown.rb
@@ -66,7 +69,6 @@ licenses:
66
69
  metadata:
67
70
  homepage_uri: https://poshtui.com
68
71
  source_code_uri: https://github.com/skatkov/yard-markdown
69
- post_install_message:
70
72
  rdoc_options: []
71
73
  require_paths:
72
74
  - lib
@@ -81,8 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
83
  - !ruby/object:Gem::Version
82
84
  version: '0'
83
85
  requirements: []
84
- rubygems_version: 3.5.9
85
- signing_key:
86
+ rubygems_version: 3.6.2
86
87
  specification_version: 4
87
88
  summary: yard plugin to generate markdown documentation
88
89
  test_files: []
data/example/Aquatic.md DELETED
@@ -1,18 +0,0 @@
1
- # Module: Aquatic
2
-
3
- **Defined in:** example_yard.rb
4
-
5
- A mixin for aquatic creatures.
6
-
7
-
8
- | Constants | Default Value |
9
- | --- | --- |
10
- | [DEFAULT_SALMON_SPEED](#constant-DEFAULT_SALMON_SPEED) | 20 |
11
- | [MAX_DEPTH](#constant-MAX_DEPTH) | 500 |
12
- # Public Instance Methods
13
- ## swim() [](#method-i-swim)
14
- Swim in the water.
15
-
16
- **@return** [void]
17
-
18
-
File without changes