fdoc 0.2.7 → 0.3.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.
- data/README.md +4 -4
- data/bin/fdoc +9 -0
- data/fdoc.gemspec +3 -1
- data/lib/fdoc/cli.rb +129 -0
- data/lib/fdoc/endpoint.rb +5 -1
- data/lib/fdoc/spec_watcher.rb +49 -37
- data/spec/fdoc/cli_spec.rb +257 -0
- data/spec/fdoc/endpoint_spec.rb +4 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/support/capture_helper.rb +14 -0
- metadata +90 -19
- data/bin/fdoc_to_html +0 -77
data/README.md
CHANGED
@@ -70,7 +70,7 @@ fdoc is built to work around your Sinatra app specs in rspec, and provides `Fdoc
|
|
70
70
|
```ruby
|
71
71
|
require 'fdoc/spec_watcher'
|
72
72
|
|
73
|
-
describe Sinatra::
|
73
|
+
describe Sinatra::Application do
|
74
74
|
include Rack::Test::Methods
|
75
75
|
include Fdoc::SpecWatcher
|
76
76
|
|
@@ -82,11 +82,11 @@ end
|
|
82
82
|
|
83
83
|
### Outside a Rails App
|
84
84
|
|
85
|
-
fdoc provides the `
|
85
|
+
fdoc provides the `fdoc convert` script to transform a directory of `.fdoc` files into more human-readable HTML.
|
86
86
|
|
87
87
|
In this repo, try running:
|
88
88
|
|
89
|
-
bin/
|
89
|
+
bin/fdoc convert ./spec/fixtures --output=./html
|
90
90
|
|
91
91
|
## Example
|
92
92
|
|
@@ -137,7 +137,7 @@ Our spec file, `spec/controllers/members_controller_spec.rb` looks like:
|
|
137
137
|
require 'fdoc/spec_watcher'
|
138
138
|
|
139
139
|
describe MembersController do
|
140
|
-
|
140
|
+
context "#show", :fdoc => "members/list" do
|
141
141
|
it "can take an offset" do
|
142
142
|
get :show, {
|
143
143
|
:offset => 5
|
data/bin/fdoc
ADDED
data/fdoc.gemspec
CHANGED
@@ -23,14 +23,16 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.files = Dir['{lib,spec}/**/*'] + %w(fdoc.gemspec Rakefile README.md Gemfile)
|
24
24
|
s.test_files = Dir['spec/**/*']
|
25
25
|
s.bindir = "bin"
|
26
|
-
s.executables << "
|
26
|
+
s.executables << "fdoc"
|
27
27
|
|
28
28
|
s.add_dependency("json")
|
29
29
|
s.add_dependency("json-schema", ">= 1.0.1")
|
30
30
|
s.add_dependency("kramdown")
|
31
|
+
s.add_dependency("thor")
|
31
32
|
|
32
33
|
s.add_development_dependency("rake")
|
33
34
|
s.add_development_dependency("rspec", "~> 2.5")
|
34
35
|
s.add_development_dependency("nokogiri")
|
35
36
|
s.add_development_dependency("cane")
|
37
|
+
s.add_development_dependency("guard-rspec")
|
36
38
|
end
|
data/lib/fdoc/cli.rb
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'fdoc/service'
|
3
|
+
require 'fdoc/meta_service'
|
4
|
+
|
5
|
+
module Fdoc
|
6
|
+
# A Thor::Error to be thrown when an fdoc directory is not found
|
7
|
+
class NotFound < Thor::Error; end
|
8
|
+
|
9
|
+
# A Thor::Error to be thrown when an fdoc output destination is unavailable
|
10
|
+
class NotADirectory < Thor::Error; end
|
11
|
+
|
12
|
+
# A Thor definition for an fdoc to HTML conversion operation
|
13
|
+
class Cli < Thor
|
14
|
+
include Thor::Actions
|
15
|
+
|
16
|
+
attr_accessor :origin_path
|
17
|
+
|
18
|
+
def self.source_root
|
19
|
+
File.expand_path("../templates", __FILE__)
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "convert FDOC_PATH", "Convert fdoc to HTML"
|
23
|
+
method_option :output, :aliases => "-o", :desc => "HTML output path"
|
24
|
+
method_option :url_base_path, :aliases => "-u", :desc => "URL base path"
|
25
|
+
def convert(fdoc_path)
|
26
|
+
say_status nil, "Converting fdoc to HTML"
|
27
|
+
|
28
|
+
self.origin_path = File.expand_path(fdoc_path)
|
29
|
+
raise Fdoc::NotFound.new(origin_path) unless has_valid_origin?
|
30
|
+
say_status :using, fdoc_path
|
31
|
+
|
32
|
+
self.destination_root = output_path
|
33
|
+
raise Fdoc::NotADirectory.new(output_path) unless has_valid_destination?
|
34
|
+
say_status :inside, output_path
|
35
|
+
|
36
|
+
in_root do
|
37
|
+
copy_file("styles.css")
|
38
|
+
create_file("index.html", meta_presenter.to_html) if has_meta_service?
|
39
|
+
end
|
40
|
+
|
41
|
+
service_presenters.each do |service_presenter|
|
42
|
+
inside_service_presenter(service_presenter) do
|
43
|
+
create_file("index.html", service_presenter.to_html)
|
44
|
+
|
45
|
+
service_presenter.endpoints.each do |endpoint_prefix_group|
|
46
|
+
endpoint_prefix_group.each do |endpoint|
|
47
|
+
create_file(endpoint.url, endpoint.to_html)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
no_tasks do
|
55
|
+
def inside_service_presenter(service, &block)
|
56
|
+
if has_meta_service?
|
57
|
+
inside(service.slug_name, {:verbose => true}, &block)
|
58
|
+
else
|
59
|
+
in_root(&block)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def output_path
|
64
|
+
@output_path ||=
|
65
|
+
if options[:output]
|
66
|
+
File.expand_path(options[:output])
|
67
|
+
else
|
68
|
+
File.expand_path("../html", origin_path)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def has_valid_origin?
|
73
|
+
origin.directory?
|
74
|
+
end
|
75
|
+
|
76
|
+
def has_valid_destination?
|
77
|
+
!destination.exist? || destination.directory?
|
78
|
+
end
|
79
|
+
|
80
|
+
def has_meta_service?
|
81
|
+
!meta_service.empty?
|
82
|
+
end
|
83
|
+
|
84
|
+
def service_presenters
|
85
|
+
@service_presenters ||= services.map do |service|
|
86
|
+
Fdoc::ServicePresenter.new(service, html_options)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def html_options
|
91
|
+
{
|
92
|
+
:static_html => true,
|
93
|
+
:url_base_path => options[:url_base_path],
|
94
|
+
:html_directory => destination_root
|
95
|
+
}
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
def services
|
102
|
+
@services ||=
|
103
|
+
if has_meta_service?
|
104
|
+
meta_service.services
|
105
|
+
else
|
106
|
+
[Fdoc::Service.new(origin_path)]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def meta_presenter
|
111
|
+
@meta_presenter ||= Fdoc::MetaServicePresenter.new(
|
112
|
+
meta_service,
|
113
|
+
html_options
|
114
|
+
)
|
115
|
+
end
|
116
|
+
|
117
|
+
def meta_service
|
118
|
+
@meta_service ||= Fdoc::MetaService.new(origin_path)
|
119
|
+
end
|
120
|
+
|
121
|
+
def origin
|
122
|
+
Pathname.new(origin_path)
|
123
|
+
end
|
124
|
+
|
125
|
+
def destination
|
126
|
+
Pathname.new(destination_root)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
data/lib/fdoc/endpoint.rb
CHANGED
@@ -22,9 +22,13 @@ class Fdoc::Endpoint
|
|
22
22
|
|
23
23
|
def consume_response(params, status_code, successful=true)
|
24
24
|
response_code = response_codes.find do |rc|
|
25
|
-
rc["
|
25
|
+
rc["successful"] == successful && (
|
26
|
+
rc["status"] == status_code || # 200
|
27
|
+
rc["status"].to_i == status_code # "200 OK"
|
28
|
+
)
|
26
29
|
end
|
27
30
|
|
31
|
+
|
28
32
|
if !response_code
|
29
33
|
raise Fdoc::UndocumentedResponseCode,
|
30
34
|
'Undocumented response: %s, successful: %s' % [
|
data/lib/fdoc/spec_watcher.rb
CHANGED
@@ -8,50 +8,62 @@ module Fdoc
|
|
8
8
|
define_method(verb) do |*params|
|
9
9
|
action, request_params = params
|
10
10
|
|
11
|
-
|
12
|
-
request_params
|
13
|
-
else
|
14
|
-
begin
|
15
|
-
JSON.parse(request_params)
|
16
|
-
rescue
|
17
|
-
{}
|
18
|
-
end
|
19
|
-
end
|
11
|
+
super(*params)
|
20
12
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
example.metadata[:fdoc]
|
25
|
-
else # Rspec 1.3.2
|
26
|
-
opts = {}
|
27
|
-
__send__(:example_group_hierarchy).each do |example|
|
28
|
-
opts.merge!(example.options)
|
29
|
-
end
|
30
|
-
opts.merge!(options)
|
31
|
-
opts[:fdoc]
|
32
|
-
end
|
13
|
+
check_response(verb, request_params) if path
|
14
|
+
end
|
15
|
+
end
|
33
16
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
17
|
+
private
|
18
|
+
|
19
|
+
def check_response(verb, request_params)
|
20
|
+
successful = Fdoc.decide_success(response_params, real_response.status)
|
21
|
+
Service.verify!(verb, path, parsed_request_params(request_params), response_params,
|
22
|
+
real_response.status, successful)
|
23
|
+
end
|
24
|
+
|
25
|
+
def parsed_request_params request_params
|
26
|
+
if request_params.kind_of?(Hash)
|
27
|
+
request_params
|
28
|
+
else
|
29
|
+
begin
|
30
|
+
JSON.parse(request_params)
|
31
|
+
rescue
|
32
|
+
{}
|
40
33
|
end
|
34
|
+
end
|
35
|
+
end
|
41
36
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
Service.verify!(verb, path, request_params, response_params,
|
50
|
-
real_response.status, successful)
|
37
|
+
def path
|
38
|
+
if respond_to?(:example) # Rspec 2
|
39
|
+
example.metadata[:fdoc]
|
40
|
+
else # Rspec 1.3.2
|
41
|
+
opts = {}
|
42
|
+
__send__(:example_group_hierarchy).each do |example|
|
43
|
+
opts.merge!(example.options)
|
51
44
|
end
|
45
|
+
opts.merge!(options)
|
46
|
+
opts[:fdoc]
|
47
|
+
end
|
48
|
+
end
|
52
49
|
|
53
|
-
|
50
|
+
def real_response
|
51
|
+
if respond_to? :response
|
52
|
+
# we are on rails
|
53
|
+
response
|
54
|
+
else
|
55
|
+
# we are on sinatra
|
56
|
+
last_response
|
54
57
|
end
|
55
58
|
end
|
59
|
+
|
60
|
+
def response_params
|
61
|
+
begin
|
62
|
+
JSON.parse(real_response.body)
|
63
|
+
rescue
|
64
|
+
{}
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
56
68
|
end
|
57
69
|
end
|
@@ -0,0 +1,257 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Fdoc::Cli do
|
4
|
+
let(:fixtures_path) { File.expand_path("../../fixtures", __FILE__) }
|
5
|
+
let(:temporary_path) { Dir.mktmpdir("fdoc-cli") }
|
6
|
+
let(:fdoc_path) { File.expand_path("fdoc", temporary_path) }
|
7
|
+
let(:html_path) { File.expand_path("html", temporary_path) }
|
8
|
+
let(:options) { {} }
|
9
|
+
|
10
|
+
subject(:cli) { Fdoc::Cli.new([fdoc_path], options) }
|
11
|
+
|
12
|
+
before { FileUtils.mkdir_p(fdoc_path) }
|
13
|
+
|
14
|
+
around { |e| capture(:stdout, &e) }
|
15
|
+
|
16
|
+
def with_fixture(fixture_file, destination_file = nil)
|
17
|
+
destination = File.expand_path(destination_file || fixture_file, fdoc_path)
|
18
|
+
FileUtils.mkdir_p(File.dirname(destination))
|
19
|
+
source = File.expand_path(fixture_file, fixtures_path)
|
20
|
+
FileUtils.cp(source, destination)
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#convert" do
|
24
|
+
let(:styles_css_path) { File.expand_path("styles.css", html_path) }
|
25
|
+
|
26
|
+
context "when the fdoc path does not exist" do
|
27
|
+
before { FileUtils.rmdir(fdoc_path) }
|
28
|
+
|
29
|
+
it "raises an exception" do
|
30
|
+
expect do
|
31
|
+
cli.convert(fdoc_path)
|
32
|
+
end.to raise_exception(Fdoc::NotFound)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "when the fdoc path exists" do
|
37
|
+
context "when the destination does not exist" do
|
38
|
+
it "makes a destination directory" do
|
39
|
+
expect do
|
40
|
+
cli.convert(fdoc_path)
|
41
|
+
end.to change { File.directory?(html_path) }.to(true)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context "when the destination exists as a file" do
|
46
|
+
before { FileUtils.touch(html_path) }
|
47
|
+
|
48
|
+
it "raises an exception" do
|
49
|
+
expect do
|
50
|
+
cli.convert(fdoc_path)
|
51
|
+
end.to raise_exception(Fdoc::NotADirectory)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
it "copies the css to the destination" do
|
56
|
+
expect do
|
57
|
+
cli.convert(fdoc_path)
|
58
|
+
end.to change { File.exist?(styles_css_path) }.from(false)
|
59
|
+
end
|
60
|
+
|
61
|
+
context "when there is a meta service fdoc" do
|
62
|
+
let(:root_html) { File.expand_path("index.html", html_path) }
|
63
|
+
let(:members_html) do
|
64
|
+
File.expand_path("members_api/index.html", html_path)
|
65
|
+
end
|
66
|
+
let(:endpoint_html) do
|
67
|
+
File.expand_path("members_api/add-PUT.html", html_path)
|
68
|
+
end
|
69
|
+
|
70
|
+
before { with_fixture("sample_group.fdoc.meta") }
|
71
|
+
|
72
|
+
context "when no service fdoc exists" do
|
73
|
+
specify { expect { cli.convert(fdoc_path) }.to raise_error }
|
74
|
+
end
|
75
|
+
|
76
|
+
context "when a service fdoc exists" do
|
77
|
+
before { with_fixture("members/members.fdoc.service") }
|
78
|
+
|
79
|
+
it "creates a root-level html file" do
|
80
|
+
expect do
|
81
|
+
cli.convert(fdoc_path)
|
82
|
+
end.to change { File.exist?(root_html) }.from(false)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "writes the service-level html file" do
|
86
|
+
expect do
|
87
|
+
cli.convert(fdoc_path)
|
88
|
+
end.to change { File.exist?(members_html) }.from(false)
|
89
|
+
end
|
90
|
+
|
91
|
+
context "when an endpoint fdoc exists" do
|
92
|
+
before { with_fixture("members/add-PUT.fdoc") }
|
93
|
+
|
94
|
+
it "writes the endpoint html file" do
|
95
|
+
expect do
|
96
|
+
cli.convert(fdoc_path)
|
97
|
+
end.to change { File.exist?(endpoint_html) }.from(false)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context "when there is no meta service fdoc" do
|
104
|
+
let(:root_html) { File.expand_path("index.html", html_path) }
|
105
|
+
let(:endpoint_html) do
|
106
|
+
File.expand_path("add-PUT.html", html_path)
|
107
|
+
end
|
108
|
+
|
109
|
+
context "when no service fdoc exists" do
|
110
|
+
it "creates a dummy index" do
|
111
|
+
expect do
|
112
|
+
cli.convert(fdoc_path)
|
113
|
+
end.to change { File.exist?(root_html) }.from(false)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context "when a service fdoc exists" do
|
118
|
+
before do
|
119
|
+
with_fixture("members/members.fdoc.service", "a.fdoc.service")
|
120
|
+
end
|
121
|
+
|
122
|
+
it "writes the service-level html file" do
|
123
|
+
expect do
|
124
|
+
cli.convert(fdoc_path)
|
125
|
+
end.to change { File.exist?(root_html) }.from(false)
|
126
|
+
end
|
127
|
+
|
128
|
+
context "when an endpoint fdoc exists" do
|
129
|
+
before { with_fixture("members/add-PUT.fdoc", "add-PUT.fdoc") }
|
130
|
+
|
131
|
+
it "writes the endpoint html file" do
|
132
|
+
expect do
|
133
|
+
cli.convert(fdoc_path)
|
134
|
+
end.to change { File.exist?(endpoint_html) }.from(false)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe "accessors" do
|
143
|
+
before do
|
144
|
+
subject.origin_path = fdoc_path
|
145
|
+
subject.destination_root = html_path
|
146
|
+
end
|
147
|
+
|
148
|
+
context "by default" do
|
149
|
+
it { should_not have_meta_service }
|
150
|
+
its(:service_presenters) { should have(1).service }
|
151
|
+
its(:output_path) { should =~ /html$/ }
|
152
|
+
end
|
153
|
+
|
154
|
+
context "when an output path is specified" do
|
155
|
+
let(:output_option) { "/a/path/for/html" }
|
156
|
+
let(:options) { {:output => output_option} }
|
157
|
+
|
158
|
+
its(:output_path) { should == output_option }
|
159
|
+
end
|
160
|
+
|
161
|
+
context "when a meta service file exists" do
|
162
|
+
before { with_fixture("sample_group.fdoc.meta") }
|
163
|
+
|
164
|
+
it { should have_meta_service }
|
165
|
+
its(:service_presenters) { should have(1).service }
|
166
|
+
end
|
167
|
+
|
168
|
+
context "when the origin is a directory" do
|
169
|
+
it { should have_valid_origin }
|
170
|
+
end
|
171
|
+
|
172
|
+
context "when the origin does not exist" do
|
173
|
+
before { FileUtils.rmdir(fdoc_path) }
|
174
|
+
|
175
|
+
it { should_not have_valid_origin }
|
176
|
+
end
|
177
|
+
|
178
|
+
context "when the origin is not a directory" do
|
179
|
+
before do
|
180
|
+
FileUtils.rmdir(fdoc_path)
|
181
|
+
FileUtils.touch(fdoc_path)
|
182
|
+
end
|
183
|
+
|
184
|
+
it { should_not have_valid_origin }
|
185
|
+
end
|
186
|
+
|
187
|
+
context "when the destination does not exist" do
|
188
|
+
it { should have_valid_destination }
|
189
|
+
end
|
190
|
+
|
191
|
+
context "when the destination is a directory" do
|
192
|
+
before { FileUtils.mkdir_p(html_path) }
|
193
|
+
|
194
|
+
it { should have_valid_destination }
|
195
|
+
end
|
196
|
+
|
197
|
+
context "when the destination is not a directory" do
|
198
|
+
before { FileUtils.touch(html_path) }
|
199
|
+
|
200
|
+
it { should_not have_valid_destination }
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
describe "#html_options" do
|
205
|
+
let(:html_path) { "/a/great/place/to/keep/html"}
|
206
|
+
|
207
|
+
before { subject.destination_root = html_path }
|
208
|
+
|
209
|
+
its(:html_options) { should include(:static_html => true) }
|
210
|
+
its(:html_options) { should include(:html_directory => html_path) }
|
211
|
+
|
212
|
+
context "when url_base_path is not provided" do
|
213
|
+
its(:html_options) { should include(:url_base_path => nil) }
|
214
|
+
end
|
215
|
+
|
216
|
+
context "when url_base_path is provided" do
|
217
|
+
let(:url_base_path) { "totally/not/like/a/wsdl" }
|
218
|
+
let(:options) { {:url_base_path => url_base_path} }
|
219
|
+
|
220
|
+
its(:html_options) { should include(:url_base_path => url_base_path) }
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
describe "#inside_service" do
|
225
|
+
let(:presenter) { cli.service_presenters.first }
|
226
|
+
|
227
|
+
before do
|
228
|
+
subject.origin_path = fdoc_path
|
229
|
+
subject.destination_root = html_path
|
230
|
+
end
|
231
|
+
|
232
|
+
context "when there is a meta service" do
|
233
|
+
before do
|
234
|
+
with_fixture("sample_group.fdoc.meta")
|
235
|
+
with_fixture("members/members.fdoc.service")
|
236
|
+
end
|
237
|
+
|
238
|
+
it "leaves the output directory" do
|
239
|
+
cli.inside_service_presenter(presenter) do
|
240
|
+
Dir.pwd.should =~ %r|#{html_path}/members_api$|
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
context "when there is a single service" do
|
246
|
+
before do
|
247
|
+
with_fixture("members/members.fdoc.service", "members.fdoc.service")
|
248
|
+
end
|
249
|
+
|
250
|
+
it "does not leave the output directory" do
|
251
|
+
cli.inside_service_presenter(presenter) do
|
252
|
+
Dir.pwd.should =~ /#{html_path}$/
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|
data/spec/fdoc/endpoint_spec.rb
CHANGED
@@ -217,6 +217,10 @@ describe Fdoc::Endpoint do
|
|
217
217
|
subject.consume_response(good_response_params, "200 OK").should be_true
|
218
218
|
end
|
219
219
|
|
220
|
+
it "allows either fully-qualified or integer HTTP status codes" do
|
221
|
+
subject.consume_response(good_response_params, 200).should be_true
|
222
|
+
end
|
223
|
+
|
220
224
|
context "with unknown keys" do
|
221
225
|
it "throws an error when there an unknown key at the top level" do
|
222
226
|
bad_params = good_response_params.merge({"extra_goodness" => true})
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fdoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -15,7 +15,7 @@ date: 2011-11-07 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: json
|
18
|
-
requirement:
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ! '>='
|
@@ -23,10 +23,15 @@ dependencies:
|
|
23
23
|
version: '0'
|
24
24
|
type: :runtime
|
25
25
|
prerelease: false
|
26
|
-
version_requirements:
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
28
|
+
requirements:
|
29
|
+
- - ! '>='
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '0'
|
27
32
|
- !ruby/object:Gem::Dependency
|
28
33
|
name: json-schema
|
29
|
-
requirement:
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
30
35
|
none: false
|
31
36
|
requirements:
|
32
37
|
- - ! '>='
|
@@ -34,10 +39,15 @@ dependencies:
|
|
34
39
|
version: 1.0.1
|
35
40
|
type: :runtime
|
36
41
|
prerelease: false
|
37
|
-
version_requirements:
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.0.1
|
38
48
|
- !ruby/object:Gem::Dependency
|
39
49
|
name: kramdown
|
40
|
-
requirement:
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
41
51
|
none: false
|
42
52
|
requirements:
|
43
53
|
- - ! '>='
|
@@ -45,10 +55,31 @@ dependencies:
|
|
45
55
|
version: '0'
|
46
56
|
type: :runtime
|
47
57
|
prerelease: false
|
48
|
-
version_requirements:
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: thor
|
66
|
+
requirement: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
type: :runtime
|
73
|
+
prerelease: false
|
74
|
+
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
49
80
|
- !ruby/object:Gem::Dependency
|
50
81
|
name: rake
|
51
|
-
requirement:
|
82
|
+
requirement: !ruby/object:Gem::Requirement
|
52
83
|
none: false
|
53
84
|
requirements:
|
54
85
|
- - ! '>='
|
@@ -56,10 +87,15 @@ dependencies:
|
|
56
87
|
version: '0'
|
57
88
|
type: :development
|
58
89
|
prerelease: false
|
59
|
-
version_requirements:
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
60
96
|
- !ruby/object:Gem::Dependency
|
61
97
|
name: rspec
|
62
|
-
requirement:
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
63
99
|
none: false
|
64
100
|
requirements:
|
65
101
|
- - ~>
|
@@ -67,10 +103,15 @@ dependencies:
|
|
67
103
|
version: '2.5'
|
68
104
|
type: :development
|
69
105
|
prerelease: false
|
70
|
-
version_requirements:
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ~>
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '2.5'
|
71
112
|
- !ruby/object:Gem::Dependency
|
72
113
|
name: nokogiri
|
73
|
-
requirement:
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
74
115
|
none: false
|
75
116
|
requirements:
|
76
117
|
- - ! '>='
|
@@ -78,10 +119,31 @@ dependencies:
|
|
78
119
|
version: '0'
|
79
120
|
type: :development
|
80
121
|
prerelease: false
|
81
|
-
version_requirements:
|
122
|
+
version_requirements: !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ! '>='
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
82
128
|
- !ruby/object:Gem::Dependency
|
83
129
|
name: cane
|
84
|
-
requirement:
|
130
|
+
requirement: !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
132
|
+
requirements:
|
133
|
+
- - ! '>='
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
type: :development
|
137
|
+
prerelease: false
|
138
|
+
version_requirements: !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ! '>='
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
- !ruby/object:Gem::Dependency
|
145
|
+
name: guard-rspec
|
146
|
+
requirement: !ruby/object:Gem::Requirement
|
85
147
|
none: false
|
86
148
|
requirements:
|
87
149
|
- - ! '>='
|
@@ -89,16 +151,22 @@ dependencies:
|
|
89
151
|
version: '0'
|
90
152
|
type: :development
|
91
153
|
prerelease: false
|
92
|
-
version_requirements:
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
none: false
|
156
|
+
requirements:
|
157
|
+
- - ! '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
93
160
|
description: A tool for documenting API endpoints.
|
94
161
|
email: support@squareup.com
|
95
162
|
executables:
|
96
|
-
-
|
163
|
+
- fdoc
|
97
164
|
extensions: []
|
98
165
|
extra_rdoc_files:
|
99
166
|
- README.md
|
100
167
|
files:
|
101
168
|
- lib/endpoint-schema.yaml
|
169
|
+
- lib/fdoc/cli.rb
|
102
170
|
- lib/fdoc/endpoint.rb
|
103
171
|
- lib/fdoc/endpoint_scaffold.rb
|
104
172
|
- lib/fdoc/meta_service.rb
|
@@ -115,6 +183,7 @@ files:
|
|
115
183
|
- lib/fdoc/templates/service.html.erb
|
116
184
|
- lib/fdoc/templates/styles.css
|
117
185
|
- lib/fdoc.rb
|
186
|
+
- spec/fdoc/cli_spec.rb
|
118
187
|
- spec/fdoc/endpoint_scaffold_spec.rb
|
119
188
|
- spec/fdoc/endpoint_spec.rb
|
120
189
|
- spec/fdoc/presenters/endpoint_presenter_spec.rb
|
@@ -129,11 +198,12 @@ files:
|
|
129
198
|
- spec/fixtures/members/members.fdoc.service
|
130
199
|
- spec/fixtures/sample_group.fdoc.meta
|
131
200
|
- spec/spec_helper.rb
|
201
|
+
- spec/support/capture_helper.rb
|
132
202
|
- fdoc.gemspec
|
133
203
|
- Rakefile
|
134
204
|
- README.md
|
135
205
|
- Gemfile
|
136
|
-
- bin/
|
206
|
+
- bin/fdoc
|
137
207
|
homepage: http://github.com/square/fdoc
|
138
208
|
licenses: []
|
139
209
|
post_install_message:
|
@@ -155,11 +225,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
225
|
version: '0'
|
156
226
|
requirements: []
|
157
227
|
rubyforge_project:
|
158
|
-
rubygems_version: 1.8.
|
228
|
+
rubygems_version: 1.8.24
|
159
229
|
signing_key:
|
160
230
|
specification_version: 3
|
161
231
|
summary: A tool for documenting API endpoints.
|
162
232
|
test_files:
|
233
|
+
- spec/fdoc/cli_spec.rb
|
163
234
|
- spec/fdoc/endpoint_scaffold_spec.rb
|
164
235
|
- spec/fdoc/endpoint_spec.rb
|
165
236
|
- spec/fdoc/presenters/endpoint_presenter_spec.rb
|
@@ -174,4 +245,4 @@ test_files:
|
|
174
245
|
- spec/fixtures/members/members.fdoc.service
|
175
246
|
- spec/fixtures/sample_group.fdoc.meta
|
176
247
|
- spec/spec_helper.rb
|
177
|
-
|
248
|
+
- spec/support/capture_helper.rb
|
data/bin/fdoc_to_html
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__), '../lib/fdoc')
|
4
|
-
|
5
|
-
if ARGV.length < 2
|
6
|
-
exec_name = File.basename($0)
|
7
|
-
abort "Usage: #{exec_name} [fdoc_directory] [html_directory] (url_base_path)"
|
8
|
-
end
|
9
|
-
|
10
|
-
fdoc_directory, html_directory, url_base_path = ARGV[0..2]
|
11
|
-
fdoc_directory = File.expand_path(fdoc_directory)
|
12
|
-
html_directory = File.expand_path(html_directory)
|
13
|
-
|
14
|
-
html_options = {
|
15
|
-
:html_directory => html_directory,
|
16
|
-
:static_html => true,
|
17
|
-
:url_base_path => url_base_path
|
18
|
-
}
|
19
|
-
|
20
|
-
def mkdir(dirname)
|
21
|
-
`mkdir -p #{dirname}` unless File.directory?(dirname)
|
22
|
-
end
|
23
|
-
|
24
|
-
mkdir(html_directory)
|
25
|
-
|
26
|
-
meta_service = Fdoc::MetaService.new(fdoc_directory)
|
27
|
-
services = if !meta_service.empty?
|
28
|
-
meta_service.services
|
29
|
-
else
|
30
|
-
Array(Fdoc::Service.new(fdoc_directory))
|
31
|
-
end
|
32
|
-
|
33
|
-
if !meta_service.empty?
|
34
|
-
meta_service_presenter= Fdoc::MetaServicePresenter.new(
|
35
|
-
meta_service, html_options
|
36
|
-
)
|
37
|
-
|
38
|
-
index_html_path = File.join(html_directory, "index.html")
|
39
|
-
File.open(index_html_path, "w") do |file|
|
40
|
-
file.write(meta_service_presenter.to_html)
|
41
|
-
|
42
|
-
puts "created #{index_html_path}"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
css_path = File.join(File.dirname(__FILE__), '../lib/fdoc/templates/styles.css')
|
47
|
-
`cp "#{css_path}" "#{html_directory}"`
|
48
|
-
puts "created #{File.expand_path(css_path)}"
|
49
|
-
|
50
|
-
services.each do |service|
|
51
|
-
service_presenter = Fdoc::ServicePresenter.new(service, html_options)
|
52
|
-
html_sub_directory = if meta_service.empty?
|
53
|
-
html_directory
|
54
|
-
else
|
55
|
-
File.join(html_directory, service_presenter.slug_name)
|
56
|
-
end
|
57
|
-
|
58
|
-
mkdir(html_sub_directory)
|
59
|
-
|
60
|
-
index_html_path = File.join(html_sub_directory, "index.html")
|
61
|
-
File.open(index_html_path, "w") do |file|
|
62
|
-
file.write(service_presenter.to_html)
|
63
|
-
|
64
|
-
puts "created #{index_html_path}"
|
65
|
-
end
|
66
|
-
|
67
|
-
service_presenter.endpoints.flatten.each do |endpoint|
|
68
|
-
endpoint_html_path = File.join(html_sub_directory, endpoint.url)
|
69
|
-
mkdir(File.dirname(endpoint_html_path))
|
70
|
-
|
71
|
-
File.open(endpoint_html_path, "w") do |file|
|
72
|
-
file.write(endpoint.to_html)
|
73
|
-
|
74
|
-
puts "created #{endpoint_html_path}"
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|