dictum 0.0.6.1 → 0.0.7
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/CHANGELOG.md +80 -0
 - data/Gemfile +1 -9
 - data/LICENSE.md +1 -1
 - data/README.md +27 -110
 - data/dictum.gemspec +6 -1
 - data/example.md +1 -1
 - data/lib/dictum/html_writer.rb +1 -1
 - data/lib/dictum/markdown_writer.rb +1 -1
 - data/lib/dictum/version.rb +1 -1
 - data/lib/tasks/default_configuration +10 -4
 - metadata +64 -7
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 8a239ef90058a4c5862a7a9d3b0126a4234bf75f
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 6d423a9f7b16eec1395d577c9932f9ee097e5261
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 3507289d2b6483ec1409ef2b80fe78ad521a4bd0e5ba5b4368cb3edf8f843a3eafc666a4f1e5fb5ae442404006fa1b253b74c6e7dc41bfb9d1275eaac25c983b
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 6a077591d19407ff3a3e6eb208673b640884458433e1b5cb238a6ede037382204362194fc82ae8dfa3147875995ace6f0d09a9cc607d34626d4d43ff39141bf1
         
     | 
    
        data/CHANGELOG.md
    ADDED
    
    | 
         @@ -0,0 +1,80 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
             
     | 
| 
      
 2 
     | 
    
         
            +
            ## Change log
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            ### [0.0.7]
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            #### Added
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            - Changelog.
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            #### Changed
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            - Moved advanced usage as default usage in README.
         
     | 
| 
      
 13 
     | 
    
         
            +
            - Fixed how markdown documentation file was deleted.
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            ### [0.0.6.1]
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            #### Added
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            - Error codes in markdown writer.
         
     | 
| 
      
 20 
     | 
    
         
            +
            - Error codes in README.
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            #### Changed
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            - Upgraded some gems versions.
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            #### Removed
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            - Ruby 2.0.0 version from .travis.yml.
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            ### [0.0.6]
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            #### Added
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            - Error code feature.
         
     | 
| 
      
 35 
     | 
    
         
            +
            - Markdown example to README.
         
     | 
| 
      
 36 
     | 
    
         
            +
            - Rake configuration installer.
         
     | 
| 
      
 37 
     | 
    
         
            +
            - Possibility to change index and header titles.
         
     | 
| 
      
 38 
     | 
    
         
            +
            - Possibility to use inline css.
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            #### Changed
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
            - Upgraded some gems versions.
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            #### Removed
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            - Ruby 1.9.3 version from .travis.yml.
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            ### [0.0.5]
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            #### Added
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            - HTML helpers tests.
         
     | 
| 
      
 53 
     | 
    
         
            +
            - Documenter and Dictum tests.
         
     | 
| 
      
 54 
     | 
    
         
            +
            - Arguments validations in writers.
         
     | 
| 
      
 55 
     | 
    
         
            +
            - Writers tests.
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            ### [0.0.4]
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
            #### Added
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            - HTML writer.
         
     | 
| 
      
 62 
     | 
    
         
            +
            - CodeCoverage badge.
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            ### [0.0.3]
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
            #### Changed
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
            - Modified README to be more descriptive.
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            ### [0.0.2]
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
            #### Added
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
            - First release. Only markdown writer.
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
            ### [0.0.1]
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
            #### Added
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
            - `dictum` gem.
         
     | 
    
        data/Gemfile
    CHANGED
    
    | 
         @@ -1,12 +1,4 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            source 'https://rubygems.org'
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            # Specify your gem's dependencies in  
     | 
| 
      
 3 
     | 
    
         
            +
            # Specify your gem's dependencies in dictum.gemspec
         
     | 
| 
       4 
4 
     | 
    
         
             
            gemspec
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            gem 'json', '~> 2.0'
         
     | 
| 
       7 
     | 
    
         
            -
            gem 'rake', '~> 12.0'
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
            group :test do
         
     | 
| 
       10 
     | 
    
         
            -
              gem 'codeclimate-test-reporter', '~> 1.0.0'
         
     | 
| 
       11 
     | 
    
         
            -
              gem 'simplecov'
         
     | 
| 
       12 
     | 
    
         
            -
            end
         
     | 
    
        data/LICENSE.md
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,11 +1,11 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # Dictum 
     | 
| 
      
 1 
     | 
    
         
            +
            # Dictum
         
     | 
| 
       2 
2 
     | 
    
         
             
            [](https://badge.fury.io/rb/dictum)
         
     | 
| 
       3 
3 
     | 
    
         
             
            [](https://gemnasium.com/github.com/Wolox/dictum)
         
     | 
| 
       4 
4 
     | 
    
         
             
            [](https://travis-ci.org/Wolox/dictum)
         
     | 
| 
       5 
5 
     | 
    
         
             
            [](https://codeclimate.com/github/Wolox/dictum)
         
     | 
| 
       6 
6 
     | 
    
         
             
            [](https://codeclimate.com/github/Wolox/dictum/coverage)
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            Create automatic documentation of your Rails APIs.
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
            ## Installation
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
         @@ -23,26 +23,15 @@ Or install it yourself as: 
     | 
|
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
                $ gem install dictum
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
            ##  
     | 
| 
      
 26 
     | 
    
         
            +
            ## Usage
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
            First run:
         
     | 
| 
      
 28 
     | 
    
         
            +
            First, run:
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
30 
     | 
    
         
             
                $ bundle exec rake dictum:configure [PATH_TO_HELPER_FILE]
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
            This will create a basic Rspec configuration in  
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
            ```ruby
         
     | 
| 
       35 
     | 
    
         
            -
            # /config/initializers/dictum.rb
         
     | 
| 
       36 
     | 
    
         
            -
            Dictum.configure do |config|
         
     | 
| 
       37 
     | 
    
         
            -
              config.output_path = Rails.root.join('docs')
         
     | 
| 
       38 
     | 
    
         
            -
              config.root_path = Rails.root
         
     | 
| 
       39 
     | 
    
         
            -
              config.output_filename = 'Documentation'
         
     | 
| 
       40 
     | 
    
         
            -
              config.output_format = :markdown
         
     | 
| 
       41 
     | 
    
         
            -
              config.index_title = 'My Documentation Title'
         
     | 
| 
       42 
     | 
    
         
            -
            end
         
     | 
| 
       43 
     | 
    
         
            -
            ```
         
     | 
| 
      
 32 
     | 
    
         
            +
            This will create a basic Rspec configuration for Dictum in `spec/support/spec_helper.rb` or `PATH_TO_HELPER_FILE`, along with Dictum's initializer file (`/config/initializers/dictum.rb`).
         
     | 
| 
       44 
33 
     | 
    
         | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
      
 34 
     | 
    
         
            +
            To document an endpoint, you have to append `dictum: true` to your controller's `it` statements, as shown below:
         
     | 
| 
       46 
35 
     | 
    
         | 
| 
       47 
36 
     | 
    
         
             
            ```ruby
         
     | 
| 
       48 
37 
     | 
    
         
             
            # spec/controllers/my_resource_controller_spec.rb
         
     | 
| 
         @@ -56,22 +45,8 @@ describe V1::MyResourceController do 
     | 
|
| 
       56 
45 
     | 
    
         | 
| 
       57 
46 
     | 
    
         
             
              describe '#some_method' do
         
     | 
| 
       58 
47 
     | 
    
         
             
                context 'some context for my resource' do
         
     | 
| 
       59 
     | 
    
         
            -
                  it 'returns status ok' do
         
     | 
| 
      
 48 
     | 
    
         
            +
                  it 'returns status ok', dictum: true, dictum_description: 'This optional property exists to add a description to the endpoint.' do
         
     | 
| 
       60 
49 
     | 
    
         
             
                    get :index
         
     | 
| 
       61 
     | 
    
         
            -
                    Dictum.endpoint(
         
     | 
| 
       62 
     | 
    
         
            -
                      resource: 'MyResource',
         
     | 
| 
       63 
     | 
    
         
            -
                      endpoint: '/api/v1/my_resource/:id',
         
     | 
| 
       64 
     | 
    
         
            -
                      http_verb: 'POST',
         
     | 
| 
       65 
     | 
    
         
            -
                      description: 'Some description of the endpoint.',
         
     | 
| 
       66 
     | 
    
         
            -
                      request_headers: { 'AUTHORIZATION' => 'user_token',
         
     | 
| 
       67 
     | 
    
         
            -
                                         'Content-Type' => 'application/json',
         
     | 
| 
       68 
     | 
    
         
            -
                                         'Accept' => 'application/json' },
         
     | 
| 
       69 
     | 
    
         
            -
                      request_path_parameters: { id: 1, page: 1 },
         
     | 
| 
       70 
     | 
    
         
            -
                      request_body_parameters: { some: 'parameter' },
         
     | 
| 
       71 
     | 
    
         
            -
                      response_headers: { 'some_header' => 'some_header_value' },
         
     | 
| 
       72 
     | 
    
         
            -
                      response_status: response.status,
         
     | 
| 
       73 
     | 
    
         
            -
                      response_body: response_body
         
     | 
| 
       74 
     | 
    
         
            -
                    )
         
     | 
| 
       75 
50 
     | 
    
         
             
                    expect(response_status).to eq(200)
         
     | 
| 
       76 
51 
     | 
    
         
             
                  end
         
     | 
| 
       77 
52 
     | 
    
         
             
                end
         
     | 
| 
         @@ -83,50 +58,7 @@ Then execute: 
     | 
|
| 
       83 
58 
     | 
    
         | 
| 
       84 
59 
     | 
    
         
             
                $ bundle exec rake dictum:document
         
     | 
| 
       85 
60 
     | 
    
         | 
| 
       86 
     | 
    
         
            -
            And voilà, Dictum will create a document like this 
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
                # My Documentation Title
         
     | 
| 
       89 
     | 
    
         
            -
                - MyResource
         
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
                # MyResource
         
     | 
| 
       92 
     | 
    
         
            -
                This is MyResource description.
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
                ## POST /api/v1/my_resource
         
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
                ### Description:
         
     | 
| 
       97 
     | 
    
         
            -
                Some description of the endpoint.
         
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
                ### Request headers:
         
     | 
| 
       100 
     | 
    
         
            -
                ```json
         
     | 
| 
       101 
     | 
    
         
            -
                {
         
     | 
| 
       102 
     | 
    
         
            -
                  "AUTHORIZATION" : "user_token",
         
     | 
| 
       103 
     | 
    
         
            -
                  "Content-Type" : "application/json",
         
     | 
| 
       104 
     | 
    
         
            -
                  "Accept" : "application/json"
         
     | 
| 
       105 
     | 
    
         
            -
                }
         
     | 
| 
       106 
     | 
    
         
            -
                ```
         
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
                ### Path parameters:
         
     | 
| 
       109 
     | 
    
         
            -
                ```json
         
     | 
| 
       110 
     | 
    
         
            -
                { "id": 1, "page": 1 }
         
     | 
| 
       111 
     | 
    
         
            -
                ```
         
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
                ### Body parameters:
         
     | 
| 
       114 
     | 
    
         
            -
                ```json
         
     | 
| 
       115 
     | 
    
         
            -
                { "some": "parameter" }
         
     | 
| 
       116 
     | 
    
         
            -
                ```
         
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
     | 
    
         
            -
                ### Response headers:
         
     | 
| 
       119 
     | 
    
         
            -
                ```json
         
     | 
| 
       120 
     | 
    
         
            -
                { "some_header": "some_header_value" }
         
     | 
| 
       121 
     | 
    
         
            -
                ```
         
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
                ### Response status:
         
     | 
| 
       124 
     | 
    
         
            -
                200
         
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
       126 
     | 
    
         
            -
                ### Response body:
         
     | 
| 
       127 
     | 
    
         
            -
                ```json
         
     | 
| 
       128 
     | 
    
         
            -
                "no_content"
         
     | 
| 
       129 
     | 
    
         
            -
                ```
         
     | 
| 
      
 61 
     | 
    
         
            +
            And voilà, Dictum will create a document like [this](https://github.com/Wolox/dictum/blob/master/example.md) in `/docs/Documentation.md`.
         
     | 
| 
       130 
62 
     | 
    
         | 
| 
       131 
63 
     | 
    
         
             
            # Error codes
         
     | 
| 
       132 
64 
     | 
    
         | 
| 
         @@ -147,36 +79,10 @@ Dictum.error_codes(ERROR_CODES) 
     | 
|
| 
       147 
79 
     | 
    
         | 
| 
       148 
80 
     | 
    
         
             
            We recommend you to define your error codes in a module or class with useful methods like get(error_code) and get_all, [like this one](https://gist.github.com/alebian/1b925151b6a6acd3e4bb2ef4b5148324).
         
     | 
| 
       149 
81 
     | 
    
         | 
| 
       150 
     | 
    
         
            -
            # Advanced usage
         
     | 
| 
       151 
     | 
    
         
            -
             
     | 
| 
       152 
     | 
    
         
            -
            If you pay attention to the basic usage, you will notice that it is a lot of boilerplate if your API has a lot of endpoints, this is not DRY. Luckily you can work around it using some Rspec tricks:
         
     | 
| 
       153 
82 
     | 
    
         | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
       155 
     | 
    
         
            -
            # spec/rails_helper.rb
         
     | 
| 
       156 
     | 
    
         
            -
            RSpec.configure do |config|
         
     | 
| 
       157 
     | 
    
         
            -
              config.after(:each) do |test|
         
     | 
| 
       158 
     | 
    
         
            -
                if test.metadata[:dictum]
         
     | 
| 
       159 
     | 
    
         
            -
                  Dictum.endpoint(
         
     | 
| 
       160 
     | 
    
         
            -
                  Dictum.endpoint(
         
     | 
| 
       161 
     | 
    
         
            -
                    resource: test.metadata[:described_class].to_s.gsub('V1::', '').gsub('Controller', ''),
         
     | 
| 
       162 
     | 
    
         
            -
                    endpoint: request.fullpath,
         
     | 
| 
       163 
     | 
    
         
            -
                    http_verb: request.env['REQUEST_METHOD'],
         
     | 
| 
       164 
     | 
    
         
            -
                    description: test.metadata[:dictum_description],
         
     | 
| 
       165 
     | 
    
         
            -
                    request_headers: { 'AUTHORIZATION' => 'user_token',
         
     | 
| 
       166 
     | 
    
         
            -
                                       'Content-Type' => 'application/json',
         
     | 
| 
       167 
     | 
    
         
            -
                                       'Accept' => 'application/json' },
         
     | 
| 
       168 
     | 
    
         
            -
                    request_path_parameters: request.env['action_dispatch.request.path_parameters'].except(:controller, :action),
         
     | 
| 
       169 
     | 
    
         
            -
                    request_body_parameters: request.env['action_dispatch.request.parameters'].except('controller', 'action'),
         
     | 
| 
       170 
     | 
    
         
            -
                    response_headers: response.headers,
         
     | 
| 
       171 
     | 
    
         
            -
                    response_status: response.status,
         
     | 
| 
       172 
     | 
    
         
            -
                    response_body: response_body
         
     | 
| 
       173 
     | 
    
         
            -
                  )
         
     | 
| 
       174 
     | 
    
         
            -
                end
         
     | 
| 
       175 
     | 
    
         
            -
              end
         
     | 
| 
       176 
     | 
    
         
            -
            end
         
     | 
| 
       177 
     | 
    
         
            -
            ```
         
     | 
| 
      
 83 
     | 
    
         
            +
            ## Descriptive usage
         
     | 
| 
       178 
84 
     | 
    
         | 
| 
       179 
     | 
    
         
            -
             
     | 
| 
      
 85 
     | 
    
         
            +
            Also, if you prefer to have more control over your endpoints documentation, you can use Dictum in the most verbose and fully customizable way, as shown below:
         
     | 
| 
       180 
86 
     | 
    
         | 
| 
       181 
87 
     | 
    
         
             
            ```ruby
         
     | 
| 
       182 
88 
     | 
    
         
             
            # spec/controllers/my_resource_controller_spec.rb
         
     | 
| 
         @@ -190,17 +96,28 @@ describe V1::MyResourceController do 
     | 
|
| 
       190 
96 
     | 
    
         | 
| 
       191 
97 
     | 
    
         
             
              describe '#some_method' do
         
     | 
| 
       192 
98 
     | 
    
         
             
                context 'some context for my resource' do
         
     | 
| 
       193 
     | 
    
         
            -
                  it 'returns status ok' 
     | 
| 
      
 99 
     | 
    
         
            +
                  it 'returns status ok' do
         
     | 
| 
       194 
100 
     | 
    
         
             
                    get :index
         
     | 
| 
      
 101 
     | 
    
         
            +
                    Dictum.endpoint(
         
     | 
| 
      
 102 
     | 
    
         
            +
                      resource: 'MyResource',
         
     | 
| 
      
 103 
     | 
    
         
            +
                      endpoint: '/api/v1/my_resource/:id',
         
     | 
| 
      
 104 
     | 
    
         
            +
                      http_verb: 'POST',
         
     | 
| 
      
 105 
     | 
    
         
            +
                      description: 'This optional property exists to add a description to the endpoint.',
         
     | 
| 
      
 106 
     | 
    
         
            +
                      request_headers: { 'AUTHORIZATION' => 'user_token',
         
     | 
| 
      
 107 
     | 
    
         
            +
                                         'Content-Type' => 'application/json',
         
     | 
| 
      
 108 
     | 
    
         
            +
                                         'Accept' => 'application/json' },
         
     | 
| 
      
 109 
     | 
    
         
            +
                      request_path_parameters: { id: 1, page: 1 },
         
     | 
| 
      
 110 
     | 
    
         
            +
                      request_body_parameters: { some: 'parameter' },
         
     | 
| 
      
 111 
     | 
    
         
            +
                      response_headers: { 'some_header' => 'some_header_value' },
         
     | 
| 
      
 112 
     | 
    
         
            +
                      response_status: response.status,
         
     | 
| 
      
 113 
     | 
    
         
            +
                      response_body: response_body
         
     | 
| 
      
 114 
     | 
    
         
            +
                    )
         
     | 
| 
       195 
115 
     | 
    
         
             
                    expect(response_status).to eq(200)
         
     | 
| 
       196 
116 
     | 
    
         
             
                  end
         
     | 
| 
       197 
117 
     | 
    
         
             
                end
         
     | 
| 
       198 
118 
     | 
    
         
             
              end
         
     | 
| 
       199 
119 
     | 
    
         
             
            end
         
     | 
| 
       200 
120 
     | 
    
         
             
            ```
         
     | 
| 
       201 
     | 
    
         
            -
             
     | 
| 
       202 
     | 
    
         
            -
            This is how your controller test should look now, much better.
         
     | 
| 
       203 
     | 
    
         
            -
             
     | 
| 
       204 
121 
     | 
    
         
             
            # Dynamic HTML documentation
         
     | 
| 
       205 
122 
     | 
    
         | 
| 
       206 
123 
     | 
    
         
             
            So far so good, but your team needs to read the documentation everytime you update it, and sending the documentation file to them doesn't seem too practical. Instead you can use the HTML version of Dictum and generate static views with the content. Here is a very basic example of what you can do to generate the views and routes dynamycally:
         
     | 
| 
         @@ -264,7 +181,7 @@ This project is maintained by [Alejandro Bezdjian](https://github.com/alebian) a 
     | 
|
| 
       264 
181 
     | 
    
         | 
| 
       265 
182 
     | 
    
         
             
            **Dictum** is available under the MIT [license](https://raw.githubusercontent.com/Wolox/dictum/master/LICENSE.md).
         
     | 
| 
       266 
183 
     | 
    
         | 
| 
       267 
     | 
    
         
            -
                Copyright (c)  
     | 
| 
      
 184 
     | 
    
         
            +
                Copyright (c) 2017 Wolox
         
     | 
| 
       268 
185 
     | 
    
         | 
| 
       269 
186 
     | 
    
         
             
                Permission is hereby granted, free of charge, to any person obtaining a copy
         
     | 
| 
       270 
187 
     | 
    
         
             
                of this software and associated documentation files (the "Software"), to deal
         
     | 
    
        data/dictum.gemspec
    CHANGED
    
    | 
         @@ -2,6 +2,7 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
            lib = File.expand_path('../lib', __FILE__)
         
     | 
| 
       3 
3 
     | 
    
         
             
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         
     | 
| 
       4 
4 
     | 
    
         
             
            require 'dictum/version'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'date'
         
     | 
| 
       5 
6 
     | 
    
         | 
| 
       6 
7 
     | 
    
         
             
            Gem::Specification.new do |spec|
         
     | 
| 
       7 
8 
     | 
    
         
             
              spec.name          = 'dictum'
         
     | 
| 
         @@ -20,9 +21,13 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       20 
21 
     | 
    
         
             
              spec.test_files    = spec.files.grep(%r{^(test|spec)/})
         
     | 
| 
       21 
22 
     | 
    
         | 
| 
       22 
23 
     | 
    
         
             
              spec.add_dependency 'nokogiri', '>= 1.3.3'
         
     | 
| 
      
 24 
     | 
    
         
            +
              spec.add_dependency 'json', '~> 2.0'
         
     | 
| 
      
 25 
     | 
    
         
            +
              spec.add_dependency 'rake', '~> 12.0'
         
     | 
| 
       23 
26 
     | 
    
         | 
| 
       24 
27 
     | 
    
         
             
              spec.add_development_dependency 'bundler', '>= 1.3.0', '< 2.0'
         
     | 
| 
       25 
28 
     | 
    
         
             
              spec.add_development_dependency 'rspec', '~> 3.4', '>= 3.4.0'
         
     | 
| 
       26 
29 
     | 
    
         
             
              spec.add_development_dependency 'byebug', '~> 8.0', '>= 8.0.0' if RUBY_VERSION >= '2.0.0'
         
     | 
| 
       27 
     | 
    
         
            -
              spec.add_development_dependency 'rubocop', '~> 0. 
     | 
| 
      
 30 
     | 
    
         
            +
              spec.add_development_dependency 'rubocop', '~> 0.48', '>= 0.48.0'
         
     | 
| 
      
 31 
     | 
    
         
            +
              spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0.0'
         
     | 
| 
      
 32 
     | 
    
         
            +
              spec.add_development_dependency 'simplecov'
         
     | 
| 
       28 
33 
     | 
    
         
             
            end
         
     | 
    
        data/example.md
    CHANGED
    
    
    
        data/lib/dictum/html_writer.rb
    CHANGED
    
    
| 
         @@ -6,7 +6,7 @@ module Dictum 
     | 
|
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
                def initialize(output_path, temp_path, config)
         
     | 
| 
       8 
8 
     | 
    
         
             
                  @output_path = "#{output_path}.md"
         
     | 
| 
       9 
     | 
    
         
            -
                  File.delete(output_path) if File.exist?(output_path)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  File.delete(@output_path) if File.exist?(@output_path)
         
     | 
| 
       10 
10 
     | 
    
         
             
                  @temp_path = temp_path
         
     | 
| 
       11 
11 
     | 
    
         
             
                  @temp_json = JSON.parse(File.read(temp_path))
         
     | 
| 
       12 
12 
     | 
    
         
             
                  @config = config
         
     | 
    
        data/lib/dictum/version.rb
    CHANGED
    
    
| 
         @@ -1,18 +1,24 @@ 
     | 
|
| 
       1 
1 
     | 
    
         | 
| 
      
 2 
     | 
    
         
            +
            DEFAULT_REQUEST_HEADERS = {
         
     | 
| 
      
 3 
     | 
    
         
            +
              'AUTHORIZATION' => 'user_token',
         
     | 
| 
      
 4 
     | 
    
         
            +
              'Content-Type' => 'application/json',
         
     | 
| 
      
 5 
     | 
    
         
            +
              'Accept' => 'application/json'
         
     | 
| 
      
 6 
     | 
    
         
            +
            }
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
       2 
8 
     | 
    
         
             
            RSpec.configure do |config|
         
     | 
| 
       3 
9 
     | 
    
         
             
              config.after(:each) do |test|
         
     | 
| 
       4 
10 
     | 
    
         
             
                if test.metadata[:dictum]
         
     | 
| 
       5 
11 
     | 
    
         
             
                Dictum.endpoint(
         
     | 
| 
       6 
     | 
    
         
            -
                  resource: test.metadata[:described_class].to_s. 
     | 
| 
      
 12 
     | 
    
         
            +
                  resource: test.metadata[:described_class].to_s.split('::').last.gsub('Controller', ''),
         
     | 
| 
       7 
13 
     | 
    
         
             
                  endpoint: request.fullpath,
         
     | 
| 
       8 
14 
     | 
    
         
             
                  http_verb: request.env['REQUEST_METHOD'],
         
     | 
| 
       9 
15 
     | 
    
         
             
                  description: test.metadata[:dictum_description],
         
     | 
| 
       10 
     | 
    
         
            -
                  request_headers:  
     | 
| 
      
 16 
     | 
    
         
            +
                  request_headers: DEFAULT_REQUEST_HEADERS,
         
     | 
| 
       11 
17 
     | 
    
         
             
                  request_path_parameters: request.env['action_dispatch.request.path_parameters'].except(:controller, :action),
         
     | 
| 
       12 
18 
     | 
    
         
             
                  request_body_parameters: request.env['action_dispatch.request.parameters'].except('controller', 'action'),
         
     | 
| 
       13 
     | 
    
         
            -
                  response_headers: response.headers 
     | 
| 
      
 19 
     | 
    
         
            +
                  response_headers: response.headers,
         
     | 
| 
       14 
20 
     | 
    
         
             
                  response_status: response.status,
         
     | 
| 
       15 
     | 
    
         
            -
                  response_body:  
     | 
| 
      
 21 
     | 
    
         
            +
                  response_body: ActiveSupport::JSON.decode(response.body)
         
     | 
| 
       16 
22 
     | 
    
         
             
                )
         
     | 
| 
       17 
23 
     | 
    
         
             
                end
         
     | 
| 
       18 
24 
     | 
    
         
             
              end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: dictum
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.7
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Alejandro Bezdjian
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2017- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-05-23 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: nokogiri
         
     | 
| 
         @@ -24,6 +24,34 @@ dependencies: 
     | 
|
| 
       24 
24 
     | 
    
         
             
                - - ">="
         
     | 
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
26 
     | 
    
         
             
                    version: 1.3.3
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: json
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '2.0'
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '2.0'
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 43 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 44 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 45 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 46 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 47 
     | 
    
         
            +
                    version: '12.0'
         
     | 
| 
      
 48 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 49 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 50 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 51 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 52 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 53 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: '12.0'
         
     | 
| 
       27 
55 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
56 
     | 
    
         
             
              name: bundler
         
     | 
| 
       29 
57 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -90,20 +118,48 @@ dependencies: 
     | 
|
| 
       90 
118 
     | 
    
         
             
                requirements:
         
     | 
| 
       91 
119 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       92 
120 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       93 
     | 
    
         
            -
                    version: '0. 
     | 
| 
      
 121 
     | 
    
         
            +
                    version: '0.48'
         
     | 
| 
       94 
122 
     | 
    
         
             
                - - ">="
         
     | 
| 
       95 
123 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       96 
     | 
    
         
            -
                    version: 0. 
     | 
| 
      
 124 
     | 
    
         
            +
                    version: 0.48.0
         
     | 
| 
       97 
125 
     | 
    
         
             
              type: :development
         
     | 
| 
       98 
126 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       99 
127 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       100 
128 
     | 
    
         
             
                requirements:
         
     | 
| 
       101 
129 
     | 
    
         
             
                - - "~>"
         
     | 
| 
       102 
130 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       103 
     | 
    
         
            -
                    version: '0. 
     | 
| 
      
 131 
     | 
    
         
            +
                    version: '0.48'
         
     | 
| 
      
 132 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 133 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 134 
     | 
    
         
            +
                    version: 0.48.0
         
     | 
| 
      
 135 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 136 
     | 
    
         
            +
              name: codeclimate-test-reporter
         
     | 
| 
      
 137 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 138 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 139 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 140 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 141 
     | 
    
         
            +
                    version: 1.0.0
         
     | 
| 
      
 142 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 143 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 144 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 145 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 146 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 147 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 148 
     | 
    
         
            +
                    version: 1.0.0
         
     | 
| 
      
 149 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 150 
     | 
    
         
            +
              name: simplecov
         
     | 
| 
      
 151 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 152 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 153 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 154 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 155 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 156 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 157 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 158 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 159 
     | 
    
         
            +
                requirements:
         
     | 
| 
       104 
160 
     | 
    
         
             
                - - ">="
         
     | 
| 
       105 
161 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       106 
     | 
    
         
            -
                    version: 0 
     | 
| 
      
 162 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       107 
163 
     | 
    
         
             
            description: Create automatic documentation of your API endpoints through your tests.
         
     | 
| 
       108 
164 
     | 
    
         
             
            email: alebezdjian@gmail.com
         
     | 
| 
       109 
165 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -114,6 +170,7 @@ files: 
     | 
|
| 
       114 
170 
     | 
    
         
             
            - ".rspec"
         
     | 
| 
       115 
171 
     | 
    
         
             
            - ".rubocop.yml"
         
     | 
| 
       116 
172 
     | 
    
         
             
            - ".travis.yml"
         
     | 
| 
      
 173 
     | 
    
         
            +
            - CHANGELOG.md
         
     | 
| 
       117 
174 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       118 
175 
     | 
    
         
             
            - LICENSE.md
         
     | 
| 
       119 
176 
     | 
    
         
             
            - README.md
         
     | 
| 
         @@ -153,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       153 
210 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       154 
211 
     | 
    
         
             
            requirements: []
         
     | 
| 
       155 
212 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       156 
     | 
    
         
            -
            rubygems_version: 2.5 
     | 
| 
      
 213 
     | 
    
         
            +
            rubygems_version: 2.4.5
         
     | 
| 
       157 
214 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       158 
215 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       159 
216 
     | 
    
         
             
            summary: Document your APIs.
         
     |