dox 1.0.0 → 1.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.
- checksums.yaml +4 -4
- data/CHANGES.md +11 -0
- data/README.md +35 -2
- data/lib/dox/entities/example.rb +8 -4
- data/lib/dox/printers/example_printer.rb +2 -2
- data/lib/dox/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 658311eb3318384ac31608e40c9926544f24e170
|
4
|
+
data.tar.gz: 35832e0fa318b5d019a3d03765612fe1f7523b4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81e5317ed65beaf22e632932e1b03df01e4933fa982b57ec85d3e1b07a5bf8a95512e67b726a6e2370a88dc3799ac0dd0fb60b8ebab66ee5db1ed6344867abca
|
7
|
+
data.tar.gz: 5cf6550f640579aa530c229e60ceb6c1fbdaeb9d4910dba247dc961503c21eb020044fd203dab03e21c6ed33716c14ad8917033b253cf8e7e8c5d68f57382baf
|
data/CHANGES.md
CHANGED
data/README.md
CHANGED
@@ -242,13 +242,46 @@ end
|
|
242
242
|
### Generate documentation
|
243
243
|
Documentation is generated in 2 steps:
|
244
244
|
|
245
|
-
1. generate API Blueprint markdown
|
246
|
-
```bundle exec
|
245
|
+
1. generate API Blueprint markdown:
|
246
|
+
```bundle exec rspec spec/controllers/api/v1 -f Dox::Formatter --order defined --tag dox --out docs.md```
|
247
247
|
|
248
248
|
2. render HTML with some renderer, for example, with Aglio:
|
249
249
|
```aglio -i docs.md -o docs.html```
|
250
250
|
|
251
251
|
|
252
|
+
#### Use Rake tasks
|
253
|
+
It's recommendable to write a few Rake tasks to make things easier. Here's an example:
|
254
|
+
|
255
|
+
```ruby
|
256
|
+
namespace :api do
|
257
|
+
namespace :doc do
|
258
|
+
desc 'Generate API documentation markdown'
|
259
|
+
task :md do
|
260
|
+
require 'rspec/core/rake_task'
|
261
|
+
|
262
|
+
RSpec::Core::RakeTask.new(:api_spec) do |t|
|
263
|
+
t.pattern = 'spec/controllers/api/v1/'
|
264
|
+
t.rspec_opts = "-f Dox::Formatter --order defined --tag dox --out public/api/docs/v1/apispec.md"
|
265
|
+
end
|
266
|
+
|
267
|
+
Rake::Task['api_spec'].invoke
|
268
|
+
end
|
269
|
+
|
270
|
+
task html: :md do
|
271
|
+
`aglio -i public/api/docs/v1/apispec.md -o public/api/docs/v1/index.html`
|
272
|
+
end
|
273
|
+
|
274
|
+
task open: :html do
|
275
|
+
`open public/api/docs/v1/index.html`
|
276
|
+
end
|
277
|
+
|
278
|
+
task publish: :md do
|
279
|
+
`apiary publish --path=public/api/docs/v1/apispec.md --api-name=doxdemo`
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
```
|
284
|
+
|
252
285
|
#### Renderers
|
253
286
|
You can render the HTML yourself with one of the renderers:
|
254
287
|
|
data/lib/dox/entities/example.rb
CHANGED
@@ -15,10 +15,8 @@ module Dox
|
|
15
15
|
@response = response
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
|
20
|
-
.except(*request.path_parameters.keys.map(&:to_s))
|
21
|
-
.except(*request.query_parameters.keys.map(&:to_s))
|
18
|
+
def request_body
|
19
|
+
@request_body ||= parse_request_body
|
22
20
|
end
|
23
21
|
|
24
22
|
def request_identifier
|
@@ -67,6 +65,12 @@ module Dox
|
|
67
65
|
def request_url_query_parameters
|
68
66
|
CGI.unescape(request.query_parameters.to_query)
|
69
67
|
end
|
68
|
+
|
69
|
+
def parse_request_body
|
70
|
+
body = request.body.read
|
71
|
+
return body if body.blank?
|
72
|
+
JSON.parse(body)
|
73
|
+
end
|
70
74
|
end
|
71
75
|
end
|
72
76
|
end
|
@@ -14,7 +14,7 @@ module Dox
|
|
14
14
|
def print_example_request
|
15
15
|
@output.puts example_request_title
|
16
16
|
@output.puts example_request_headers
|
17
|
-
return unless example.
|
17
|
+
return unless example.request_body.present?
|
18
18
|
|
19
19
|
@output.puts example_request_body
|
20
20
|
end
|
@@ -52,7 +52,7 @@ module Dox
|
|
52
52
|
|
53
53
|
+ Body
|
54
54
|
|
55
|
-
#{indent_lines(12, pretty_json(example.
|
55
|
+
#{indent_lines(12, pretty_json(example.request_body))}
|
56
56
|
HEREDOC
|
57
57
|
end
|
58
58
|
|
data/lib/dox/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Melita Kokot
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-06-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|