raddocs 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/raddocs.rb +14 -2
- data/lib/views/example.haml +32 -24
- data/lib/views/index.haml +6 -5
- metadata +54 -10
data/lib/raddocs.rb
CHANGED
@@ -5,12 +5,12 @@ class Raddocs < Sinatra::Base
|
|
5
5
|
set :haml, :format => :html5
|
6
6
|
|
7
7
|
get "/" do
|
8
|
-
index = JSON.parse(File.read("
|
8
|
+
index = JSON.parse(File.read("#{docs_dir}/index.json"))
|
9
9
|
haml :index, :locals => { :index => index }
|
10
10
|
end
|
11
11
|
|
12
12
|
get "/:resource/:example" do
|
13
|
-
example = JSON.parse(File.read("
|
13
|
+
example = JSON.parse(File.read("#{docs_dir}/#{params[:resource]}/#{params[:example]}.json"))
|
14
14
|
haml :example, :locals => { :example => example }
|
15
15
|
end
|
16
16
|
|
@@ -23,4 +23,16 @@ class Raddocs < Sinatra::Base
|
|
23
23
|
request.env["SCRIPT_NAME"]
|
24
24
|
end
|
25
25
|
end
|
26
|
+
|
27
|
+
class << self
|
28
|
+
attr_accessor :docs_dir
|
29
|
+
|
30
|
+
def docs_dir
|
31
|
+
@docs_dir ||= "docs"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def docs_dir
|
36
|
+
self.class.docs_dir
|
37
|
+
end
|
26
38
|
end
|
data/lib/views/example.haml
CHANGED
@@ -8,51 +8,59 @@
|
|
8
8
|
|
9
9
|
- if example["parameters"].count > 0
|
10
10
|
%h3 Parameters
|
11
|
-
%table
|
11
|
+
%table.parameters
|
12
12
|
%thead
|
13
13
|
%tr
|
14
14
|
%th Name
|
15
15
|
%th Description
|
16
16
|
%tbody
|
17
17
|
- example["parameters"].each do |param|
|
18
|
-
%tr
|
18
|
+
%tr.parameter
|
19
19
|
%td
|
20
20
|
%span.name= param["name"]
|
21
21
|
%td
|
22
22
|
%span.description= param["description"]
|
23
23
|
|
24
|
-
- example["requests"].
|
25
|
-
.request
|
24
|
+
- example["requests"].each_with_index do |request, index|
|
25
|
+
.request{ :id => "request-#{index}" }
|
26
26
|
%h3 Request
|
27
27
|
|
28
|
-
%
|
29
|
-
|
28
|
+
%section.headers
|
29
|
+
%h4 Headers
|
30
|
+
%pre.headers= request["request_headers"]
|
30
31
|
|
31
|
-
%
|
32
|
-
|
32
|
+
%section.route
|
33
|
+
%h4 Route
|
34
|
+
%pre.route.highlight== #{request["request_method"]} #{request["request_path"]}
|
33
35
|
|
34
36
|
- if request["request_query_parameters"]
|
35
|
-
%
|
36
|
-
|
37
|
+
%section.query-parameters
|
38
|
+
%h4 Query Parameters
|
39
|
+
%pre.query-parameters.highlight= request["request_query_parameters"]
|
37
40
|
|
38
41
|
- if request["request_body"]
|
39
|
-
%
|
40
|
-
|
42
|
+
%section.body
|
43
|
+
%h4 Body
|
44
|
+
.body= request["request_body"]
|
41
45
|
|
42
46
|
- if request["curl"]
|
43
|
-
%
|
44
|
-
|
47
|
+
%section.curl
|
48
|
+
%h4 cURL
|
49
|
+
%pre= request["curl"]
|
45
50
|
|
46
|
-
|
47
|
-
|
48
|
-
|
51
|
+
- if request["response_status"]
|
52
|
+
.response
|
53
|
+
%h3 Response
|
49
54
|
|
50
|
-
|
51
|
-
|
55
|
+
%section.headers
|
56
|
+
%h4 Headers
|
57
|
+
%pre.headers= request["response_headers"]
|
52
58
|
|
53
|
-
|
54
|
-
|
59
|
+
%section.status
|
60
|
+
%h4 Status
|
61
|
+
%pre.status= request["response_status"]
|
55
62
|
|
56
|
-
|
57
|
-
|
58
|
-
|
63
|
+
- if request["response_body"]
|
64
|
+
%section.body
|
65
|
+
%h4 Body
|
66
|
+
.body= request["response_body"]
|
data/lib/views/index.haml
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
%h1 Api Documentation
|
2
2
|
|
3
3
|
- index["resources"].each do |resource|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
.resource
|
5
|
+
%h2= resource["name"]
|
6
|
+
%ul.examples
|
7
|
+
- resource["examples"].each do |example|
|
8
|
+
%li.example
|
9
|
+
= link_to example["description"], "/#{example["link"].gsub(".json", "")}"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raddocs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
16
|
-
requirement: &
|
16
|
+
requirement: &70252117740960 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70252117740960
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: haml
|
27
|
-
requirement: &
|
27
|
+
requirement: &70252117699660 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70252117699660
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: json
|
38
|
-
requirement: &
|
38
|
+
requirement: &70252117638640 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,54 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70252117638640
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: &70252113306280 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70252113306280
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rack-test
|
60
|
+
requirement: &70252121997380 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70252121997380
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: capybara
|
71
|
+
requirement: &70252121924620 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70252121924620
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: rake
|
82
|
+
requirement: &70252121928480 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70252121928480
|
47
91
|
description: Browse documentation generated by the rspec_api_documentation gem
|
48
92
|
email:
|
49
|
-
- eric@
|
93
|
+
- eric@oestrich.org
|
50
94
|
executables: []
|
51
95
|
extensions: []
|
52
96
|
extra_rdoc_files: []
|
@@ -56,7 +100,7 @@ files:
|
|
56
100
|
- lib/views/example.haml
|
57
101
|
- lib/views/index.haml
|
58
102
|
- lib/views/layout.haml
|
59
|
-
homepage: http://
|
103
|
+
homepage: http://github.com/oestrich/raddocs
|
60
104
|
licenses: []
|
61
105
|
post_install_message:
|
62
106
|
rdoc_options: []
|