autodoc-grape 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +21 -0
- data/README.md +40 -0
- data/Rakefile +1 -0
- data/autodoc-grape.gemspec +28 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/autodoc/grape.rb +10 -0
- data/lib/autodoc/grape/document/parameter.rb +62 -0
- data/lib/autodoc/grape/monkey_patches/document_grape_extension.rb +35 -0
- data/lib/autodoc/grape/version.rb +5 -0
- metadata +145 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6797d121ea4b92281c65cc4bc1344f1a61c2c39c
|
4
|
+
data.tar.gz: e5ffe33e7aacdd5df46a3f4b1c9aa738a858dfec
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0cf1eb42e68f8b4286b20386256a76325febc32875a35d91d96c75907ebb4d62d2a956918ddac1f4ba08fc024118c4cdca92ca2ad66288cd8cf1be5bb3ce09f3
|
7
|
+
data.tar.gz: b656ac74787a9f9721f97256a526a229b8a4535a3fa3ce5f8c850b71d453b0828caf07f7decf0a840fc453ae83191643b87ffe863caf8811920919677cb54069
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle/
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
log/*.log
|
13
|
+
pkg
|
14
|
+
pkg/
|
15
|
+
rdoc
|
16
|
+
spec/dummy/.sass-cache
|
17
|
+
spec/dummy/db/*.sqlite3
|
18
|
+
spec/dummy/log/*.log
|
19
|
+
spec/dummy/tmp/
|
20
|
+
spec/reports
|
21
|
+
tmp
|
22
|
+
vendor/bundle
|
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Keisuke Ishizawa
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Autodoc::Grape
|
2
|
+
|
3
|
+
Extend [r7kamura/autodoc](https:/github.com/r7kamura/autodoc/) to generate documention for [Grape API](https://github.com/ruby-grape/grape).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'autodoc-grape'
|
11
|
+
```
|
12
|
+
|
13
|
+
## Example
|
14
|
+
|
15
|
+
### Grape API params block
|
16
|
+
```ruby
|
17
|
+
params do
|
18
|
+
requires :id, type: Integer
|
19
|
+
optional :hash, type: Hash do
|
20
|
+
requires :attr, type: String
|
21
|
+
end
|
22
|
+
end
|
23
|
+
```
|
24
|
+
|
25
|
+
### Generated Parameter Section
|
26
|
+
```md
|
27
|
+
### Parameters
|
28
|
+
* id Integer (required)
|
29
|
+
* hash Hash
|
30
|
+
* attr String (required)
|
31
|
+
```
|
32
|
+
|
33
|
+
|
34
|
+
## Supported Parameter Options
|
35
|
+
The following are all valid options.
|
36
|
+
|
37
|
+
* required
|
38
|
+
* values
|
39
|
+
* default
|
40
|
+
* description
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'autodoc/grape/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "autodoc-grape"
|
8
|
+
spec.version = Autodoc::Grape::VERSION
|
9
|
+
spec.authors = ["Keisuke Ishizawa"]
|
10
|
+
spec.email = ["muddyapesjm66@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Autodoc for Grape API specs."
|
13
|
+
spec.homepage = "https://github.com/kei-p/autodoc-grape"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "autodoc"
|
22
|
+
spec.add_dependency "grape"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
25
|
+
spec.add_development_dependency "rails", "4.2.0"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "sqlite3"
|
28
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "autodoc/grape"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
module Autodoc
|
2
|
+
module Grape
|
3
|
+
module Document
|
4
|
+
class Parameter
|
5
|
+
attr_reader :validator
|
6
|
+
|
7
|
+
def initialize(validator)
|
8
|
+
@validator = validator
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
"#{body}#{payload}"
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def indent
|
18
|
+
" " * ( nest_key_names.count - 1 )
|
19
|
+
end
|
20
|
+
|
21
|
+
def nest_key_names
|
22
|
+
validator[0].gsub(%r{\[(.*?)\]}, '__\1').split('__')
|
23
|
+
end
|
24
|
+
|
25
|
+
def key
|
26
|
+
nest_key_names.last
|
27
|
+
end
|
28
|
+
|
29
|
+
def options
|
30
|
+
validator[1]
|
31
|
+
end
|
32
|
+
|
33
|
+
def body
|
34
|
+
"#{indent}* #{key} #{options[:type]}"
|
35
|
+
end
|
36
|
+
|
37
|
+
def payload
|
38
|
+
string = ""
|
39
|
+
string << " (#{assets.join(', ')})" if assets.any?
|
40
|
+
string << " - #{options[:desc]}" if options[:desc]
|
41
|
+
string
|
42
|
+
end
|
43
|
+
|
44
|
+
def required
|
45
|
+
"required" if options[:required]
|
46
|
+
end
|
47
|
+
|
48
|
+
def assets
|
49
|
+
@assets ||= [required, only, default_value].compact
|
50
|
+
end
|
51
|
+
|
52
|
+
def only
|
53
|
+
"only: `#{options[:values].inspect}`" if options[:values]
|
54
|
+
end
|
55
|
+
|
56
|
+
def default_value
|
57
|
+
"default: `#{options[:default].inspect}`" if options[:default]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module DocumentGrapeExtension
|
2
|
+
private
|
3
|
+
|
4
|
+
def has_validators?
|
5
|
+
!!(grape_request? && validators) || super
|
6
|
+
end
|
7
|
+
|
8
|
+
def route_info
|
9
|
+
@route_info ||= begin
|
10
|
+
grape_request? ? request.env["rack.routing_args"][:route_info] : nil
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def validators
|
15
|
+
if grape_request?
|
16
|
+
route_info.instance_variable_get(:@options)[:params]
|
17
|
+
else
|
18
|
+
super
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def parameters
|
23
|
+
if grape_request?
|
24
|
+
validators.map { |validator| Autodoc::Grape::Document::Parameter.new(validator) }.join("\n")
|
25
|
+
else
|
26
|
+
super
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def grape_request?
|
31
|
+
defined?(Grape) && request.env["rack.routing_args"][:route_info].instance_of?(Grape::Route) rescue false
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Autodoc::Document.send(:prepend, DocumentGrapeExtension)
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: autodoc-grape
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Keisuke Ishizawa
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: autodoc
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: grape
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.9'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 4.2.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 4.2.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sqlite3
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- muddyapesjm66@gmail.com
|
100
|
+
executables:
|
101
|
+
- console
|
102
|
+
- setup
|
103
|
+
extensions: []
|
104
|
+
extra_rdoc_files: []
|
105
|
+
files:
|
106
|
+
- ".gitignore"
|
107
|
+
- ".rspec"
|
108
|
+
- ".travis.yml"
|
109
|
+
- CODE_OF_CONDUCT.md
|
110
|
+
- Gemfile
|
111
|
+
- LICENSE.txt
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- autodoc-grape.gemspec
|
115
|
+
- bin/console
|
116
|
+
- bin/setup
|
117
|
+
- lib/autodoc/grape.rb
|
118
|
+
- lib/autodoc/grape/document/parameter.rb
|
119
|
+
- lib/autodoc/grape/monkey_patches/document_grape_extension.rb
|
120
|
+
- lib/autodoc/grape/version.rb
|
121
|
+
homepage: https://github.com/kei-p/autodoc-grape
|
122
|
+
licenses:
|
123
|
+
- MIT
|
124
|
+
metadata: {}
|
125
|
+
post_install_message:
|
126
|
+
rdoc_options: []
|
127
|
+
require_paths:
|
128
|
+
- lib
|
129
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
requirements: []
|
140
|
+
rubyforge_project:
|
141
|
+
rubygems_version: 2.2.2
|
142
|
+
signing_key:
|
143
|
+
specification_version: 4
|
144
|
+
summary: Autodoc for Grape API specs.
|
145
|
+
test_files: []
|