raml_doc 0.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cb509f65b7d5e684ddb654c634e5df1ed362cca9
4
+ data.tar.gz: 74ae09b07265b376073210822400f525f57e9bad
5
+ SHA512:
6
+ metadata.gz: 39891942cccebdb7c4f237f45ba9bcf8a10ceac19b7dd272f15891247bb710f96186671910158b3a8c48225fde063df30a5f44ed25e6d6b91e670492d8b7e5bd
7
+ data.tar.gz: 0c4e9d0972f31c8763bb54200647727fafe540150201e93b69a62308c9967a61d9d2e20221904797754cd905dd11b8a66ca5f606b5bb131da8093cc659a24313
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in raml_doc.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,88 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ raml_doc (0.1.0)
5
+ kramdown (= 1.11.1)
6
+ raml_ruby (= 0.1.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (4.2.6)
12
+ i18n (~> 0.7)
13
+ json (~> 1.7, >= 1.7.7)
14
+ minitest (~> 5.1)
15
+ thread_safe (~> 0.3, >= 0.3.4)
16
+ tzinfo (~> 1.1)
17
+ addressable (2.3.8)
18
+ binding_of_caller (0.7.2)
19
+ debug_inspector (>= 0.0.1)
20
+ byebug (9.0.4)
21
+ coderay (1.1.1)
22
+ coveralls (0.8.13)
23
+ json (~> 1.8)
24
+ simplecov (~> 0.11.0)
25
+ term-ansicolor (~> 1.3)
26
+ thor (~> 0.19.1)
27
+ tins (~> 1.6.0)
28
+ debug_inspector (0.0.2)
29
+ docile (1.1.5)
30
+ i18n (0.7.0)
31
+ interception (0.5)
32
+ json (1.8.3)
33
+ json-schema (2.6.2)
34
+ addressable (~> 2.3.8)
35
+ kramdown (1.11.1)
36
+ method_source (0.8.2)
37
+ minitest (5.9.0)
38
+ os (0.9.6)
39
+ pry (0.10.3)
40
+ coderay (~> 1.1.0)
41
+ method_source (~> 0.8.1)
42
+ slop (~> 3.4)
43
+ pry-byebug (3.4.0)
44
+ byebug (~> 9.0)
45
+ pry (~> 0.10)
46
+ pry-rescue (1.4.4)
47
+ interception (>= 0.5)
48
+ pry
49
+ pry-stack_explorer (0.4.9.2)
50
+ binding_of_caller (>= 0.7)
51
+ pry (>= 0.9.11)
52
+ pry-test (0.6.4)
53
+ os
54
+ pry
55
+ pry-byebug
56
+ pry-rescue
57
+ pry-stack_explorer
58
+ rake (11.1.2)
59
+ raml_ruby (0.1.2)
60
+ activesupport (>= 4.1)
61
+ json-schema (~> 2.5)
62
+ uri_template (~> 0.7)
63
+ simplecov (0.11.2)
64
+ docile (~> 1.1.0)
65
+ json (~> 1.8)
66
+ simplecov-html (~> 0.10.0)
67
+ simplecov-html (0.10.0)
68
+ slop (3.6.0)
69
+ term-ansicolor (1.3.2)
70
+ tins (~> 1.0)
71
+ thor (0.19.1)
72
+ thread_safe (0.3.5)
73
+ tins (1.6.0)
74
+ tzinfo (1.2.2)
75
+ thread_safe (~> 0.1)
76
+ uri_template (0.7.0)
77
+
78
+ PLATFORMS
79
+ ruby
80
+
81
+ DEPENDENCIES
82
+ coveralls
83
+ pry-test
84
+ rake
85
+ raml_doc!
86
+
87
+ BUNDLED WITH
88
+ 1.11.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Nathan Hopkins
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # RamlDoc
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/raml_doc`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'raml_doc'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install raml_doc
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/raml_doc.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "raml_doc"
5
+ require "pry"
6
+ Pry.start
data/bin/ramldoc ADDED
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "optparse"
4
+ require "bundler/setup"
5
+ require "raml_doc"
6
+
7
+ options = {
8
+ :template => "default"
9
+ }
10
+
11
+ option_parser = OptionParser.new do |opts|
12
+ opts.banner = "Usage: ramldoc [options]"
13
+
14
+ opts.on("-f", "--file FILE", "The RAML file used to generate docs") do |f|
15
+ options[:file] = f
16
+ end
17
+
18
+ opts.on("-t", "--template [default]", "The template used to generate docs") do |t|
19
+ options[:template] = t
20
+ end
21
+ end
22
+
23
+ option_parser.parse!
24
+
25
+ puts RamlDoc.generate(options[:file], options[:template])
26
+
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ module RamlHelper
2
+ def max_parameter(method)
3
+ method.query_parameters.max_by do |name_and_parameter|
4
+ name_and_parameter.first.size
5
+ end.last
6
+ end
7
+ end
@@ -0,0 +1,109 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en" class="">
3
+ <head>
4
+ <title><%= @raml.title %></title>
5
+ </head>
6
+ <body>
7
+ <div class="container">
8
+ <h1>
9
+ <%= @raml.title %>
10
+ <small>Version <%= @raml.version %></small>
11
+ </h1>
12
+
13
+ <% @raml.resources.each do |_, resource| %>
14
+ <h2 id="<%= resource.resource_path_name %>" class="page-header">
15
+ <i class="fa fa-external-link-square" aria-hidden="true"></i>
16
+ <%= resource.name %>
17
+ </h2>
18
+ <p class="lead">
19
+ <%= resource.description %>
20
+ </p>
21
+ <% resource.methods.each do |_, method| %>
22
+ <div class="panel panel-default">
23
+ <div class="panel-heading">
24
+ <h3 class="panel-title">
25
+ <span class="label label-info"><%= method.name %></span>
26
+ <a class="text-muted" href="<%= @raml.base_uri + resource.resource_path %>">
27
+ <%= @raml.base_uri + resource.resource_path %>
28
+ </a>
29
+ <small class="pull-right">
30
+ <var><%= @raml.media_type %></var>
31
+ </small>
32
+ </h3>
33
+ </div>
34
+ <div class="panel-body">
35
+ <div>
36
+ <ul class="nav nav-tabs" role="tablist">
37
+ <li role="presentation" class="active">
38
+ <a href="#description-<%= resource.resource_path_name %>" aria-controls="home" role="tab" data-toggle="tab">
39
+ <i class="fa fa-info-circle" aria-hidden="true"></i>
40
+ Description
41
+ </a>
42
+ </li>
43
+ <li role="presentation">
44
+ <a href="#headers-<%= resource.resource_path_name %>" aria-controls="home" role="tab" data-toggle="tab">
45
+ <i class="fa fa-code" aria-hidden="true"></i>
46
+ Headers
47
+ </a>
48
+ </li>
49
+ <li role="presentation">
50
+ <a href="#querystring-parameters<%= resource.resource_path_name %>" aria-controls="profile" role="tab" data-toggle="tab">
51
+ <i class="fa fa-code" aria-hidden="true"></i>
52
+ Querystring Parameters
53
+ </a>
54
+ </li>
55
+ <li role="presentation">
56
+ <a href="#responses-<%= resource.resource_path_name %>" aria-controls="home" role="tab" data-toggle="tab">
57
+ <i class="fa fa-code" aria-hidden="true"></i>
58
+ Responses
59
+ </a>
60
+ </li>
61
+ </ul>
62
+
63
+ <div class="tab-content">
64
+ <div role="tabpanel" class="tab-pane active" id="description-<%= resource.resource_path_name %>">
65
+ <p class="lead">
66
+ <%= markdown method.description %>
67
+ </p>
68
+ </div>
69
+ <div role="tabpanel" class="tab-pane" id="headers-<%= resource.resource_path_name %>">
70
+ <p>...</p>
71
+ </div>
72
+ <div role="tabpanel" class="tab-pane" id="querystring-parameters<%= resource.resource_path_name %>">
73
+ <p>
74
+ <ul>
75
+ <% method.query_parameters.each do |_, parameter| %>
76
+ <li>
77
+ <var><strong><%= parameter.required ? "*#{parameter.name}" : "[#{parameter.name}]" %></strong></var>
78
+ <% if parameter.example %>
79
+ <code><%= parameter.example %></code>
80
+ <% end %>
81
+ <p><small><%= markdown parameter.description %></small></p>
82
+ </li>
83
+ <% end %>
84
+ </ul>
85
+ </p>
86
+ </div>
87
+ <div role="tabpanel" class="tab-pane" id="responses-<%= resource.resource_path_name %>">
88
+ <p>...</p>
89
+ </div>
90
+ </div>
91
+ </div>
92
+ </div>
93
+ </div>
94
+ <% end %>
95
+ <% end %>
96
+ </div>
97
+
98
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
99
+ <style type="text/css" rel="stylesheet">
100
+ @import url(https://fonts.googleapis.com/css?family=Raleway:600|Merriweather);
101
+ h1, h2, h3, h4, h5, h6 { font-family: "Raleway", sans-serif; }
102
+ p, div { font-family: "Merriweather", serif; }
103
+ code, pre, kbd, var { font-family: monospace; }
104
+ </style>
105
+ <script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
106
+ <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
107
+ <script src="https://use.fontawesome.com/ff1f204224.js"></script>
108
+ </body>
109
+ </html>
@@ -0,0 +1,3 @@
1
+ module RamlDoc
2
+ VERSION = "0.0.0"
3
+ end
@@ -0,0 +1,22 @@
1
+ require "kramdown"
2
+ require "raml_doc/raml_helper"
3
+
4
+ module RamlDoc
5
+ class View
6
+ include RamlHelper
7
+
8
+ def initialize(raml)
9
+ @raml = raml
10
+ end
11
+
12
+ def render(template)
13
+ template_path = File.join(File.expand_path("../templates", __FILE__), "#{template}.html.erb")
14
+ template = ERB.new(File.read(template_path))
15
+ template.result binding
16
+ end
17
+
18
+ def markdown(string)
19
+ Kramdown::Document.new(string).to_html
20
+ end
21
+ end
22
+ end
data/lib/raml_doc.rb ADDED
@@ -0,0 +1,12 @@
1
+ require "raml"
2
+ require "erb"
3
+ require "raml_doc/version"
4
+ require "raml_doc/view"
5
+
6
+ module RamlDoc
7
+ def self.generate(file_path, template)
8
+ raml = Raml.parse_file(file_path)
9
+ view = View.new(raml)
10
+ view.render template
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: raml_doc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Nathan Hopkins
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: raml_ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: kramdown
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.11.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.11.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry-test
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: coveralls
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - natehop@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - Gemfile
91
+ - Gemfile.lock
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - bin/console
96
+ - bin/ramldoc
97
+ - bin/setup
98
+ - lib/raml_doc.rb
99
+ - lib/raml_doc/raml_helper.rb
100
+ - lib/raml_doc/templates/default.html.erb
101
+ - lib/raml_doc/version.rb
102
+ - lib/raml_doc/view.rb
103
+ homepage: https://github.com/hopsoft/raml_doc
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.5.1
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: Generate API documentation from RAML files
127
+ test_files: []