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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3696fee9fddea2f824f129a0a25e61383b01cec
4
- data.tar.gz: c69809b3ce6618fc593dd8897938e5f34d8788c9
3
+ metadata.gz: 658311eb3318384ac31608e40c9926544f24e170
4
+ data.tar.gz: 35832e0fa318b5d019a3d03765612fe1f7523b4e
5
5
  SHA512:
6
- metadata.gz: 28f6f85ab7471792a741658f83a1a1b522359da8bed3e4bd5f9e9a4cf71d9e28e80fe1a087fc459bd9c4c58afbde4cb797ceb0732d7a3980556c2c973bf7838e
7
- data.tar.gz: 2e71c5e388fc0c7bb727f057219e6376b4a2fe80a645738fef539ced75d1099227a27c8ac786b2c8c160c98e99fc99b22a2e0404dc414d7b3a0f2276b1e9bd7a
6
+ metadata.gz: 81e5317ed65beaf22e632932e1b03df01e4933fa982b57ec85d3e1b07a5bf8a95512e67b726a6e2370a88dc3799ac0dd0fb60b8ebab66ee5db1ed6344867abca
7
+ data.tar.gz: 5cf6550f640579aa530c229e60ceb6c1fbdaeb9d4910dba247dc961503c21eb020044fd203dab03e21c6ed33716c14ad8917033b253cf8e7e8c5d68f57382baf
data/CHANGES.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 1.0.1
4
+
5
+ Released on June 10, 2017
6
+
7
+ New:
8
+ - Add Rake tasks for generating documentation to Readme
9
+
10
+ Fix:
11
+ - Fix printing request body for test examples
12
+
13
+
3
14
  ## Version 1.0.0
4
15
 
5
16
  Released on May 6, 2017
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 with dox command:
246
- ```bundle exec dox spec/controllers/api/v1 > docs.md```
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
 
@@ -15,10 +15,8 @@ module Dox
15
15
  @response = response
16
16
  end
17
17
 
18
- def request_parameters
19
- request.parameters
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.request_parameters.present?
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.request_parameters))}
55
+ #{indent_lines(12, pretty_json(example.request_body))}
56
56
  HEREDOC
57
57
  end
58
58
 
@@ -1,3 +1,3 @@
1
1
  module Dox
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
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.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-05-06 00:00:00.000000000 Z
12
+ date: 2017-06-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler