grape_doc 0.0.1
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.
- data/.gitignore +17 -0
- data/.rvmrc +48 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +9 -0
- data/LICENSE +22 -0
- data/README.md +83 -0
- data/Rakefile +6 -0
- data/bin/grape_doc +5 -0
- data/grape_doc.gemspec +19 -0
- data/lib/core_ext/object.rb +18 -0
- data/lib/grape_doc/api_document.rb +33 -0
- data/lib/grape_doc/api_parameter.rb +29 -0
- data/lib/grape_doc/api_parser.rb +19 -0
- data/lib/grape_doc/api_resource.rb +11 -0
- data/lib/grape_doc/doc_generator.rb +32 -0
- data/lib/grape_doc/formatters/markdown_formatter.rb +28 -0
- data/lib/grape_doc/version.rb +3 -0
- data/lib/grape_doc.rb +21 -0
- data/spec/api_document_spec.rb +28 -0
- data/spec/api_parameter_spec.rb +42 -0
- data/spec/api_parser_spec.rb +78 -0
- data/spec/api_resource_spec.rb +10 -0
- data/spec/api_response.rb +9 -0
- data/spec/doc_generator_spec.rb +8 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/test_classes/api.rb +9 -0
- data/spec/test_classes/projects.rb +42 -0
- data/spec/test_classes/users.rb +8 -0
- metadata +144 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
+
# development environment upon cd'ing into the directory
|
5
|
+
|
6
|
+
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
|
7
|
+
# Only full ruby name is supported here, for short names use:
|
8
|
+
# echo "rvm use 1.9.2" > .rvmrc
|
9
|
+
environment_id="ruby-1.9.2-p320@grape_doc"
|
10
|
+
|
11
|
+
# Uncomment the following lines if you want to verify rvm version per project
|
12
|
+
# rvmrc_rvm_version="1.13.6 (stable)" # 1.10.1 seams as a safe start
|
13
|
+
# eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
|
14
|
+
# echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
|
15
|
+
# return 1
|
16
|
+
# }
|
17
|
+
|
18
|
+
# First we attempt to load the desired environment directly from the environment
|
19
|
+
# file. This is very fast and efficient compared to running through the entire
|
20
|
+
# CLI and selector. If you want feedback on which environment was used then
|
21
|
+
# insert the word 'use' after --create as this triggers verbose mode.
|
22
|
+
if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
|
23
|
+
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
24
|
+
then
|
25
|
+
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
26
|
+
[[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
|
27
|
+
\. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
|
28
|
+
else
|
29
|
+
# If the environment file has not yet been created, use the RVM CLI to select.
|
30
|
+
rvm --create "$environment_id" || {
|
31
|
+
echo "Failed to create RVM environment '${environment_id}'."
|
32
|
+
return 1
|
33
|
+
}
|
34
|
+
fi
|
35
|
+
|
36
|
+
# If you use bundler, this might be useful to you:
|
37
|
+
# if [[ -s Gemfile ]] && {
|
38
|
+
# ! builtin command -v bundle >/dev/null ||
|
39
|
+
# builtin command -v bundle | GREP_OPTIONS= \grep $rvm_path/bin/bundle >/dev/null
|
40
|
+
# }
|
41
|
+
# then
|
42
|
+
# printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n"
|
43
|
+
# gem install bundler
|
44
|
+
# fi
|
45
|
+
# if [[ -s Gemfile ]] && builtin command -v bundle >/dev/null
|
46
|
+
# then
|
47
|
+
# bundle install | GREP_OPTIONS= \grep -vE '^Using|Your bundle is complete'
|
48
|
+
# fi
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Alex Denisov
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# GrapeDoc
|
2
|
+
|
3
|
+
This gem generate API documentation from Grape API.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile under development group
|
8
|
+
|
9
|
+
gem 'grape_doc'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install grape_doc
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
To generate API documentation you should cd to rails app directory
|
22
|
+
|
23
|
+
$ cd rails_app
|
24
|
+
|
25
|
+
Then run
|
26
|
+
|
27
|
+
$ grape_doc
|
28
|
+
|
29
|
+
It'll generate documentation for each Grape::API subclass and place it into **doc** directory. Each API subclass were placed as separated file.
|
30
|
+
|
31
|
+
You can pass a doc formatter as parameter
|
32
|
+
|
33
|
+
$ grape_doc markdown
|
34
|
+
|
35
|
+
_At this time it supports only MarkDown format._
|
36
|
+
|
37
|
+
## API description
|
38
|
+
|
39
|
+
### Parameters
|
40
|
+
|
41
|
+
#### grape > 0.2.1
|
42
|
+
|
43
|
+
desc "Returns a tweet."
|
44
|
+
params do
|
45
|
+
requires :id,
|
46
|
+
:type => Integer,
|
47
|
+
:desc => "Tweet id."
|
48
|
+
end
|
49
|
+
get '/show/:id' do
|
50
|
+
Tweet.find(params[:id])
|
51
|
+
end
|
52
|
+
|
53
|
+
#### grape <= 0.2.1
|
54
|
+
|
55
|
+
desc "Returns a tweet.",
|
56
|
+
:params => {
|
57
|
+
:id => {
|
58
|
+
:desc => "Tweet id.",
|
59
|
+
:type => Integer,
|
60
|
+
:requires => true
|
61
|
+
}
|
62
|
+
}
|
63
|
+
get '/show/:id' do
|
64
|
+
Tweet.find(params[:id])
|
65
|
+
end
|
66
|
+
|
67
|
+
## TODO
|
68
|
+
|
69
|
+
- generate plain response
|
70
|
+
- generate response from Grape::Entity
|
71
|
+
- generate response from Grape::Entity with nested entities
|
72
|
+
- other output formats
|
73
|
+
- write docs into separated files
|
74
|
+
- add code documentation
|
75
|
+
- and more others features
|
76
|
+
|
77
|
+
## Contributing
|
78
|
+
|
79
|
+
1. Fork it
|
80
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
81
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
82
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
83
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/grape_doc
ADDED
data/grape_doc.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/grape_doc/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Alex Denisov"]
|
6
|
+
gem.email = ["1101.debian@gmail.com"]
|
7
|
+
gem.description = %q{Documentation generator for Grape API}
|
8
|
+
gem.summary = %q{Documentation generator for Grape API}
|
9
|
+
gem.homepage = "https://github.com/AlexDenisov/grape_doc"
|
10
|
+
gem.files = `git ls-files`.split($\)
|
11
|
+
gem.executables << "grape_doc"
|
12
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
|
+
gem.name = "grape_doc"
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.version = GrapeDoc::VERSION
|
16
|
+
gem.add_runtime_dependency 'grape', '~> 0.2', '>= 0.2.1'
|
17
|
+
gem.add_runtime_dependency 'json', '~> 1.7', '>= 1.7.4'
|
18
|
+
gem.add_development_dependency 'rspec', '~> 2.11'
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Subclasses
|
2
|
+
def subclasses(direct = false)
|
3
|
+
classes = []
|
4
|
+
if direct
|
5
|
+
ObjectSpace.each_object(Class) do |c|
|
6
|
+
next unless c.superclass == self
|
7
|
+
classes << c
|
8
|
+
end
|
9
|
+
else
|
10
|
+
ObjectSpace.each_object(Class) do |c|
|
11
|
+
next unless c.ancestors.include?(self) and (c != self)
|
12
|
+
classes << c
|
13
|
+
end
|
14
|
+
end
|
15
|
+
classes
|
16
|
+
end
|
17
|
+
end
|
18
|
+
Object.send(:include, Subclasses)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module GrapeDoc
|
2
|
+
class APIDocument
|
3
|
+
attr_accessor :resource_name,
|
4
|
+
:path,
|
5
|
+
:description,
|
6
|
+
:params,
|
7
|
+
:response,
|
8
|
+
:http_method,
|
9
|
+
:empty
|
10
|
+
def initialize(resource = nil, route = nil)
|
11
|
+
return if route.nil?
|
12
|
+
if route.route_path == "/:version/(.:format)"
|
13
|
+
self.empty = true
|
14
|
+
return
|
15
|
+
end
|
16
|
+
self.path = route.route_path.gsub('(.:format)','')
|
17
|
+
self.resource_name = resource
|
18
|
+
self.http_method = route.route_method
|
19
|
+
self.description = route.route_description
|
20
|
+
self.params = APIParameter.initialize_parameters route.route_params
|
21
|
+
self.response = nil_or_empty route.route_response
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def nil_or_empty(hash)
|
26
|
+
if hash
|
27
|
+
return hash.empty? ? nil : hash
|
28
|
+
end
|
29
|
+
hash
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module GrapeDoc
|
2
|
+
class APIParameter
|
3
|
+
attr_accessor :field,
|
4
|
+
:description,
|
5
|
+
:sample_value,
|
6
|
+
:field_type,
|
7
|
+
:required
|
8
|
+
def initialize(parameter_name = nil,
|
9
|
+
parameter_hash = nil)
|
10
|
+
return if parameter_name.nil? or
|
11
|
+
parameter_hash.nil? or
|
12
|
+
parameter_hash.empty? or
|
13
|
+
parameter_name.empty?
|
14
|
+
self.field = parameter_name.to_s
|
15
|
+
self.required = parameter_hash[:requires] ||
|
16
|
+
parameter_hash[:required]
|
17
|
+
self.description = parameter_hash[:desc] ||
|
18
|
+
parameter_hash[:description]
|
19
|
+
end
|
20
|
+
def self.initialize_parameters(params_hash)
|
21
|
+
params = params_hash.map do |name, hash|
|
22
|
+
APIParameter.new(name, hash)
|
23
|
+
end
|
24
|
+
return nil if params.empty?
|
25
|
+
params
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module GrapeDoc
|
2
|
+
class APIParser
|
3
|
+
def self.parse(klass)
|
4
|
+
return nil if klass.routes.count.zero?
|
5
|
+
documents = klass.routes.map do |route|
|
6
|
+
resource = klass.to_s.split("::").last
|
7
|
+
document = APIDocument.new(resource, route)
|
8
|
+
if document.empty
|
9
|
+
nil
|
10
|
+
else
|
11
|
+
document
|
12
|
+
end
|
13
|
+
end.compact.sort_by{ |doc| doc.resource_name }
|
14
|
+
end
|
15
|
+
def parse(klass)
|
16
|
+
self.class.parse klass
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module GrapeDoc
|
2
|
+
class DOCGenerator
|
3
|
+
attr_accessor :resources,
|
4
|
+
:formatter,
|
5
|
+
:single_file
|
6
|
+
def initialize
|
7
|
+
self.resources = Grape::API.subclasses.map do |klass|
|
8
|
+
resource = APIResource.new(klass)
|
9
|
+
if resource.documents.nil? or resource.documents.count.zero?
|
10
|
+
nil
|
11
|
+
else
|
12
|
+
resource
|
13
|
+
end
|
14
|
+
end.compact.sort_by{ |res| res.resource_name }
|
15
|
+
end
|
16
|
+
|
17
|
+
def init_formatter
|
18
|
+
return GrapeDoc::MarkdownFormatter.new self.formatter.nil?
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
def generate
|
23
|
+
doc_formatter = init_formatter
|
24
|
+
generated_resources = self.resources.map do | resource |
|
25
|
+
doc_formatter.generate_resource_doc resource
|
26
|
+
end.join
|
27
|
+
output = File.open("#{Dir.pwd}/doc/api.md", "w")
|
28
|
+
output << generated_resources
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module GrapeDoc
|
2
|
+
class MarkdownFormatter
|
3
|
+
def generate_resource_doc(resource)
|
4
|
+
title = "### #{resource.resource_name}\n"
|
5
|
+
|
6
|
+
documents = resource.documents.map do |document|
|
7
|
+
path = "#### #{document.http_method} #{document.path}\n\n"
|
8
|
+
description = "#{document.description}\n\n"
|
9
|
+
|
10
|
+
parameters = document.params.map do |parameter|
|
11
|
+
next if parameter.field.nil? or parameter.field.empty?
|
12
|
+
param = " - #{parameter.field}"
|
13
|
+
param += " (#{parameter.field_type})" if parameter.field_type
|
14
|
+
param += " (required)" if parameter.required
|
15
|
+
param += " : #{parameter.description}\n\n"
|
16
|
+
end.join if document.params
|
17
|
+
|
18
|
+
route = "#{path} #{description}"
|
19
|
+
route += "**Parameters:** \n\n\n#{parameters}" if parameters
|
20
|
+
route += "\n\n"
|
21
|
+
|
22
|
+
end.join
|
23
|
+
return "" if documents.nil? or documents.empty?
|
24
|
+
"#{title}\n\n\n#{documents}\n"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
data/lib/grape_doc.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'core_ext/object'
|
2
|
+
require 'grape_doc/version'
|
3
|
+
require 'grape_doc/api_document'
|
4
|
+
require 'grape_doc/api_parser'
|
5
|
+
require 'grape_doc/api_parameter'
|
6
|
+
require 'grape_doc/api_resource'
|
7
|
+
require 'grape_doc/doc_generator'
|
8
|
+
require 'grape_doc/formatters/markdown_formatter'
|
9
|
+
|
10
|
+
begin
|
11
|
+
require File.expand_path(Dir.pwd + "/config/environment")
|
12
|
+
rescue LoadError => ex
|
13
|
+
puts "#{ex}"
|
14
|
+
end
|
15
|
+
|
16
|
+
module GrapeDoc
|
17
|
+
def self.generate_doc
|
18
|
+
generator = DOCGenerator.new
|
19
|
+
generator.generate
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "GrapeDoc::APIDocument" do
|
4
|
+
describe "should respond to" do
|
5
|
+
let(:api_document) {
|
6
|
+
GrapeDoc::APIDocument.new
|
7
|
+
}
|
8
|
+
it "resource" do
|
9
|
+
api_document.respond_to?(:resource_name).should be_true
|
10
|
+
end
|
11
|
+
it "path" do
|
12
|
+
api_document.respond_to?(:path).should be_true
|
13
|
+
end
|
14
|
+
it "description" do
|
15
|
+
api_document.respond_to?(:description).should be_true
|
16
|
+
end
|
17
|
+
it "params" do
|
18
|
+
api_document.respond_to?(:params).should be_true
|
19
|
+
end
|
20
|
+
it "response" do
|
21
|
+
api_document.respond_to?(:response).should be_true
|
22
|
+
end
|
23
|
+
it "http_method" do
|
24
|
+
api_document.respond_to?(:http_method).should be_true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'test_classes/projects'
|
3
|
+
|
4
|
+
include GrapeDoc
|
5
|
+
|
6
|
+
describe GrapeDoc::APIParameter do
|
7
|
+
let(:parser) { APIParser.new }
|
8
|
+
let(:parameter) { APIParameter.new }
|
9
|
+
|
10
|
+
describe "should respond to" do
|
11
|
+
it "field" do
|
12
|
+
parameter.respond_to?(:field).should be_true
|
13
|
+
end
|
14
|
+
it "description" do
|
15
|
+
parameter.respond_to?(:description).should be_true
|
16
|
+
end
|
17
|
+
it "sample_value" do
|
18
|
+
parameter.respond_to?(:sample_value).should be_true
|
19
|
+
end
|
20
|
+
it "field_type" do
|
21
|
+
parameter.respond_to?(:field_type).should be_true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "initialize within different data" do
|
26
|
+
it "parse PUT project" do
|
27
|
+
document = parser.parse(Projects)[2]
|
28
|
+
params = document.params
|
29
|
+
params.each do |p|
|
30
|
+
p.kind_of?(APIParameter).should be_true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
it "parse PUT project with parameters" do
|
34
|
+
document = parser.parse(Projects)[2]
|
35
|
+
param = document.params.first
|
36
|
+
param.field.should == "project_id"
|
37
|
+
param.description.should == "Project ID"
|
38
|
+
param.required.should be_true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'test_classes/projects'
|
4
|
+
require 'test_classes/users'
|
5
|
+
include GrapeDoc
|
6
|
+
|
7
|
+
describe GrapeDoc::APIParser do
|
8
|
+
let(:parser) { APIParser.new }
|
9
|
+
describe "parse empty child class" do
|
10
|
+
it "should return nil" do
|
11
|
+
parser.parse(Users).should be_nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
describe "parse non-empty child class" do
|
15
|
+
it "should_not return nil" do
|
16
|
+
parser.parse(Projects).should_not be_nil
|
17
|
+
end
|
18
|
+
it "should return two documents" do
|
19
|
+
parser.parse(Projects).count.should == 4
|
20
|
+
end
|
21
|
+
it "should return array of APIDocument objects" do
|
22
|
+
parser.parse(Projects).each do |document|
|
23
|
+
document.kind_of?(APIDocument).should be_true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
it "should parse GET route without meta info" do
|
27
|
+
document = parser.parse(Projects).first
|
28
|
+
document.resource_name.should == "Projects"
|
29
|
+
document.path.should == "/projects"
|
30
|
+
document.http_method.should == "GET"
|
31
|
+
document.description.should be_nil
|
32
|
+
document.params.should be_nil
|
33
|
+
document.response.should be_nil
|
34
|
+
end
|
35
|
+
it "should parse POST route within meta info" do
|
36
|
+
document = parser.parse(Projects)[1]
|
37
|
+
document.resource_name.should == "Projects"
|
38
|
+
document.path.should == "/projects"
|
39
|
+
document.http_method.should == "POST"
|
40
|
+
document.description.should == "Create Project"
|
41
|
+
document.params.should be_nil
|
42
|
+
document.response.should be_nil
|
43
|
+
end
|
44
|
+
it "should parse PUT route within meta info" do
|
45
|
+
params = {
|
46
|
+
:project_id => {
|
47
|
+
:desc => "Project ID",
|
48
|
+
:required => true
|
49
|
+
}
|
50
|
+
}
|
51
|
+
document = parser.parse(Projects)[2]
|
52
|
+
document.resource_name.should == "Projects"
|
53
|
+
document.path.should == "/projects"
|
54
|
+
document.http_method.should == "PUT"
|
55
|
+
document.description.should == "Update Project"
|
56
|
+
document.response.should be_nil
|
57
|
+
end
|
58
|
+
it "should parse DELETE route within meta info" do
|
59
|
+
params = {
|
60
|
+
:project_id => {
|
61
|
+
:desc => "Project ID",
|
62
|
+
:required => true
|
63
|
+
}
|
64
|
+
}
|
65
|
+
response = {
|
66
|
+
:status => true
|
67
|
+
}
|
68
|
+
document = parser.parse(Projects)[3]
|
69
|
+
document.resource_name.should == "Projects"
|
70
|
+
document.path.should == "/projects"
|
71
|
+
document.http_method.should == "DELETE"
|
72
|
+
document.description.should == "Delete Project"
|
73
|
+
# document.params.should == params
|
74
|
+
document.response.should == response
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
module GrapeDoc
|
2
|
+
class Projects < Grape::API
|
3
|
+
resource :projects do
|
4
|
+
get do
|
5
|
+
|
6
|
+
end
|
7
|
+
|
8
|
+
desc "Create Project"
|
9
|
+
post do
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Update Project", {
|
14
|
+
:params => {
|
15
|
+
:project_id => {
|
16
|
+
:desc => "Project ID",
|
17
|
+
:required => true
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
put do
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Delete Project", {
|
26
|
+
:params => {
|
27
|
+
:project_id => {
|
28
|
+
:desc => "Project ID",
|
29
|
+
:required => true
|
30
|
+
}
|
31
|
+
},
|
32
|
+
:response => {
|
33
|
+
:status => true
|
34
|
+
}
|
35
|
+
}
|
36
|
+
delete do
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: grape_doc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alex Denisov
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: grape
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0.2'
|
22
|
+
- - ! '>='
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.2.1
|
25
|
+
type: :runtime
|
26
|
+
prerelease: false
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0.2'
|
33
|
+
- - ! '>='
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 0.2.1
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: json
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1.7'
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.7.4
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 1.7.4
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rspec
|
60
|
+
requirement: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '2.11'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ~>
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '2.11'
|
74
|
+
description: Documentation generator for Grape API
|
75
|
+
email:
|
76
|
+
- 1101.debian@gmail.com
|
77
|
+
executables:
|
78
|
+
- grape_doc
|
79
|
+
extensions: []
|
80
|
+
extra_rdoc_files: []
|
81
|
+
files:
|
82
|
+
- .gitignore
|
83
|
+
- .rvmrc
|
84
|
+
- CHANGELOG.md
|
85
|
+
- Gemfile
|
86
|
+
- LICENSE
|
87
|
+
- README.md
|
88
|
+
- Rakefile
|
89
|
+
- bin/grape_doc
|
90
|
+
- grape_doc.gemspec
|
91
|
+
- lib/core_ext/object.rb
|
92
|
+
- lib/grape_doc.rb
|
93
|
+
- lib/grape_doc/api_document.rb
|
94
|
+
- lib/grape_doc/api_parameter.rb
|
95
|
+
- lib/grape_doc/api_parser.rb
|
96
|
+
- lib/grape_doc/api_resource.rb
|
97
|
+
- lib/grape_doc/doc_generator.rb
|
98
|
+
- lib/grape_doc/formatters/markdown_formatter.rb
|
99
|
+
- lib/grape_doc/version.rb
|
100
|
+
- spec/api_document_spec.rb
|
101
|
+
- spec/api_parameter_spec.rb
|
102
|
+
- spec/api_parser_spec.rb
|
103
|
+
- spec/api_resource_spec.rb
|
104
|
+
- spec/api_response.rb
|
105
|
+
- spec/doc_generator_spec.rb
|
106
|
+
- spec/spec_helper.rb
|
107
|
+
- spec/test_classes/api.rb
|
108
|
+
- spec/test_classes/projects.rb
|
109
|
+
- spec/test_classes/users.rb
|
110
|
+
homepage: https://github.com/AlexDenisov/grape_doc
|
111
|
+
licenses: []
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
118
|
+
requirements:
|
119
|
+
- - ! '>='
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ! '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 1.8.24
|
131
|
+
signing_key:
|
132
|
+
specification_version: 3
|
133
|
+
summary: Documentation generator for Grape API
|
134
|
+
test_files:
|
135
|
+
- spec/api_document_spec.rb
|
136
|
+
- spec/api_parameter_spec.rb
|
137
|
+
- spec/api_parser_spec.rb
|
138
|
+
- spec/api_resource_spec.rb
|
139
|
+
- spec/api_response.rb
|
140
|
+
- spec/doc_generator_spec.rb
|
141
|
+
- spec/spec_helper.rb
|
142
|
+
- spec/test_classes/api.rb
|
143
|
+
- spec/test_classes/projects.rb
|
144
|
+
- spec/test_classes/users.rb
|