rspec-api-documentation 1.1.1.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/lib/rspec_api_documentation.rb +63 -0
  3. data/lib/rspec_api_documentation/api_documentation.rb +38 -0
  4. data/lib/rspec_api_documentation/api_formatter.rb +45 -0
  5. data/lib/rspec_api_documentation/client_base.rb +82 -0
  6. data/lib/rspec_api_documentation/configuration.rb +84 -0
  7. data/lib/rspec_api_documentation/curl.rb +61 -0
  8. data/lib/rspec_api_documentation/dsl.rb +17 -0
  9. data/lib/rspec_api_documentation/dsl/callback.rb +25 -0
  10. data/lib/rspec_api_documentation/dsl/endpoint.rb +134 -0
  11. data/lib/rspec_api_documentation/dsl/resource.rb +83 -0
  12. data/lib/rspec_api_documentation/example.rb +49 -0
  13. data/lib/rspec_api_documentation/headers.rb +32 -0
  14. data/lib/rspec_api_documentation/index.rb +7 -0
  15. data/lib/rspec_api_documentation/oauth2_mac_client.rb +70 -0
  16. data/lib/rspec_api_documentation/rack_test_client.rb +58 -0
  17. data/lib/rspec_api_documentation/railtie.rb +7 -0
  18. data/lib/rspec_api_documentation/test_server.rb +31 -0
  19. data/lib/rspec_api_documentation/views/html_example.rb +16 -0
  20. data/lib/rspec_api_documentation/views/html_index.rb +14 -0
  21. data/lib/rspec_api_documentation/views/markup_example.rb +58 -0
  22. data/lib/rspec_api_documentation/views/markup_index.rb +21 -0
  23. data/lib/rspec_api_documentation/views/textile_example.rb +16 -0
  24. data/lib/rspec_api_documentation/views/textile_index.rb +14 -0
  25. data/lib/rspec_api_documentation/writers/combined_json_writer.rb +20 -0
  26. data/lib/rspec_api_documentation/writers/combined_text_writer.rb +106 -0
  27. data/lib/rspec_api_documentation/writers/formatter.rb +11 -0
  28. data/lib/rspec_api_documentation/writers/general_markup_writer.rb +42 -0
  29. data/lib/rspec_api_documentation/writers/html_writer.rb +21 -0
  30. data/lib/rspec_api_documentation/writers/index_writer.rb +16 -0
  31. data/lib/rspec_api_documentation/writers/json_iodocs_writer.rb +111 -0
  32. data/lib/rspec_api_documentation/writers/json_writer.rb +111 -0
  33. data/lib/rspec_api_documentation/writers/textile_writer.rb +21 -0
  34. data/lib/tasks/docs.rake +7 -0
  35. data/templates/rspec_api_documentation/html_example.mustache +106 -0
  36. data/templates/rspec_api_documentation/html_index.mustache +34 -0
  37. data/templates/rspec_api_documentation/textile_example.mustache +68 -0
  38. data/templates/rspec_api_documentation/textile_index.mustache +10 -0
  39. metadata +267 -0
@@ -0,0 +1,21 @@
1
+ module RspecApiDocumentation
2
+ module Writers
3
+ class TextileWriter < GeneralMarkupWriter
4
+ attr_accessor :index, :configuration
5
+
6
+ EXTENSION = 'textile'
7
+
8
+ def markup_index_class
9
+ RspecApiDocumentation::Views::TextileIndex
10
+ end
11
+
12
+ def markup_example_class
13
+ RspecApiDocumentation::Views::TextileExample
14
+ end
15
+
16
+ def extension
17
+ EXTENSION
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,7 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ desc 'Generate API request documentation from API specs'
4
+ RSpec::Core::RakeTask.new('docs:generate') do |t|
5
+ t.pattern = 'spec/acceptance/**/*_spec.rb'
6
+ t.rspec_opts = ["--format RspecApiDocumentation::ApiFormatter"]
7
+ end
@@ -0,0 +1,106 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>{{resource_name}} API</title>
5
+ <meta charset="utf-8">
6
+ <style>
7
+ td.required .name:after {
8
+ float: right;
9
+ content: "required";
10
+ font-weight: normal;
11
+ color: #F08080;
12
+ }
13
+
14
+ p {
15
+ padding: 15px;
16
+ font-size: 130%;
17
+ }
18
+
19
+ pre {
20
+ white-space: pre-wrap;
21
+ }
22
+
23
+ body {
24
+ margin-left: auto;
25
+ margin-right: auto;
26
+ width: 900px;
27
+ }
28
+ </style>
29
+ </head>
30
+ <body>
31
+ <div class="container">
32
+ <h1>{{resource_name}} API</h1>
33
+
34
+ <div class="article">
35
+ <h2>{{ description }}</h2>
36
+ <h3>{{ http_method }} {{ route }}</h3>
37
+ {{# explanation }}
38
+ <p class="explanation">
39
+ {{ explanation }}
40
+ </p>
41
+ {{/ explanation }}
42
+
43
+ {{# has_parameters? }}
44
+ <h3>Parameters</h3>
45
+ <table class="parameters table table-striped table-bordered table-condensed">
46
+ <thead>
47
+ <tr>
48
+ <th>Name</th>
49
+ <th>Description</th>
50
+ </tr>
51
+ </thead>
52
+ <tbody>
53
+ {{# parameters }}
54
+ <tr>
55
+ <td{{# required }} class="required"{{/ required }}>
56
+ <span class="name">{{ name }}</span>
57
+ </td>
58
+ <td>
59
+ <span class="description">{{ description }}</span>
60
+ </td>
61
+ </tr>
62
+ {{/ parameters }}
63
+ </tbody>
64
+ </table>
65
+ {{/ has_parameters? }}
66
+
67
+ {{# requests }}
68
+ <h3>Request</h3>
69
+
70
+ <h4>Headers</h4>
71
+ <pre class="request headers">{{ request_headers_text }}</pre>
72
+
73
+ <h4>Route</h4>
74
+ <pre class="request route highlight">{{ request_method }} {{ request_path }}</pre>
75
+
76
+ {{# request_query_parameters_text }}
77
+ <h4>Query Parameters</h4>
78
+ <pre class="request query_parameters highlight">{{ request_query_parameters_text }}</pre>
79
+ {{/ request_query_parameters_text }}
80
+
81
+ {{# request_body }}
82
+ <h4>Body</h4>
83
+ <pre class="request body">{{{ request_body }}}</pre>
84
+ {{/ request_body }}
85
+
86
+ {{# curl }}
87
+ <h4>cURL</h4>
88
+ <pre class="request">{{ curl }}</pre>
89
+ {{/ curl }}
90
+
91
+ {{# response_status }}
92
+ <h3>Response</h3>
93
+ <h4>Headers</h4>
94
+ <pre class="response headers">{{ response_headers_text }}</pre>
95
+ <h4>Status</h4>
96
+ <pre class="response status">{{ response_status }} {{ response_status_text}}</pre>
97
+ {{# response_body }}
98
+ <h4>Body</h4>
99
+ <pre class="response body">{{{ response_body }}}</pre>
100
+ {{/ response_body }}
101
+ {{/ response_status }}
102
+ {{/ requests }}
103
+ </div>
104
+ </div>
105
+ </body>
106
+ </html>
@@ -0,0 +1,34 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>{{ api_name }}</title>
5
+ <meta charset="utf-8">
6
+
7
+ <style>
8
+ body {
9
+ margin-left: auto;
10
+ margin-right: auto;
11
+ width: 900px;
12
+ }
13
+ </style>
14
+ </head>
15
+ <body>
16
+ <div class="container">
17
+ <h1>{{ api_name }}</h1>
18
+
19
+ {{# sections }}
20
+ <div class="article">
21
+ <h2>{{ resource_name }}</h2>
22
+
23
+ <ul>
24
+ {{# examples }}
25
+ <li>
26
+ <a href="{{ dirname }}/{{ filename }}">{{ description }}</a>
27
+ </li>
28
+ {{/ examples }}
29
+ </ul>
30
+ </div>
31
+ {{/ sections }}
32
+ </div>
33
+ </body>
34
+ </html>
@@ -0,0 +1,68 @@
1
+ h1. {{ resource_name }} API
2
+
3
+ h2. {{ description }}
4
+
5
+ h3. {{ http_method }} {{ route }}
6
+
7
+ {{# explanation }}
8
+ {{ explanation }}
9
+ {{/ explanation }}
10
+
11
+ {{# has_parameters? }}
12
+ h3. Parameters
13
+ {{# parameters }}
14
+
15
+ Name : {{ name }} {{# required }} *- required -*{{/ required }}
16
+ Description : {{ description }}
17
+ {{/ parameters }}
18
+ {{/ has_parameters? }}
19
+
20
+ {{# requests }}
21
+ h3. Request
22
+
23
+ h4. Headers
24
+
25
+ <pre>{{ request_headers_text }}</pre>
26
+
27
+ h4. Route
28
+
29
+ <pre>{{ request_method }} {{ request_path }}</pre>
30
+
31
+ {{# request_query_parameters_text }}
32
+ h4. Query Parameters
33
+
34
+ <pre>{{ request_query_parameters_text }}</pre>
35
+ {{/ request_query_parameters_text }}
36
+
37
+ {{# request_body }}
38
+ h4. Body
39
+
40
+ <pre>{{{ request_body }}}</pre>
41
+ {{/ request_body }}
42
+
43
+ {{# curl }}
44
+ h4. cURL
45
+
46
+ <pre class="request">{{ curl }}</pre>
47
+ {{/ curl }}
48
+
49
+ {{# response_status }}
50
+ h3. Response
51
+
52
+ h4. Headers
53
+
54
+ <pre>{{ response_headers_text }}</pre>
55
+
56
+ h4. Status
57
+
58
+ <pre>{{ response_status }} {{ response_status_text}}</pre>
59
+
60
+ {{# response_body }}
61
+ h4. Body
62
+
63
+ <pre>{{{ response_body }}}</pre>
64
+ {{/ response_body }}
65
+ {{/ response_status }}
66
+
67
+ {{/ requests }}
68
+
@@ -0,0 +1,10 @@
1
+ h1. {{ api_name }}
2
+
3
+ {{# sections }}
4
+ h2. {{ resource_name }}
5
+
6
+ {{# examples }}
7
+ * "{{ description }}":{{ dirname }}/{{ filename }}
8
+ {{/ examples }}
9
+
10
+ {{/ sections }}
metadata ADDED
@@ -0,0 +1,267 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rspec-api-documentation
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.1.alpha
5
+ platform: ruby
6
+ authors:
7
+ - Chris Cahoon
8
+ - Sam Goldman
9
+ - Eric Oestrich
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-09-13 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.14.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - '>='
27
+ - !ruby/object:Gem::Version
28
+ version: 2.14.0
29
+ - !ruby/object:Gem::Dependency
30
+ name: activesupport
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - '>='
34
+ - !ruby/object:Gem::Version
35
+ version: 3.0.0
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - '>='
41
+ - !ruby/object:Gem::Version
42
+ version: 3.0.0
43
+ - !ruby/object:Gem::Dependency
44
+ name: i18n
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - '>='
48
+ - !ruby/object:Gem::Version
49
+ version: 0.1.0
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - '>='
55
+ - !ruby/object:Gem::Version
56
+ version: 0.1.0
57
+ - !ruby/object:Gem::Dependency
58
+ name: mustache
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - '>='
62
+ - !ruby/object:Gem::Version
63
+ version: 0.99.4
64
+ type: :runtime
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - '>='
69
+ - !ruby/object:Gem::Version
70
+ version: 0.99.4
71
+ - !ruby/object:Gem::Dependency
72
+ name: webmock
73
+ requirement: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 1.7.0
78
+ type: :runtime
79
+ prerelease: false
80
+ version_requirements: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - '>='
83
+ - !ruby/object:Gem::Version
84
+ version: 1.7.0
85
+ - !ruby/object:Gem::Dependency
86
+ name: json
87
+ requirement: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - '>='
90
+ - !ruby/object:Gem::Version
91
+ version: 1.4.6
92
+ type: :runtime
93
+ prerelease: false
94
+ version_requirements: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - '>='
97
+ - !ruby/object:Gem::Version
98
+ version: 1.4.6
99
+ - !ruby/object:Gem::Dependency
100
+ name: fakefs
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - '>='
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ type: :development
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ - !ruby/object:Gem::Dependency
114
+ name: sinatra
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ type: :development
121
+ prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ - !ruby/object:Gem::Dependency
128
+ name: aruba
129
+ requirement: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :development
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ - !ruby/object:Gem::Dependency
142
+ name: capybara
143
+ requirement: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ type: :development
149
+ prerelease: false
150
+ version_requirements: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ - !ruby/object:Gem::Dependency
156
+ name: rake
157
+ requirement: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - '>='
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ type: :development
163
+ prerelease: false
164
+ version_requirements: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - '>='
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ - !ruby/object:Gem::Dependency
170
+ name: rack-test
171
+ requirement: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - '>='
174
+ - !ruby/object:Gem::Version
175
+ version: 0.6.2
176
+ type: :development
177
+ prerelease: false
178
+ version_requirements: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - '>='
181
+ - !ruby/object:Gem::Version
182
+ version: 0.6.2
183
+ - !ruby/object:Gem::Dependency
184
+ name: rack-oauth2
185
+ requirement: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - '>='
188
+ - !ruby/object:Gem::Version
189
+ version: 0.14.4
190
+ type: :development
191
+ prerelease: false
192
+ version_requirements: !ruby/object:Gem::Requirement
193
+ requirements:
194
+ - - '>='
195
+ - !ruby/object:Gem::Version
196
+ version: 0.14.4
197
+ description: Generate API docs from your test suite
198
+ email:
199
+ - chris@smartlogicsolutions.com
200
+ - sam@smartlogicsolutions.com
201
+ - eric@smartlogicsolutions.com
202
+ executables: []
203
+ extensions: []
204
+ extra_rdoc_files: []
205
+ files:
206
+ - lib/rspec_api_documentation/api_documentation.rb
207
+ - lib/rspec_api_documentation/api_formatter.rb
208
+ - lib/rspec_api_documentation/client_base.rb
209
+ - lib/rspec_api_documentation/configuration.rb
210
+ - lib/rspec_api_documentation/curl.rb
211
+ - lib/rspec_api_documentation/dsl/callback.rb
212
+ - lib/rspec_api_documentation/dsl/endpoint.rb
213
+ - lib/rspec_api_documentation/dsl/resource.rb
214
+ - lib/rspec_api_documentation/dsl.rb
215
+ - lib/rspec_api_documentation/example.rb
216
+ - lib/rspec_api_documentation/headers.rb
217
+ - lib/rspec_api_documentation/index.rb
218
+ - lib/rspec_api_documentation/oauth2_mac_client.rb
219
+ - lib/rspec_api_documentation/rack_test_client.rb
220
+ - lib/rspec_api_documentation/railtie.rb
221
+ - lib/rspec_api_documentation/test_server.rb
222
+ - lib/rspec_api_documentation/views/html_example.rb
223
+ - lib/rspec_api_documentation/views/html_index.rb
224
+ - lib/rspec_api_documentation/views/markup_example.rb
225
+ - lib/rspec_api_documentation/views/markup_index.rb
226
+ - lib/rspec_api_documentation/views/textile_example.rb
227
+ - lib/rspec_api_documentation/views/textile_index.rb
228
+ - lib/rspec_api_documentation/writers/combined_json_writer.rb
229
+ - lib/rspec_api_documentation/writers/combined_text_writer.rb
230
+ - lib/rspec_api_documentation/writers/formatter.rb
231
+ - lib/rspec_api_documentation/writers/general_markup_writer.rb
232
+ - lib/rspec_api_documentation/writers/html_writer.rb
233
+ - lib/rspec_api_documentation/writers/index_writer.rb
234
+ - lib/rspec_api_documentation/writers/json_iodocs_writer.rb
235
+ - lib/rspec_api_documentation/writers/json_writer.rb
236
+ - lib/rspec_api_documentation/writers/textile_writer.rb
237
+ - lib/rspec_api_documentation.rb
238
+ - lib/tasks/docs.rake
239
+ - templates/rspec_api_documentation/html_example.mustache
240
+ - templates/rspec_api_documentation/html_index.mustache
241
+ - templates/rspec_api_documentation/textile_example.mustache
242
+ - templates/rspec_api_documentation/textile_index.mustache
243
+ homepage: http://smartlogicsolutions.com
244
+ licenses: []
245
+ metadata: {}
246
+ post_install_message:
247
+ rdoc_options: []
248
+ require_paths:
249
+ - lib
250
+ required_ruby_version: !ruby/object:Gem::Requirement
251
+ requirements:
252
+ - - '>='
253
+ - !ruby/object:Gem::Version
254
+ version: '0'
255
+ required_rubygems_version: !ruby/object:Gem::Requirement
256
+ requirements:
257
+ - - '>='
258
+ - !ruby/object:Gem::Version
259
+ version: 1.3.6
260
+ requirements: []
261
+ rubyforge_project:
262
+ rubygems_version: 2.1.0
263
+ signing_key:
264
+ specification_version: 4
265
+ summary: A double black belt for your docs
266
+ test_files: []
267
+ has_rdoc: