yard-api 0.3.1 → 0.3.2
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/lib/yard-api/version.rb +1 -1
- data/lib/yard-api/yardoc_task.rb +2 -0
- data/templates/api/fulldoc/json/setup.rb +50 -31
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da18e5c099f63291990732b6b8641f9b3d6588a4
|
4
|
+
data.tar.gz: 697447ab5b213e1322e37888fd4ef9bc49c89fef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2912e45619e1199eebb28422298e380155795978e62966c168af494e3ce98e058ef6f748495df012359692033573c213be34d7e2da5589837d5090d46bee5f91
|
7
|
+
data.tar.gz: a721d465aa53ab6e817bbb7485c9f75dff2ce6c193c3a8a1746115393b963bd97d132c05cdcd9bdc1bb38aab1af54a429333689d665d9a5b1a31069399743b19
|
data/lib/yard-api/version.rb
CHANGED
data/lib/yard-api/yardoc_task.rb
CHANGED
@@ -5,6 +5,7 @@ include YARD::Templates::Helpers::FilterHelper
|
|
5
5
|
include YARD::Templates::Helpers::HtmlHelper
|
6
6
|
|
7
7
|
RouteHelper = YARD::Templates::Helpers::RouteHelper
|
8
|
+
ArgumentTag = YARD::APIPlugin::Tags::ArgumentTag
|
8
9
|
|
9
10
|
def init
|
10
11
|
resources = options[:objects]
|
@@ -15,17 +16,17 @@ end
|
|
15
16
|
|
16
17
|
def serialize_resource(resource, controllers)
|
17
18
|
Templates::Engine.with_serializer("#{topicize resource}.json", options[:serializer]) do
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
}
|
19
|
+
{
|
20
|
+
id: topicize(resource),
|
21
|
+
title: resource,
|
22
|
+
text: controllers.map { |c| c.docstring }.join("\n\n"),
|
23
|
+
objects: controllers.map { |c| dump_controller_objects(c) }.flatten,
|
24
|
+
endpoints: dump_resource_endpoints(controllers)
|
25
|
+
}.to_json
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
|
-
def
|
29
|
+
def dump_resource_endpoints(controllers)
|
29
30
|
meths = controllers.map do |controller|
|
30
31
|
controller.meths(:inherited => false, :included => false)
|
31
32
|
end.flatten
|
@@ -33,40 +34,58 @@ def method_details_list(controllers)
|
|
33
34
|
meths = run_verifier(meths)
|
34
35
|
|
35
36
|
meths.map do |object, i|
|
36
|
-
|
37
|
+
dump_endpoint(object).tap do |object_info|
|
37
38
|
object_info[:tags] = dump_object_tags(object)
|
38
39
|
end
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
42
|
-
def
|
43
|
+
def dump_controller_objects(controller)
|
43
44
|
(controller.tags(:object) + controller.tags(:model)).map do |obj|
|
44
|
-
|
45
|
+
dump_object(obj)
|
46
|
+
end
|
47
|
+
end
|
45
48
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
def dump_object(obj)
|
50
|
+
title, spec = obj.text.split(%r{\n+}, 2).map(&:strip)
|
51
|
+
spec = JSON.parse(spec)
|
52
|
+
schema = spec.has_key?('properties') ? spec['properties'] : spec
|
53
|
+
|
54
|
+
schema_tags = schema.map do |(prop_name, prop)|
|
55
|
+
is_required = prop.has_key?('required') ? prop['required'] : false
|
56
|
+
is_required_str = is_required ? 'Required' : 'Optional'
|
57
|
+
|
58
|
+
ArgumentTag.new(nil, "[#{is_required_str}, #{prop['type']}] #{prop_name}\n #{prop['description']}")
|
51
59
|
end
|
60
|
+
|
61
|
+
{
|
62
|
+
id: topicize("#{obj.object.path}::#{title}"),
|
63
|
+
scoped_id: topicize(title),
|
64
|
+
title: title,
|
65
|
+
text: spec['description'] || '',
|
66
|
+
controller: obj.object.path,
|
67
|
+
schema: schema_tags.as_json.map { |e| e.delete('tag_name'); e }
|
68
|
+
}
|
52
69
|
end
|
53
70
|
|
54
|
-
def
|
71
|
+
def dump_endpoint(endpoint)
|
72
|
+
title = endpoint.tag(:API).text
|
73
|
+
|
55
74
|
{
|
56
|
-
|
57
|
-
|
58
|
-
title:
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
dynamic:
|
68
|
-
group:
|
69
|
-
visibility:
|
75
|
+
id: topicize(endpoint.path),
|
76
|
+
scoped_id: topicize(title),
|
77
|
+
title: title,
|
78
|
+
text: endpoint.base_docstring,
|
79
|
+
controller: endpoint.namespace.path,
|
80
|
+
route: get_route(endpoint),
|
81
|
+
type: endpoint.type,
|
82
|
+
source: endpoint.source,
|
83
|
+
source_type: endpoint.source_type,
|
84
|
+
signature: endpoint.signature,
|
85
|
+
files: endpoint.files,
|
86
|
+
dynamic: endpoint.dynamic,
|
87
|
+
group: endpoint.group,
|
88
|
+
visibility: endpoint.visibility
|
70
89
|
}
|
71
90
|
end
|
72
91
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yard-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ahmad Amireh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|