apidoc_to_gfm 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +28 -0
- data/Rakefile +6 -0
- data/apidoc_to_gfm.gemspec +29 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/example/.gitignore +18 -0
- data/example/.rspec +2 -0
- data/example/Gemfile +13 -0
- data/example/Gemfile.lock +167 -0
- data/example/README.rdoc +28 -0
- data/example/Rakefile +6 -0
- data/example/app/assets/images/.keep +0 -0
- data/example/app/assets/javascripts/application.js +16 -0
- data/example/app/assets/stylesheets/application.css +15 -0
- data/example/app/controllers/application_controller.rb +5 -0
- data/example/app/controllers/concerns/.keep +0 -0
- data/example/app/controllers/orders_controller.rb +31 -0
- data/example/app/controllers/uploads_controller.rb +5 -0
- data/example/app/helpers/application_helper.rb +2 -0
- data/example/app/mailers/.keep +0 -0
- data/example/app/models/.keep +0 -0
- data/example/app/models/concerns/.keep +0 -0
- data/example/app/models/order.rb +2 -0
- data/example/app/views/layouts/application.html.erb +14 -0
- data/example/bin/bundle +3 -0
- data/example/bin/rails +8 -0
- data/example/bin/rake +8 -0
- data/example/bin/spring +18 -0
- data/example/config/application.rb +30 -0
- data/example/config/boot.rb +4 -0
- data/example/config/database.yml +25 -0
- data/example/config/environment.rb +5 -0
- data/example/config/environments/development.rb +37 -0
- data/example/config/environments/production.rb +83 -0
- data/example/config/environments/test.rb +39 -0
- data/example/config/initializers/backtrace_silencers.rb +7 -0
- data/example/config/initializers/cookies_serializer.rb +3 -0
- data/example/config/initializers/filter_parameter_logging.rb +4 -0
- data/example/config/initializers/inflections.rb +16 -0
- data/example/config/initializers/mime_types.rb +4 -0
- data/example/config/initializers/session_store.rb +3 -0
- data/example/config/initializers/wrap_parameters.rb +14 -0
- data/example/config/locales/en.yml +23 -0
- data/example/config/routes.rb +7 -0
- data/example/config/secrets.yml +22 -0
- data/example/config.ru +4 -0
- data/example/db/migrate/20140616151047_create_orders.rb +11 -0
- data/example/db/schema.rb +24 -0
- data/example/db/seeds.rb +7 -0
- data/example/lib/assets/.keep +0 -0
- data/example/lib/tasks/.keep +0 -0
- data/example/log/.keep +0 -0
- data/example/public/404.html +67 -0
- data/example/public/422.html +67 -0
- data/example/public/500.html +66 -0
- data/example/public/favicon.ico +0 -0
- data/example/public/robots.txt +5 -0
- data/example/spec/acceptance/orders_spec.rb +94 -0
- data/example/spec/acceptance/uploads_spec.rb +15 -0
- data/example/spec/acceptance_helper.rb +9 -0
- data/example/spec/fixtures/file.png +0 -0
- data/example/spec/rails_helper.rb +43 -0
- data/example/spec/spec_helper.rb +74 -0
- data/example/vendor/assets/javascripts/.keep +0 -0
- data/example/vendor/assets/stylesheets/.keep +0 -0
- data/lib/apidoc_to_gfm/version.rb +3 -0
- data/lib/apidoc_to_gfm/views/example.rb +42 -0
- data/lib/apidoc_to_gfm/views/helpers.rb +14 -0
- data/lib/apidoc_to_gfm/views/index.rb +17 -0
- data/lib/apidoc_to_gfm/views.rb +8 -0
- data/lib/apidoc_to_gfm/writers/writer.rb +13 -0
- data/lib/apidoc_to_gfm/writers.rb +6 -0
- data/lib/apidoc_to_gfm.rb +10 -0
- data/templates/rspec_api_documentation/gfm_example.mustache +34 -0
- data/templates/rspec_api_documentation/gfm_index.mustache +10 -0
- metadata +180 -0
@@ -0,0 +1,43 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
require 'spec_helper'
|
4
|
+
require File.expand_path("../../config/environment", __FILE__)
|
5
|
+
require 'rspec/rails'
|
6
|
+
|
7
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
8
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
9
|
+
# run as spec files by default. This means that files in spec/support that end
|
10
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
11
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
12
|
+
# end with _spec.rb. You can configure this pattern with with the --pattern
|
13
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
14
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
15
|
+
|
16
|
+
# Checks for pending migrations before tests are run.
|
17
|
+
# If you are not using ActiveRecord, you can remove this line.
|
18
|
+
ActiveRecord::Migration.maintain_test_schema!
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
22
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
23
|
+
|
24
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
25
|
+
# examples within a transaction, remove the following line or assign false
|
26
|
+
# instead of true.
|
27
|
+
config.use_transactional_fixtures = true
|
28
|
+
|
29
|
+
# RSpec Rails can automatically mix in different behaviours to your tests
|
30
|
+
# based on their file location, for example enabling you to call `get` and
|
31
|
+
# `post` in specs under `spec/controllers`.
|
32
|
+
#
|
33
|
+
# You can disable this behaviour by removing the line below, and instead
|
34
|
+
# explicitly tag your specs with their type, e.g.:
|
35
|
+
#
|
36
|
+
# RSpec.describe UsersController, :type => :controller do
|
37
|
+
# # ...
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# The different available types are documented in the features, such as in
|
41
|
+
# https://relishapp.com/rspec/rspec-rails/docs
|
42
|
+
config.infer_spec_type_from_file_location!
|
43
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
4
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
5
|
+
#
|
6
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
7
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
|
+
# individual file that may not need all of that loaded. Instead, make a
|
10
|
+
# separate helper file that requires this one and then use it only in the specs
|
11
|
+
# that actually need it.
|
12
|
+
#
|
13
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
14
|
+
# users commonly want.
|
15
|
+
#
|
16
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
+
RSpec.configure do |config|
|
18
|
+
# These two settings work together to allow you to limit a spec run
|
19
|
+
# to individual examples or groups you care about by tagging them with
|
20
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
21
|
+
# get run.
|
22
|
+
config.filter_run :focus
|
23
|
+
config.run_all_when_everything_filtered = true
|
24
|
+
|
25
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
26
|
+
# file, and it's useful to allow more verbose output when running an
|
27
|
+
# individual spec file.
|
28
|
+
if config.files_to_run.one?
|
29
|
+
# Use the documentation formatter for detailed output,
|
30
|
+
# unless a formatter has already been configured
|
31
|
+
# (e.g. via a command-line flag).
|
32
|
+
config.default_formatter = 'doc'
|
33
|
+
end
|
34
|
+
|
35
|
+
# Print the 10 slowest examples and example groups at the
|
36
|
+
# end of the spec run, to help surface which specs are running
|
37
|
+
# particularly slow.
|
38
|
+
config.profile_examples = 10
|
39
|
+
|
40
|
+
# Run specs in random order to surface order dependencies. If you find an
|
41
|
+
# order dependency and want to debug it, you can fix the order by providing
|
42
|
+
# the seed, which is printed after each run.
|
43
|
+
# --seed 1234
|
44
|
+
config.order = :random
|
45
|
+
|
46
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
47
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
48
|
+
# test failures related to randomization by passing the same `--seed` value
|
49
|
+
# as the one that triggered the failure.
|
50
|
+
Kernel.srand config.seed
|
51
|
+
|
52
|
+
# rspec-expectations config goes here. You can use an alternate
|
53
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
54
|
+
# assertions if you prefer.
|
55
|
+
config.expect_with :rspec do |expectations|
|
56
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
57
|
+
# For more details, see:
|
58
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
59
|
+
expectations.syntax = :expect
|
60
|
+
end
|
61
|
+
|
62
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
63
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
64
|
+
config.mock_with :rspec do |mocks|
|
65
|
+
# Enable only the newer, non-monkey-patching expect syntax.
|
66
|
+
# For more details, see:
|
67
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
68
|
+
mocks.syntax = :expect
|
69
|
+
|
70
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
71
|
+
# a real object. This is generally recommended.
|
72
|
+
mocks.verify_partial_doubles = true
|
73
|
+
end
|
74
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
module ApidocToGFM
|
4
|
+
module Views
|
5
|
+
class Example < ::RspecApiDocumentation::Views::MarkdownExample
|
6
|
+
include Helpers
|
7
|
+
|
8
|
+
def initialize(example, configuration)
|
9
|
+
super
|
10
|
+
self.template_name = "rspec_api_documentation/gfm_example"
|
11
|
+
self.template_path = template_path_from_gem unless template_exists?
|
12
|
+
end
|
13
|
+
|
14
|
+
# Gitlab works only english filenames!
|
15
|
+
def dirname
|
16
|
+
transliterate(super).downcase
|
17
|
+
end
|
18
|
+
|
19
|
+
def filename
|
20
|
+
transliterate(super).downcase
|
21
|
+
end
|
22
|
+
|
23
|
+
def parameters
|
24
|
+
super.map do |parameter|
|
25
|
+
parameter.merge({
|
26
|
+
:required => parameter[:required] ? 'yes' : 'no',
|
27
|
+
})
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def extension
|
32
|
+
@extension ||= 'md'.freeze
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def transliterate(string, replacement = '_')
|
38
|
+
ActiveSupport::Inflector.transliterate string, replacement
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module ApidocToGFM
|
2
|
+
module Views
|
3
|
+
module Helpers
|
4
|
+
def template_exists?
|
5
|
+
path = File.join(self.template_path, self.template_name)
|
6
|
+
File.exists? path
|
7
|
+
end
|
8
|
+
|
9
|
+
def template_path_from_gem
|
10
|
+
File.expand_path("../../../../templates", __FILE__)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ApidocToGFM
|
2
|
+
module Views
|
3
|
+
class Index < ::RspecApiDocumentation::Views::MarkdownIndex
|
4
|
+
include Helpers
|
5
|
+
|
6
|
+
def initialize(index, configuration)
|
7
|
+
super
|
8
|
+
self.template_name = "rspec_api_documentation/gfm_index"
|
9
|
+
self.template_path = template_path_from_gem unless template_exists?
|
10
|
+
end
|
11
|
+
|
12
|
+
def examples
|
13
|
+
@index.examples.map { |example| Example.new(example, @configuration) }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require "rspec_api_documentation"
|
2
|
+
|
3
|
+
require "apidoc_to_gfm/version"
|
4
|
+
require "apidoc_to_gfm/views"
|
5
|
+
require "apidoc_to_gfm/writers"
|
6
|
+
|
7
|
+
module ApidocToGFM
|
8
|
+
end
|
9
|
+
|
10
|
+
RspecApiDocumentation::Writers.const_set("gfm_writer".classify, ApidocToGFM::Writers::Writer)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# {{ resource_name }}
|
2
|
+
|
3
|
+
## {{ description }}
|
4
|
+
|
5
|
+
{{# explanation }}
|
6
|
+
|
7
|
+
{{ explanation }}
|
8
|
+
{{/ explanation }}
|
9
|
+
|
10
|
+
```
|
11
|
+
{{ http_method }} {{ route }}
|
12
|
+
```
|
13
|
+
|
14
|
+
{{# has_parameters? }}
|
15
|
+
|
16
|
+
| Attribute | Type | Required | Description |
|
17
|
+
| --------- | ---- | -------- | ----------- |
|
18
|
+
{{# parameters }}
|
19
|
+
| {{ name }} | {{ Type }} | {{ required }} | {{ description }} |
|
20
|
+
{{/ parameters }}
|
21
|
+
|
22
|
+
{{/ has_parameters? }}
|
23
|
+
|
24
|
+
{{# requests }}
|
25
|
+
{{# response_status }}
|
26
|
+
{{# response_body }}
|
27
|
+
|
28
|
+
Example response:
|
29
|
+
|
30
|
+
<pre>{{ response_body }}</pre>
|
31
|
+
|
32
|
+
{{/ response_body }}
|
33
|
+
{{/ response_status }}
|
34
|
+
{{/ requests }}
|
metadata
ADDED
@@ -0,0 +1,180 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: apidoc_to_gfm
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- German Antsiferov
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec_api_documentation
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.7.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.7.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.14'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.14'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: The template supports GitLab Flavored Markdown (GFM)
|
70
|
+
email:
|
71
|
+
- dxdy@bk.ru
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- .rspec
|
78
|
+
- .travis.yml
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- apidoc_to_gfm.gemspec
|
84
|
+
- bin/console
|
85
|
+
- bin/setup
|
86
|
+
- example/.gitignore
|
87
|
+
- example/.rspec
|
88
|
+
- example/Gemfile
|
89
|
+
- example/Gemfile.lock
|
90
|
+
- example/README.rdoc
|
91
|
+
- example/Rakefile
|
92
|
+
- example/app/assets/images/.keep
|
93
|
+
- example/app/assets/javascripts/application.js
|
94
|
+
- example/app/assets/stylesheets/application.css
|
95
|
+
- example/app/controllers/application_controller.rb
|
96
|
+
- example/app/controllers/concerns/.keep
|
97
|
+
- example/app/controllers/orders_controller.rb
|
98
|
+
- example/app/controllers/uploads_controller.rb
|
99
|
+
- example/app/helpers/application_helper.rb
|
100
|
+
- example/app/mailers/.keep
|
101
|
+
- example/app/models/.keep
|
102
|
+
- example/app/models/concerns/.keep
|
103
|
+
- example/app/models/order.rb
|
104
|
+
- example/app/views/layouts/application.html.erb
|
105
|
+
- example/bin/bundle
|
106
|
+
- example/bin/rails
|
107
|
+
- example/bin/rake
|
108
|
+
- example/bin/spring
|
109
|
+
- example/config.ru
|
110
|
+
- example/config/application.rb
|
111
|
+
- example/config/boot.rb
|
112
|
+
- example/config/database.yml
|
113
|
+
- example/config/environment.rb
|
114
|
+
- example/config/environments/development.rb
|
115
|
+
- example/config/environments/production.rb
|
116
|
+
- example/config/environments/test.rb
|
117
|
+
- example/config/initializers/backtrace_silencers.rb
|
118
|
+
- example/config/initializers/cookies_serializer.rb
|
119
|
+
- example/config/initializers/filter_parameter_logging.rb
|
120
|
+
- example/config/initializers/inflections.rb
|
121
|
+
- example/config/initializers/mime_types.rb
|
122
|
+
- example/config/initializers/session_store.rb
|
123
|
+
- example/config/initializers/wrap_parameters.rb
|
124
|
+
- example/config/locales/en.yml
|
125
|
+
- example/config/routes.rb
|
126
|
+
- example/config/secrets.yml
|
127
|
+
- example/db/migrate/20140616151047_create_orders.rb
|
128
|
+
- example/db/schema.rb
|
129
|
+
- example/db/seeds.rb
|
130
|
+
- example/lib/assets/.keep
|
131
|
+
- example/lib/tasks/.keep
|
132
|
+
- example/log/.keep
|
133
|
+
- example/public/404.html
|
134
|
+
- example/public/422.html
|
135
|
+
- example/public/500.html
|
136
|
+
- example/public/favicon.ico
|
137
|
+
- example/public/robots.txt
|
138
|
+
- example/spec/acceptance/orders_spec.rb
|
139
|
+
- example/spec/acceptance/uploads_spec.rb
|
140
|
+
- example/spec/acceptance_helper.rb
|
141
|
+
- example/spec/fixtures/file.png
|
142
|
+
- example/spec/rails_helper.rb
|
143
|
+
- example/spec/spec_helper.rb
|
144
|
+
- example/vendor/assets/javascripts/.keep
|
145
|
+
- example/vendor/assets/stylesheets/.keep
|
146
|
+
- lib/apidoc_to_gfm.rb
|
147
|
+
- lib/apidoc_to_gfm/version.rb
|
148
|
+
- lib/apidoc_to_gfm/views.rb
|
149
|
+
- lib/apidoc_to_gfm/views/example.rb
|
150
|
+
- lib/apidoc_to_gfm/views/helpers.rb
|
151
|
+
- lib/apidoc_to_gfm/views/index.rb
|
152
|
+
- lib/apidoc_to_gfm/writers.rb
|
153
|
+
- lib/apidoc_to_gfm/writers/writer.rb
|
154
|
+
- templates/rspec_api_documentation/gfm_example.mustache
|
155
|
+
- templates/rspec_api_documentation/gfm_index.mustache
|
156
|
+
homepage: https://github.com/mr-dxdy/apidoc_to_gfm.git
|
157
|
+
licenses:
|
158
|
+
- MIT
|
159
|
+
metadata: {}
|
160
|
+
post_install_message:
|
161
|
+
rdoc_options: []
|
162
|
+
require_paths:
|
163
|
+
- lib
|
164
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ! '>='
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ! '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
requirements: []
|
175
|
+
rubyforge_project:
|
176
|
+
rubygems_version: 2.6.10
|
177
|
+
signing_key:
|
178
|
+
specification_version: 4
|
179
|
+
summary: An template for rspec_api_documentation
|
180
|
+
test_files: []
|