yard-api 0.1.3 → 0.1.4
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/options.rb +3 -0
- data/lib/yard-api/tags/argument_tag.rb +78 -0
- data/lib/yard-api/tags.rb +5 -2
- data/lib/yard-api/version.rb +1 -1
- data/lib/yard-api.rb +13 -0
- data/spec/spec_helper.rb +100 -31
- data/spec/tags/argument_spec.rb +129 -0
- data/templates/api/fulldoc/html/setup.rb +5 -2
- data/templates/api/tags/html/argument/_list.erb +29 -0
- data/templates/api/tags/html/argument/_table.erb +41 -0
- data/templates/api/tags/html/argument.erb +5 -28
- data/yard-api.gemspec +2 -2
- metadata +10 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4a4a3b1beee6e7ade875e7a95004d14da25fb0d7
|
|
4
|
+
data.tar.gz: ea2078d3f6d4ecf6afdc91aa635ebf53cb046343
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eeb5f091e4cd539126f6fd69dd93186b9e7ef5ab9f417cf588c25b48fc979585c1b18c4d5bdc0345af656b0d0812c7c7132ef558719622b111c687c85f9e6316
|
|
7
|
+
data.tar.gz: adb5d639749e0544ef05234636cbe666459a9dc6bfc9fae9c239a25e796ea4539c1b343e4e4a648d81fb8039bd398cb7e0cfc2dd10a14a7b3eb4f288b9944782
|
data/lib/yard-api/options.rb
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
require 'yaml'
|
|
2
|
+
|
|
3
|
+
module YARD::APIPlugin::Tags
|
|
4
|
+
class ArgumentTag < YARD::Tags::Tag
|
|
5
|
+
attr_reader :accepted_values, :is_required
|
|
6
|
+
|
|
7
|
+
RE_ARRAY_LITERAL = /\[[^\]]+\]/
|
|
8
|
+
RE_ARRAY_TYPE = /^#{RE_ARRAY_LITERAL}$/
|
|
9
|
+
RE_ACCEPTED_VALUES_PREFIXES = /
|
|
10
|
+
accepted\svalues |
|
|
11
|
+
accepts |
|
|
12
|
+
possible\svalues
|
|
13
|
+
/imx
|
|
14
|
+
RE_ACCEPTED_VALUES_STR = /
|
|
15
|
+
#{RE_ACCEPTED_VALUES_PREFIXES}:\s*(#{RE_ARRAY_LITERAL})
|
|
16
|
+
/mx
|
|
17
|
+
|
|
18
|
+
def initialize(name, buf)
|
|
19
|
+
YARD::Tags::Library.instance.tag_create(:attr, buf).tap do |tag|
|
|
20
|
+
super(:argument, tag.text, tag.types, tag.name)
|
|
21
|
+
|
|
22
|
+
@is_required = parse_is_required(@types)
|
|
23
|
+
@accepted_values = parse_accepted_values(@types, @text)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def unscoped_name
|
|
28
|
+
if scope_tag = @object.tag(:argument_scope)
|
|
29
|
+
if @name =~ /^#{scope_tag.text}\[([^\]]+)\]$/
|
|
30
|
+
$1
|
|
31
|
+
else
|
|
32
|
+
@name
|
|
33
|
+
end
|
|
34
|
+
else
|
|
35
|
+
@name
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def parse_is_required(types)
|
|
42
|
+
strict = !!YARD::APIPlugin.options.strict_arguments
|
|
43
|
+
specifier = types.detect { |typestr| typestr.match(/optional|required/i) }
|
|
44
|
+
|
|
45
|
+
if specifier
|
|
46
|
+
types.delete(specifier)
|
|
47
|
+
|
|
48
|
+
return true if specifier.downcase == 'required'
|
|
49
|
+
return false if specifier.downcase == 'optional'
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
strict
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def parse_accepted_values(types, text)
|
|
56
|
+
str = if types.last.match(RE_ARRAY_TYPE)
|
|
57
|
+
types.pop
|
|
58
|
+
elsif text.match(RE_ACCEPTED_VALUES_STR)
|
|
59
|
+
$1
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
if str
|
|
63
|
+
begin
|
|
64
|
+
YAML.load(str)
|
|
65
|
+
rescue Exception => e
|
|
66
|
+
YARD::APIPlugin.on_error <<-Error
|
|
67
|
+
Unable to parse accepted values for @argument tag.
|
|
68
|
+
Error: #{exception}
|
|
69
|
+
Offending docstring:
|
|
70
|
+
#{text}
|
|
71
|
+
Error
|
|
72
|
+
|
|
73
|
+
return nil
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
data/lib/yard-api/tags.rb
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
require 'yard-api/tags/argument_tag'
|
|
2
|
+
|
|
3
|
+
YARD::Tags::Library.define_tag("API endpoint", :API)
|
|
4
|
+
YARD::Tags::Library.define_tag("API endpoint argument", :argument, YARD::APIPlugin::Tags::ArgumentTag)
|
|
5
|
+
YARD::Tags::Library.define_tag("API endpoint argument scope", :argument_scope)
|
|
3
6
|
YARD::Tags::Library.define_tag("API response field", :request_field)
|
|
4
7
|
YARD::Tags::Library.define_tag("API response field", :response_field)
|
|
5
8
|
YARD::Tags::Library.define_tag("API example request", :example_request, :with_title_and_text)
|
data/lib/yard-api/version.rb
CHANGED
data/lib/yard-api.rb
CHANGED
|
@@ -31,6 +31,19 @@ module YARD
|
|
|
31
31
|
def self.options
|
|
32
32
|
@@options ||= Options.new
|
|
33
33
|
end
|
|
34
|
+
|
|
35
|
+
def self.log(message, level=::Logger::INFO)
|
|
36
|
+
log = YARD::Logger.instance
|
|
37
|
+
log.enter_level(level) { log.puts(message) }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.on_error(message)
|
|
41
|
+
if self.options.strict
|
|
42
|
+
raise error
|
|
43
|
+
else
|
|
44
|
+
self.log(error, ::Logger::WARN)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
34
47
|
end
|
|
35
48
|
|
|
36
49
|
require 'yard-api/version'
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,44 +1,113 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Copyright (c) 2013 Instructure, Inc.
|
|
3
|
-
#
|
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a
|
|
5
|
-
# copy of this software and associated documentation files (the "Software"),
|
|
6
|
-
# to deal in the Software without restriction, including without limitation
|
|
7
|
-
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
8
|
-
# and/or sell copies of the Software, and to permit persons to whom the
|
|
9
|
-
# Software is furnished to do so, subject to the following conditions:
|
|
10
|
-
#
|
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
|
12
|
-
# all copies or substantial portions of the Software.
|
|
13
|
-
#
|
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
17
|
-
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
-
# SOFTWARE.
|
|
21
|
-
#
|
|
22
|
-
|
|
23
|
-
require 'yard'
|
|
24
|
-
require File.join(File.dirname(__FILE__), '..', 'lib', 'yard-api')
|
|
25
|
-
|
|
26
1
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
|
27
2
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
|
28
|
-
#
|
|
29
|
-
# loaded
|
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
|
4
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
|
5
|
+
#
|
|
6
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
|
7
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
|
8
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
|
9
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
|
10
|
+
# a separate helper file that requires the additional dependencies and performs
|
|
11
|
+
# the additional setup, and require it from the spec files that actually need it.
|
|
12
|
+
#
|
|
13
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
|
14
|
+
# users commonly want.
|
|
30
15
|
#
|
|
31
16
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
32
17
|
RSpec.configure do |config|
|
|
33
|
-
|
|
34
|
-
|
|
18
|
+
|
|
19
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'yard-api')
|
|
20
|
+
|
|
21
|
+
# rspec-expectations config goes here. You can use an alternate
|
|
22
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
|
23
|
+
# assertions if you prefer.
|
|
24
|
+
config.expect_with :rspec do |expectations|
|
|
25
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
|
26
|
+
# and `failure_message` of custom matchers include text for helper methods
|
|
27
|
+
# defined using `chain`, e.g.:
|
|
28
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
|
29
|
+
# # => "be bigger than 2 and smaller than 4"
|
|
30
|
+
# ...rather than:
|
|
31
|
+
# # => "be bigger than 2"
|
|
32
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
|
36
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
|
37
|
+
config.mock_with :rspec do |mocks|
|
|
38
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
|
39
|
+
# a real object. This is generally recommended, and will default to
|
|
40
|
+
# `true` in RSpec 4.
|
|
41
|
+
mocks.verify_partial_doubles = true
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# The settings below are suggested to provide a good initial experience
|
|
45
|
+
# with RSpec, but feel free to customize to your heart's content.
|
|
46
|
+
=begin
|
|
47
|
+
# These two settings work together to allow you to limit a spec run
|
|
48
|
+
# to individual examples or groups you care about by tagging them with
|
|
49
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
|
50
|
+
# get run.
|
|
35
51
|
config.filter_run :focus
|
|
52
|
+
config.run_all_when_everything_filtered = true
|
|
53
|
+
|
|
54
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
|
55
|
+
# For more details, see:
|
|
56
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
|
57
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
|
58
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
|
59
|
+
config.disable_monkey_patching!
|
|
60
|
+
|
|
61
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
|
62
|
+
# be too noisy due to issues in dependencies.
|
|
63
|
+
config.warnings = true
|
|
64
|
+
|
|
65
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
|
66
|
+
# file, and it's useful to allow more verbose output when running an
|
|
67
|
+
# individual spec file.
|
|
68
|
+
if config.files_to_run.one?
|
|
69
|
+
# Use the documentation formatter for detailed output,
|
|
70
|
+
# unless a formatter has already been configured
|
|
71
|
+
# (e.g. via a command-line flag).
|
|
72
|
+
config.default_formatter = 'doc'
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Print the 10 slowest examples and example groups at the
|
|
76
|
+
# end of the spec run, to help surface which specs are running
|
|
77
|
+
# particularly slow.
|
|
78
|
+
config.profile_examples = 10
|
|
36
79
|
|
|
37
80
|
# Run specs in random order to surface order dependencies. If you find an
|
|
38
81
|
# order dependency and want to debug it, you can fix the order by providing
|
|
39
82
|
# the seed, which is printed after each run.
|
|
40
83
|
# --seed 1234
|
|
41
|
-
config.order =
|
|
84
|
+
config.order = :random
|
|
85
|
+
|
|
86
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
|
87
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
|
88
|
+
# test failures related to randomization by passing the same `--seed` value
|
|
89
|
+
# as the one that triggered the failure.
|
|
90
|
+
Kernel.srand config.seed
|
|
91
|
+
=end
|
|
92
|
+
|
|
93
|
+
config.before(:each) do
|
|
94
|
+
@overridden_options = {}
|
|
95
|
+
@options = YARD::APIPlugin.options
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def set_option(key, value)
|
|
99
|
+
unless @overridden_options.has_key?(key.to_sym)
|
|
100
|
+
@overridden_options[key.to_sym] = @options.value
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
@options.send("#{key}=", value)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
config.after(:each) do
|
|
107
|
+
@overridden_options.each_pair do |key, value|
|
|
108
|
+
@options.send("#{key}=", value)
|
|
109
|
+
end
|
|
42
110
|
|
|
43
|
-
|
|
111
|
+
@overridden_options.clear
|
|
112
|
+
end
|
|
44
113
|
end
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe YARD::APIPlugin::Tags::ArgumentTag do
|
|
4
|
+
def populate(str=nil)
|
|
5
|
+
YARD::Registry.clear
|
|
6
|
+
YARD.parse_string str if str
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def find_tag(method_name, tag_name, index=0)
|
|
10
|
+
P(method_name.to_sym)
|
|
11
|
+
.tags.select { |tag| tag.tag_name == tag_name.to_s }[index]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
before do
|
|
15
|
+
YARD::Registry.clear
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'should work like an @attr tag' do
|
|
19
|
+
populate <<-'eof'
|
|
20
|
+
# @argument [String] name
|
|
21
|
+
# Your full name.
|
|
22
|
+
def signup
|
|
23
|
+
end
|
|
24
|
+
eof
|
|
25
|
+
|
|
26
|
+
tag = find_tag(:signup, :argument, 0)
|
|
27
|
+
|
|
28
|
+
expect(tag.name).to eq 'name'
|
|
29
|
+
expect(tag.text).to eq 'Your full name.'
|
|
30
|
+
expect(tag.types).to eq ['String']
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe '#is_required' do
|
|
34
|
+
it 'should default to whatever Options.strict_arguments is set to' do
|
|
35
|
+
set_option(:strict_arguments, false)
|
|
36
|
+
|
|
37
|
+
populate <<-'eof'
|
|
38
|
+
# @argument [String] name
|
|
39
|
+
# Your full name.
|
|
40
|
+
#
|
|
41
|
+
# @argument [Optional, Number] age
|
|
42
|
+
# How old you currently are.
|
|
43
|
+
def signup
|
|
44
|
+
end
|
|
45
|
+
eof
|
|
46
|
+
|
|
47
|
+
expect(find_tag(:signup, :argument, 0).is_required).to be false
|
|
48
|
+
expect(find_tag(:signup, :argument, 1).is_required).to be false
|
|
49
|
+
|
|
50
|
+
set_option(:strict_arguments, true)
|
|
51
|
+
|
|
52
|
+
populate <<-'eof'
|
|
53
|
+
# @argument [String] name
|
|
54
|
+
# Your full name.
|
|
55
|
+
#
|
|
56
|
+
# @argument [Optional, Number] age
|
|
57
|
+
# How old you currently are.
|
|
58
|
+
def signup
|
|
59
|
+
end
|
|
60
|
+
eof
|
|
61
|
+
|
|
62
|
+
expect(find_tag(:signup, :argument, 0).is_required).to be true
|
|
63
|
+
expect(find_tag(:signup, :argument, 1).is_required).to be false
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'should be true if Required is written in typestr' do
|
|
67
|
+
set_option :strict_arguments, false
|
|
68
|
+
|
|
69
|
+
populate <<-'eof'
|
|
70
|
+
# @argument [Required, String] name
|
|
71
|
+
# Your full name.
|
|
72
|
+
def signup
|
|
73
|
+
end
|
|
74
|
+
eof
|
|
75
|
+
|
|
76
|
+
expect(find_tag(:signup, :argument).is_required).to be true
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
describe '#accepted_values' do
|
|
81
|
+
it 'should work in the type specifier: @argument [String, ["foo", "bar"]]' do
|
|
82
|
+
populate <<-'eof'
|
|
83
|
+
# @argument [Required, String, ["S","M","L","XL"]] size
|
|
84
|
+
# Your full name.
|
|
85
|
+
def order_shirt
|
|
86
|
+
end
|
|
87
|
+
eof
|
|
88
|
+
|
|
89
|
+
expect(find_tag(:order_shirt, :argument).accepted_values).to eq(%w[S M L XL])
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'should work using "Accepted values: [...]"' do
|
|
93
|
+
populate <<-'eof'
|
|
94
|
+
# @argument [String] size
|
|
95
|
+
# Size of the t-shirt you want.
|
|
96
|
+
# Accepted values: ["S","M","L","XL"]
|
|
97
|
+
def order_shirt
|
|
98
|
+
end
|
|
99
|
+
eof
|
|
100
|
+
|
|
101
|
+
expect(find_tag(:order_shirt, :argument).accepted_values).to eq(%w[S M L XL])
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
it 'should work using "Accepts: [...]"' do
|
|
105
|
+
populate <<-'eof'
|
|
106
|
+
# @argument [String] size
|
|
107
|
+
# Size of the t-shirt you want.
|
|
108
|
+
# Accepts: ["S","M","L","XL"]
|
|
109
|
+
def order_shirt
|
|
110
|
+
end
|
|
111
|
+
eof
|
|
112
|
+
|
|
113
|
+
expect(find_tag(:order_shirt, :argument).accepted_values).to eq(%w[S M L XL])
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it 'should work using "Possible values: [...]"' do
|
|
117
|
+
populate <<-'eof'
|
|
118
|
+
# @argument [String] size
|
|
119
|
+
# Size of the t-shirt you want.
|
|
120
|
+
# Possible values: ["S","M","L","XL"]
|
|
121
|
+
def order_shirt
|
|
122
|
+
end
|
|
123
|
+
eof
|
|
124
|
+
|
|
125
|
+
expect(find_tag(:order_shirt, :argument).accepted_values).to eq(%w[S M L XL])
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
end
|
|
129
|
+
end
|
|
@@ -10,6 +10,11 @@ def init
|
|
|
10
10
|
|
|
11
11
|
build_json_objects_map
|
|
12
12
|
generate_assets
|
|
13
|
+
|
|
14
|
+
if api_options.one_file
|
|
15
|
+
return serialize_onefile_index
|
|
16
|
+
end
|
|
17
|
+
|
|
13
18
|
serialize_index
|
|
14
19
|
serialize_static_pages
|
|
15
20
|
serialize_resource_index if api_options['resource_index']
|
|
@@ -38,8 +43,6 @@ def serialize_resource(resource, controllers)
|
|
|
38
43
|
end
|
|
39
44
|
|
|
40
45
|
def serialize_index
|
|
41
|
-
return serialize_onefile_index if api_options.one_file
|
|
42
|
-
|
|
43
46
|
options[:file] = api_options['readme']
|
|
44
47
|
serialize('index.html')
|
|
45
48
|
options.delete(:file)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<ul class="argument">
|
|
2
|
+
<% @argument_tags.each do |tag| %>
|
|
3
|
+
<%
|
|
4
|
+
tag.text ||= ''
|
|
5
|
+
desc = tag.text.strip.sub(/^\[([^\]]+)\]/, '').strip
|
|
6
|
+
type = $1
|
|
7
|
+
desc = desc.sub(/(\(optional\))/, '').strip
|
|
8
|
+
is_optional = $1.present?
|
|
9
|
+
name, desc = desc.split(/\s/, 2).map(&:strip)
|
|
10
|
+
desc = desc.sub(/[A|a]ccepted values:\s*\[([^\]]+)\]/, '').strip
|
|
11
|
+
accepted_values = $1
|
|
12
|
+
%>
|
|
13
|
+
<li>
|
|
14
|
+
<code class="argument-name"><%= h name %></code>
|
|
15
|
+
<span class="argument-type"><%= type %></span>
|
|
16
|
+
<span class="argument-values fade">
|
|
17
|
+
<em><%= "[#{accepted_values}]" if accepted_values.present? %></em>
|
|
18
|
+
</span>
|
|
19
|
+
|
|
20
|
+
<% unless is_optional %>
|
|
21
|
+
<em class="argument-required">Required</em>
|
|
22
|
+
<% end %>
|
|
23
|
+
|
|
24
|
+
<% if !desc.empty? %>
|
|
25
|
+
<%= html_markup_markdown(desc) %>
|
|
26
|
+
<% end %>
|
|
27
|
+
</li>
|
|
28
|
+
<% end %>
|
|
29
|
+
</ul>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<table>
|
|
2
|
+
<thead>
|
|
3
|
+
<tr>
|
|
4
|
+
<th>Name</th>
|
|
5
|
+
<th>Type</th>
|
|
6
|
+
<th>Accepted Values</th>
|
|
7
|
+
<th>Required?</th>
|
|
8
|
+
<th>Description</th>
|
|
9
|
+
</tr>
|
|
10
|
+
</thead>
|
|
11
|
+
|
|
12
|
+
<tbody>
|
|
13
|
+
<% @argument_tags.each do |tag| %>
|
|
14
|
+
<tr>
|
|
15
|
+
<td><code class="argument-name"><%= h tag.unscoped_name %></code></td>
|
|
16
|
+
<td><span class="argument-type"><%= tag.type %></span></td>
|
|
17
|
+
<td>
|
|
18
|
+
<ul class="argument-values">
|
|
19
|
+
<% (tag.accepted_values || []).each do |value| %>
|
|
20
|
+
<li><%= value %></li>
|
|
21
|
+
<% end %>
|
|
22
|
+
</ul>
|
|
23
|
+
</td>
|
|
24
|
+
|
|
25
|
+
<td>
|
|
26
|
+
<% if tag.is_required %>
|
|
27
|
+
<em class="argument-required">Yes</em>
|
|
28
|
+
<% else %>
|
|
29
|
+
<em class="argument-optional">No</em>
|
|
30
|
+
<% end %>
|
|
31
|
+
</td>
|
|
32
|
+
|
|
33
|
+
<td>
|
|
34
|
+
<% if !tag.text.empty? %>
|
|
35
|
+
<%= html_markup_markdown(tag.text) %>
|
|
36
|
+
<% end %>
|
|
37
|
+
</td>
|
|
38
|
+
</tr>
|
|
39
|
+
<% end %>
|
|
40
|
+
</tbody>
|
|
41
|
+
</table>
|
|
@@ -1,32 +1,9 @@
|
|
|
1
1
|
<section class="endpoint-arguments">
|
|
2
2
|
<h4>Parameters:</h4>
|
|
3
|
-
<ul class="argument">
|
|
4
|
-
<% @argument_tags.each do |tag| %>
|
|
5
|
-
<%
|
|
6
|
-
tag.text ||= ''
|
|
7
|
-
desc = tag.text.strip.sub(/^\[([^\]]+)\]/, '').strip
|
|
8
|
-
type = $1
|
|
9
|
-
desc = desc.sub(/(\(optional\))/, '').strip
|
|
10
|
-
is_optional = $1.present?
|
|
11
|
-
name, desc = desc.split(/\s/, 2).map(&:strip)
|
|
12
|
-
desc = desc.sub(/[A|a]ccepted values:\s*\[([^\]]+)\]/, '').strip
|
|
13
|
-
accepted_values = $1
|
|
14
|
-
%>
|
|
15
|
-
<li>
|
|
16
|
-
<code class="argument-name"><%= h name %></code>
|
|
17
|
-
<span class="argument-type"><%= type %></span>
|
|
18
|
-
<span class="argument-values fade">
|
|
19
|
-
<em><%= "[#{accepted_values}]" if accepted_values.present? %></em>
|
|
20
|
-
</span>
|
|
21
3
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<%= html_markup_markdown(desc) %>
|
|
28
|
-
<% end %>
|
|
29
|
-
</li>
|
|
30
|
-
<% end %>
|
|
31
|
-
</ul>
|
|
4
|
+
<% if api_options.tabular_arguments %>
|
|
5
|
+
<%= erb :"argument/_table" %>
|
|
6
|
+
<% else %>
|
|
7
|
+
<%= erb :"argument/_list" %>
|
|
8
|
+
<% end %>
|
|
32
9
|
</section>
|
data/yard-api.gemspec
CHANGED
|
@@ -17,6 +17,6 @@ Gem::Specification.new do |s|
|
|
|
17
17
|
s.license = 'AGPL3'
|
|
18
18
|
s.add_dependency 'yard', '0.8.7'
|
|
19
19
|
s.add_dependency 'yard-appendix', '~> 0.1.8'
|
|
20
|
-
s.add_development_dependency 'rspec'
|
|
21
|
-
s.add_development_dependency 'gem-release'
|
|
20
|
+
s.add_development_dependency 'rspec'
|
|
21
|
+
s.add_development_dependency 'gem-release'
|
|
22
22
|
end
|
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.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ahmad Amireh
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-09-
|
|
11
|
+
date: 2014-09-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: yard
|
|
@@ -42,28 +42,28 @@ dependencies:
|
|
|
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
|
|
@@ -81,6 +81,7 @@ files:
|
|
|
81
81
|
- lib/yard-api/options.rb
|
|
82
82
|
- lib/yard-api/railtie.rb
|
|
83
83
|
- lib/yard-api/tags.rb
|
|
84
|
+
- lib/yard-api/tags/argument_tag.rb
|
|
84
85
|
- lib/yard-api/templates/helpers/base_helper.rb
|
|
85
86
|
- lib/yard-api/templates/helpers/html_helper.rb
|
|
86
87
|
- lib/yard-api/templates/helpers/route_helper.rb
|
|
@@ -88,6 +89,7 @@ files:
|
|
|
88
89
|
- lib/yard-api/version.rb
|
|
89
90
|
- lib/yard-api/yardoc_task.rb
|
|
90
91
|
- spec/spec_helper.rb
|
|
92
|
+
- spec/tags/argument_spec.rb
|
|
91
93
|
- tasks/yard_api.rake
|
|
92
94
|
- templates/api/appendix/html/setup.rb
|
|
93
95
|
- templates/api/docstring/html/setup.rb
|
|
@@ -106,6 +108,8 @@ files:
|
|
|
106
108
|
- templates/api/onefile/html/sidebar.erb
|
|
107
109
|
- templates/api/tags/html/_example_code_block.erb
|
|
108
110
|
- templates/api/tags/html/argument.erb
|
|
111
|
+
- templates/api/tags/html/argument/_list.erb
|
|
112
|
+
- templates/api/tags/html/argument/_table.erb
|
|
109
113
|
- templates/api/tags/html/emits.erb
|
|
110
114
|
- templates/api/tags/html/example_request.erb
|
|
111
115
|
- templates/api/tags/html/example_response.erb
|