yard-markdown 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -1
- data/README.md +1 -1
- data/example/Bird.md +1 -1
- data/example/Duck.md +1 -1
- data/example/Waterfowl.md +1 -1
- data/example/index.csv +18 -0
- data/lib/yard-markdown.rb +1 -6
- data/templates/default/fulldoc/markdown/setup.rb +45 -3
- metadata +5 -5
- data/lib/yard/markdown/version.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c561fb4adb1a813dee7cc4f1793ecee708627115f85aab396933822e4886cb0
|
4
|
+
data.tar.gz: 17e36c633008becd1b8ead5af645e58182d5be5959736cfb34280f4c7a077848
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c472b473610259d5067deceacbdc08ba3e2f68b00e07947d9b0aa55657623d28fccaf65237f213fc01f03b1f5d4674094fdfbe825f1829d17dadcc6c6efec69
|
7
|
+
data.tar.gz: abd879a66a9334c633120f9a1ee486cffa42dd4d08b184fe321bbea27a6f002a626b9adb76c46efc5637a3d489e3f365bdbea6b75f9901b3a22f8694bd73fbcc
|
data/.yardopts
CHANGED
data/README.md
CHANGED
@@ -14,7 +14,7 @@ gem 'yard-markdown'
|
|
14
14
|
```
|
15
15
|
And run `bundle install`
|
16
16
|
|
17
|
-
Run yardoc with `--format=markdown`
|
17
|
+
Run yardoc with `--format=markdown --plugin=markdown` parameters.
|
18
18
|
|
19
19
|
## Backstory
|
20
20
|
Successor to rdoc-mardown gem that was authored by me. So there is a lot of similarities between two - [example](https://github.com/skatkov/rdoc-markdown/tree/main/example).
|
data/example/Bird.md
CHANGED
data/example/Duck.md
CHANGED
data/example/Waterfowl.md
CHANGED
data/example/index.csv
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
name,type,path
|
2
|
+
Waterfowl,Module,Waterfowl.md
|
3
|
+
DEFAULT_DUCK_VELOCITY,Constant,Waterfowl.md#constant-DEFAULT_DUCK_VELOCITY
|
4
|
+
swim,Method,Waterfowl.md#method-i-swim
|
5
|
+
Bird,Class,Bird.md
|
6
|
+
DEFAULT_DUCK_VELOCITY,Constant,Bird.md#constant-DEFAULT_DUCK_VELOCITY
|
7
|
+
_fly_impl,Method,Bird.md#method-i-_fly_impl
|
8
|
+
fly,Method,Bird.md#method-i-fly
|
9
|
+
speak,Method,Bird.md#method-i-speak
|
10
|
+
Duck,Class,Duck.md
|
11
|
+
DEFAULT_DUCK_VELOCITY,Constant,Duck.md#constant-DEFAULT_DUCK_VELOCITY
|
12
|
+
initialize,Method,Duck.md#method-i-initialize
|
13
|
+
speak,Method,Duck.md#method-i-speak
|
14
|
+
swim,Method,Duck.md#method-i-swim
|
15
|
+
useful?,Method,Duck.md#method-i-useful?
|
16
|
+
rubber_ducks,Method,Duck.md#method-c-rubber_ducks
|
17
|
+
domestic,Attribute,Duck.md#attribute-i-domestic
|
18
|
+
rubber,Attribute,Duck.md#attribute-i-rubber
|
data/lib/yard-markdown.rb
CHANGED
@@ -1,15 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
dir = File.dirname(__FILE__)
|
4
|
-
$LOAD_PATH.unshift dir unless $LOAD_PATH.include?(dir)
|
5
|
-
|
6
3
|
require "yard"
|
7
|
-
require_relative "markdown/version"
|
8
4
|
|
9
5
|
module YARD
|
10
6
|
module Markdown
|
11
7
|
end
|
12
8
|
end
|
13
9
|
|
14
|
-
|
15
|
-
YARD::Templates::Engine.register_template_path dir + '/../templates'
|
10
|
+
YARD::Templates::Engine.register_template_path File.dirname(__FILE__) + '/../templates'
|
@@ -30,6 +30,45 @@ def init
|
|
30
30
|
log.backtrace(e)
|
31
31
|
end
|
32
32
|
end
|
33
|
+
|
34
|
+
serialize_index(objects)
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
require 'csv'
|
39
|
+
|
40
|
+
def serialize_index(objects)
|
41
|
+
filepath = "#{options.serializer.basepath}/index.csv"
|
42
|
+
|
43
|
+
CSV.open(filepath, 'wb') do |csv|
|
44
|
+
csv << %w[name type path]
|
45
|
+
|
46
|
+
objects.each do |object|
|
47
|
+
next if object.name == :root
|
48
|
+
|
49
|
+
if object.type == :class
|
50
|
+
csv << [object.name, 'Class', options.serializer.serialized_path(object)]
|
51
|
+
elsif object.type == :module
|
52
|
+
csv << [object.name, 'Module', options.serializer.serialized_path(object)]
|
53
|
+
end
|
54
|
+
|
55
|
+
if constant_listing.size.positive?
|
56
|
+
constant_listing.each { |cnst| csv << [cnst.name(false), 'Constant', (options.serializer.serialized_path(object) + "#" +aref(cnst))] }
|
57
|
+
end
|
58
|
+
|
59
|
+
if (insmeths = public_instance_methods(object)).size > 0
|
60
|
+
insmeths.each { |item| csv << [item.name(false), 'Method', options.serializer.serialized_path(object) + "#" + aref(item)] }
|
61
|
+
end
|
62
|
+
|
63
|
+
if (pubmeths = public_class_methods(object)).size > 0
|
64
|
+
pubmeths.each { |item| csv << [item.name(false), 'Method', options.serializer.serialized_path(object) + '#' + aref(item)]}
|
65
|
+
end
|
66
|
+
|
67
|
+
if (attrs = attr_listing(object)).size > 0
|
68
|
+
attrs.each { |item| csv << [item.name(false), 'Attribute', options.serializer.serialized_path(object) + "#" + aref(item)]}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
33
72
|
end
|
34
73
|
|
35
74
|
def serialize(object)
|
@@ -56,7 +95,7 @@ def serialize(object)
|
|
56
95
|
<% groups(constant_listing, "Constants") do |list, name| %>
|
57
96
|
# <%= name %>
|
58
97
|
<% list.each do |cnst| %>
|
59
|
-
## <%= cnst.name %> =
|
98
|
+
## <%= cnst.name %> = [](#<%=aref(cnst)%>)
|
60
99
|
(<%= cnst.value %>) <%= cnst.docstring %>
|
61
100
|
<% end %>
|
62
101
|
<% end %>
|
@@ -88,13 +127,15 @@ def serialize(object)
|
|
88
127
|
|
89
128
|
<% end %>
|
90
129
|
<% end %>
|
91
|
-
'.gsub(/^ /,
|
130
|
+
'.gsub(/^ /, ''), trim_mode: '%<>')
|
92
131
|
|
93
132
|
template.result(binding)
|
94
133
|
end
|
95
134
|
|
96
135
|
def aref(object)
|
97
|
-
if
|
136
|
+
if object.type == :constant
|
137
|
+
"constant-#{object.name(false)}"
|
138
|
+
elsif !object.attr_info.nil?
|
98
139
|
"attribute-#{object.scope[0]}-#{object.name(false)}"
|
99
140
|
else
|
100
141
|
"#{object.type}-#{object.scope[0]}-#{object.name(false)}"
|
@@ -103,6 +144,7 @@ end
|
|
103
144
|
|
104
145
|
def constant_listing
|
105
146
|
return @constants if defined?(@constants) && @constants
|
147
|
+
|
106
148
|
@constants = object.constants(included: false, inherited: false)
|
107
149
|
@constants += object.cvars
|
108
150
|
@constants
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yard-markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stanislav (Stas) Katkov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
description: yard
|
27
|
+
description: yard plugin to generates markdown documentation for gems
|
28
28
|
email:
|
29
29
|
- yard-markdown@skatkov.com
|
30
30
|
executables: []
|
@@ -41,8 +41,8 @@ files:
|
|
41
41
|
- example/Bird.md
|
42
42
|
- example/Duck.md
|
43
43
|
- example/Waterfowl.md
|
44
|
+
- example/index.csv
|
44
45
|
- lib/yard-markdown.rb
|
45
|
-
- lib/yard/markdown/version.rb
|
46
46
|
- sig/yard/markdown.rbs
|
47
47
|
- templates/default/fulldoc/markdown/setup.rb
|
48
48
|
homepage: https://poshtui.com
|
@@ -69,5 +69,5 @@ requirements: []
|
|
69
69
|
rubygems_version: 3.4.22
|
70
70
|
signing_key:
|
71
71
|
specification_version: 4
|
72
|
-
summary: yard
|
72
|
+
summary: yard plugin to generate markdown documentation
|
73
73
|
test_files: []
|