yard-api 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/yard-api/options.rb +6 -0
- data/lib/yard-api/templates/helpers/html_helper.rb +10 -4
- data/lib/yard-api/version.rb +1 -1
- data/lib/yard-api/yardoc_task.rb +2 -2
- data/lib/yard-api.rb +7 -0
- data/templates/api/fulldoc/html/setup.rb +17 -5
- data/templates/api/layout/html/headers.erb +6 -13
- data/templates/api/layout/html/layout.erb +1 -1
- data/templates/api/layout/html/scripts.erb +1 -1
- data/templates/api/layout/html/setup.rb +14 -0
- data/templates/api/layout/html/sidebar.erb +16 -13
- data/templates/api/onefile/html/setup.rb +1 -0
- data/templates/api/onefile/html/sidebar.erb +15 -0
- data/yard-api.gemspec +3 -3
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 199b61a69ee11af6ea6ba0dddb1b7227647258ec
|
4
|
+
data.tar.gz: 7d1e0fec57a1f4366d698c272af0c96056fdf1e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 412350ca78f192d978a921c57f0a0294e184fe3ce9c754a9e9374a19ba4128deaf0e1f81e98c4f6e2f9599abe07b99d1b53874580c048ae22fdefeb7cbafbe44
|
7
|
+
data.tar.gz: a4ce1b0807cf2e4c5c27aadb4223a28f22a0a96a4a73a0fae2650c36692a5fba2bab480ff42d4f7464a9b51db2b8cbde5e8b33913a517ce72d9c6b9a92d423ac
|
data/lib/yard-api/options.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module YARD::APIPlugin
|
2
2
|
class Options < YARD::Options
|
3
3
|
default_attr :title, 'Rails API Project'
|
4
|
+
default_attr :source, 'doc/api'
|
4
5
|
default_attr :static, []
|
5
6
|
default_attr :files, []
|
6
7
|
default_attr :route_namespace, ''
|
@@ -8,6 +9,11 @@ module YARD::APIPlugin
|
|
8
9
|
default_attr :footer_copyright, nil
|
9
10
|
default_attr :footer_note, nil
|
10
11
|
|
12
|
+
default_attr :one_file, false
|
13
|
+
default_attr :verbose, false
|
14
|
+
default_attr :debug, false
|
15
|
+
default_attr :theme, 'default'
|
16
|
+
|
11
17
|
attr_accessor :readme
|
12
18
|
end
|
13
19
|
end
|
@@ -35,13 +35,15 @@ module YARD::Templates::Helpers::HtmlHelper
|
|
35
35
|
elsif entry.is_a?(String)
|
36
36
|
[ entry ]
|
37
37
|
end
|
38
|
-
end.flatten.compact
|
38
|
+
end.flatten.compact.uniq.map { |path| File.join(options.source, path) }
|
39
|
+
|
40
|
+
puts "Static pages: #{paths}" if options.verbose
|
39
41
|
|
40
42
|
markdown_exts = YARD::Templates::Helpers::MarkupHelper::MARKUP_EXTENSIONS[:markdown]
|
41
43
|
readme_page = options.readme
|
42
44
|
pages = Dir.glob(paths)
|
43
45
|
|
44
|
-
if readme_page.present?
|
46
|
+
if readme_page.present? && !options.one_file
|
45
47
|
pages.delete_if { |page| page.match(readme_page) }
|
46
48
|
end
|
47
49
|
|
@@ -57,6 +59,10 @@ module YARD::Templates::Helpers::HtmlHelper
|
|
57
59
|
File.basename(page).sub(/\.\w+$/, '').gsub(/\W/, ' ').gsub(/\s+/, ' ').capitalize
|
58
60
|
end
|
59
61
|
|
62
|
+
if options.verbose
|
63
|
+
puts "Serializing static page #{page}"
|
64
|
+
end
|
65
|
+
|
60
66
|
{
|
61
67
|
src: page,
|
62
68
|
filename: filename,
|
@@ -85,9 +91,9 @@ module YARD::Templates::Helpers::HtmlHelper
|
|
85
91
|
link_url("#{html_file}##{bookmark}", appendix.title)
|
86
92
|
end
|
87
93
|
|
88
|
-
def sidebar_link(title, href)
|
94
|
+
def sidebar_link(title, href, options={})
|
89
95
|
<<-HTML
|
90
|
-
<a href="#{url_for(href)}">#{title}</a>
|
96
|
+
<a href="#{url_for(href)}" class="#{options[:class_name]}">#{title}</a>
|
91
97
|
HTML
|
92
98
|
end
|
93
99
|
|
data/lib/yard-api/version.rb
CHANGED
data/lib/yard-api/yardoc_task.rb
CHANGED
data/lib/yard-api.rb
CHANGED
@@ -45,4 +45,11 @@ module YARD
|
|
45
45
|
module Templates
|
46
46
|
Engine.register_template_path YARD::APIPlugin::TEMPLATE_PATH
|
47
47
|
end
|
48
|
+
|
49
|
+
module CLI
|
50
|
+
class YardocOptions < Templates::TemplateOptions
|
51
|
+
default_attr :resources, []
|
52
|
+
default_attr :json_objects, []
|
53
|
+
end
|
54
|
+
end
|
48
55
|
end
|
@@ -12,7 +12,7 @@ def init
|
|
12
12
|
generate_assets
|
13
13
|
serialize_index
|
14
14
|
serialize_static_pages
|
15
|
-
|
15
|
+
serialize_resource_index if api_options['resource_index']
|
16
16
|
|
17
17
|
options.delete(:objects)
|
18
18
|
|
@@ -38,12 +38,24 @@ def serialize_resource(resource, controllers)
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def serialize_index
|
41
|
+
return serialize_onefile_index if api_options.one_file
|
42
|
+
|
41
43
|
options[:file] = api_options['readme']
|
42
44
|
serialize('index.html')
|
43
45
|
options.delete(:file)
|
44
46
|
end
|
45
47
|
|
46
|
-
def
|
48
|
+
def serialize_onefile_index
|
49
|
+
options[:all_resources] = true
|
50
|
+
|
51
|
+
Templates::Engine.with_serializer('index.html', options[:serializer]) do
|
52
|
+
T('onefile').run(options)
|
53
|
+
end
|
54
|
+
|
55
|
+
options.delete(:all_resources)
|
56
|
+
end
|
57
|
+
|
58
|
+
def serialize_resource_index
|
47
59
|
options[:all_resources] = true
|
48
60
|
|
49
61
|
Templates::Engine.with_serializer("all_resources.html", options[:serializer]) do
|
@@ -58,9 +70,9 @@ def asset(path, content)
|
|
58
70
|
end
|
59
71
|
|
60
72
|
def generate_assets
|
61
|
-
|
62
|
-
|
63
|
-
|
73
|
+
layout = Object.new.extend(T('layout'))
|
74
|
+
|
75
|
+
[].concat(layout.stylesheets).concat(layout.javascripts).uniq.each do |file|
|
64
76
|
asset(file, file(file, true))
|
65
77
|
end
|
66
78
|
end
|
@@ -3,17 +3,10 @@
|
|
3
3
|
|
4
4
|
<title><%= api_options['title'] %></title>
|
5
5
|
|
6
|
-
|
7
|
-
rel="stylesheet"
|
8
|
-
|
9
|
-
type="text/css"
|
10
|
-
media="screen"
|
11
|
-
charset="utf-8" />
|
6
|
+
<% stylesheets.each do |stylesheet| %>
|
7
|
+
<link rel="stylesheet" href="<%= url_for(stylesheet) %>" type="text/css" charset="utf-8" />
|
8
|
+
<% end %>
|
12
9
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
type="text/css" />
|
17
|
-
|
18
|
-
<script src="<%= url_for("js/highlight/highlight.pack.js") %>" type="text/javascript"></script>
|
19
|
-
<script src="<%= url_for("js/jquery-1.11.1.min.js") %>" type="text/javascript"></script>
|
10
|
+
<% javascripts.each do |javascript| %>
|
11
|
+
<script src="<%= url_for(javascript) %>" type="text/javascript"></script>
|
12
|
+
<% end %>
|
@@ -17,6 +17,20 @@ def init
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
def stylesheets
|
21
|
+
%w[
|
22
|
+
css/common.css
|
23
|
+
css/highlight.css
|
24
|
+
]
|
25
|
+
end
|
26
|
+
|
27
|
+
def javascripts
|
28
|
+
%w[
|
29
|
+
js/jquery-1.11.1.min.js
|
30
|
+
js/highlight/highlight.pack.js
|
31
|
+
]
|
32
|
+
end
|
33
|
+
|
20
34
|
def contents
|
21
35
|
@contents
|
22
36
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<
|
1
|
+
<div>
|
2
2
|
<h1>
|
3
3
|
<%= api_options['title'] %>
|
4
4
|
<%= api_options['version'] %>
|
@@ -6,18 +6,21 @@
|
|
6
6
|
|
7
7
|
<h2 class='first'>Pages</h2>
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
<nav id="static_pages">
|
10
|
+
<%= sidebar_link('Home', 'index.html') %>
|
11
|
+
<% static_pages.each do |page| %>
|
12
|
+
<%= sidebar_link(page[:title], page[:filename]) %>
|
13
|
+
<% end %>
|
14
|
+
</nav>
|
14
15
|
|
15
16
|
<h2>Resources</h2>
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
<nav id="api_resources">
|
18
|
+
<% if api_options['resource_index'] %>
|
19
|
+
<%= sidebar_link('All Resources', 'all_resources.html') %>
|
20
|
+
<% end %>
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
</nav>
|
22
|
+
<% options[:resources].each do |resource, controllers| %>
|
23
|
+
<%= sidebar_link resource, "#{topicize(resource)}.html" %>
|
24
|
+
<% end %>
|
25
|
+
</nav>
|
26
|
+
</div>
|
@@ -0,0 +1 @@
|
|
1
|
+
include T('api/layout/html')
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<div>
|
2
|
+
<h1>
|
3
|
+
<%= sidebar_link("#{api_options.title} #{api_options.version}", 'index.html') %>
|
4
|
+
</h1>
|
5
|
+
|
6
|
+
<nav id="static_pages">
|
7
|
+
<% static_pages.each do |page| %>
|
8
|
+
<%= sidebar_link(page[:title], page[:filename]) %>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<% options[:resources].each do |resource, controllers| %>
|
12
|
+
<%= sidebar_link resource, "#{topicize(resource)}.html", class_name: "api_resource_link" %>
|
13
|
+
<% end %>
|
14
|
+
</nav>
|
15
|
+
</div>
|
data/yard-api.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.has_rdoc = 'yard'
|
17
17
|
s.license = 'AGPL3'
|
18
18
|
s.add_dependency 'yard', '0.8.7'
|
19
|
-
s.add_dependency 'yard-appendix', '
|
20
|
-
s.add_development_dependency 'rspec'
|
21
|
-
s.add_development_dependency 'gem-release'
|
19
|
+
s.add_dependency 'yard-appendix', '~> 0.1.8'
|
20
|
+
s.add_development_dependency 'rspec', '~> 0'
|
21
|
+
s.add_development_dependency 'gem-release', '~> 0'
|
22
22
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yard-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ahmad Amireh
|
@@ -28,42 +28,42 @@ dependencies:
|
|
28
28
|
name: yard-appendix
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 0.1.8
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.1.8
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: gem-release
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: |2
|
@@ -102,6 +102,8 @@ files:
|
|
102
102
|
- templates/api/method_details/html/header.erb
|
103
103
|
- templates/api/method_details/html/method_signature.erb
|
104
104
|
- templates/api/method_details/html/setup.rb
|
105
|
+
- templates/api/onefile/html/setup.rb
|
106
|
+
- templates/api/onefile/html/sidebar.erb
|
105
107
|
- templates/api/tags/html/_example_code_block.erb
|
106
108
|
- templates/api/tags/html/argument.erb
|
107
109
|
- templates/api/tags/html/emits.erb
|