autodoc 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile +1 -0
- data/README.md +4 -0
- data/lib/autodoc/configuration.rb +8 -0
- data/lib/autodoc/documents.rb +15 -0
- data/lib/autodoc/templates/toc.html.erb +82 -0
- data/lib/autodoc/version.rb +1 -1
- data/spec/requests/recipes_spec.rb +7 -7
- data/spec/spec_helper.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3398b87997facd945fc411efcad5b7fe4bd1ea0a
|
4
|
+
data.tar.gz: 86726fc12df1d0e7564edb712b7e9ea3c430dd42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6bf838b4dfe9f2616ff1220189c14b67567dfc8088c2d226f223c1ca2122984666236ae752884098261d67159ebc051ac2d941019b25dc61ff4a4a1538d4597
|
7
|
+
data.tar.gz: e3db0ce08099d05159c6f85921a06232d295a67ebb7c30e34f078f0ce653f6431681fecbecc4d27dbaa84a189add4637619e339ba16b6212d16db1ea8f1cd6a9
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -75,10 +75,14 @@ You can configure `Autodoc.configuration` to change its behavior:
|
|
75
75
|
* template - [String] ERB template for each document (default: [document.md.erb](https://github.com/r7kamura/autodoc/blob/master/lib/autodoc/templates/document.md.erb))
|
76
76
|
* toc_template - [String] ERB template for ToC (default: [toc.md.erb](https://github.com/r7kamura/autodoc/blob/master/lib/autodoc/templates/toc.md.erb))
|
77
77
|
* toc - [Boolean] whether to generate toc.md (default: false)
|
78
|
+
* toc_html_template - [String] ERB template for html ToC (default: [toc.html.erb](https://github.com/r7kamura/autodoc/blob/master/lib/autodoc/templates/toc.html.erb))
|
79
|
+
* toc_html - [Boolean] whether to generate toc.html - a single page documentation with a toc (default: false)
|
78
80
|
|
79
81
|
```ruby
|
80
82
|
# example
|
81
83
|
Autodoc.configuration.path = "doc/api"
|
82
84
|
Autodoc.configuration.toc = true
|
85
|
+
Autodoc.configuration.toc_html = true
|
83
86
|
Autodoc.configuration.template = File.read(File.expand_path("../autodoc/templates/document.md.erb", __FILE__))
|
87
|
+
|
84
88
|
```
|
@@ -34,6 +34,14 @@ module Autodoc
|
|
34
34
|
File.read(File.expand_path("../templates/toc.md.erb", __FILE__))
|
35
35
|
end
|
36
36
|
|
37
|
+
property :toc_html do
|
38
|
+
false
|
39
|
+
end
|
40
|
+
|
41
|
+
property :toc_html_template do
|
42
|
+
File.read(File.expand_path("../templates/toc.html.erb", __FILE__))
|
43
|
+
end
|
44
|
+
|
37
45
|
property :toc do
|
38
46
|
false
|
39
47
|
end
|
data/lib/autodoc/documents.rb
CHANGED
@@ -13,6 +13,8 @@ module Autodoc
|
|
13
13
|
|
14
14
|
def write
|
15
15
|
write_toc if Autodoc.configuration.toc
|
16
|
+
write_toc_html if Autodoc.configuration.toc_html
|
17
|
+
|
16
18
|
write_documents
|
17
19
|
end
|
18
20
|
|
@@ -34,8 +36,21 @@ module Autodoc
|
|
34
36
|
ERB.new(Autodoc.configuration.toc_template, nil, "-").result(binding)
|
35
37
|
end
|
36
38
|
|
39
|
+
def write_toc_html
|
40
|
+
toc_html_path.parent.mkpath
|
41
|
+
toc_html_path.open("w") {|file| file << render_toc_html }
|
42
|
+
end
|
43
|
+
|
44
|
+
def render_toc_html
|
45
|
+
ERB.new(Autodoc.configuration.toc_html_template, nil, "-").result(binding)
|
46
|
+
end
|
47
|
+
|
37
48
|
def toc_path
|
38
49
|
Autodoc.configuration.pathname + "toc.md"
|
39
50
|
end
|
51
|
+
|
52
|
+
def toc_html_path
|
53
|
+
Autodoc.configuration.pathname + "toc.html"
|
54
|
+
end
|
40
55
|
end
|
41
56
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
<%# coding: UTF-8 -%>
|
2
|
+
<head>
|
3
|
+
<style>
|
4
|
+
.api-docs {
|
5
|
+
left: 210px;
|
6
|
+
}
|
7
|
+
|
8
|
+
.api-docs, .api-docs-toc {
|
9
|
+
width: 66%;
|
10
|
+
}
|
11
|
+
|
12
|
+
.api-action {
|
13
|
+
padding: 10px;
|
14
|
+
}
|
15
|
+
|
16
|
+
.tocify-wrapper {
|
17
|
+
overflow-y: auto;
|
18
|
+
overflow-x: hidden;
|
19
|
+
position: fixed;
|
20
|
+
width: 210px;
|
21
|
+
float: left;
|
22
|
+
font-size: 16px;
|
23
|
+
background-color: #AAAADD;
|
24
|
+
top: 1px;
|
25
|
+
bottom: -1px;
|
26
|
+
padding: 10px;
|
27
|
+
}
|
28
|
+
|
29
|
+
.generated-at {
|
30
|
+
position: fixed;
|
31
|
+
bottom: 10px;
|
32
|
+
}
|
33
|
+
|
34
|
+
.api-resource {
|
35
|
+
border-bottom: black 1px solid;
|
36
|
+
}
|
37
|
+
|
38
|
+
pre {
|
39
|
+
padding: 10px;
|
40
|
+
background-color: #CCCCEE;
|
41
|
+
}
|
42
|
+
|
43
|
+
.page-wrapper {
|
44
|
+
margin-left: 240px;
|
45
|
+
min-width: 700px;
|
46
|
+
position: relative;
|
47
|
+
z-index: 10;
|
48
|
+
}
|
49
|
+
</style>
|
50
|
+
</head>
|
51
|
+
<% markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, {fenced_code_blocks: true}) %>
|
52
|
+
<% document_markdown = '' %>
|
53
|
+
<html>
|
54
|
+
<div class='tocify-wrapper'>
|
55
|
+
<h1> Table of Contents </h1>
|
56
|
+
<% @table.sort.each do |pathname, documents| -%>
|
57
|
+
<% title = pathname.cleanpath.to_s.sub(/^.*doc\//,'') -%>
|
58
|
+
<% link = pathname.to_s.html_safe -%>
|
59
|
+
<li>
|
60
|
+
<a href="#<%= link -%>"><%= title -%></a>
|
61
|
+
</li>
|
62
|
+
<%
|
63
|
+
document_markdown += '<div id="' + pathname.to_s.html_safe + '" class="api-resource">'
|
64
|
+
documents.each do |document|
|
65
|
+
document_markdown += '<div class="api-action">'
|
66
|
+
document_markdown += markdown.render(document.render)
|
67
|
+
document_markdown += '</div>'
|
68
|
+
end
|
69
|
+
document_markdown += '</div>'
|
70
|
+
%>
|
71
|
+
<% end -%>
|
72
|
+
<div class='generated-at'>
|
73
|
+
Generated at:
|
74
|
+
<br>
|
75
|
+
<%= Time.now.to_s -%>
|
76
|
+
</div>
|
77
|
+
</div>
|
78
|
+
|
79
|
+
<div class='page-wrapper'>
|
80
|
+
<%= document_markdown -%>
|
81
|
+
</div>
|
82
|
+
</html>
|
data/lib/autodoc/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe "Recipes", type: :request do
|
4
|
-
let(:
|
4
|
+
let(:env_hash) do
|
5
5
|
{ "ACCEPT" => "application/json", "CONTENT_TYPE" => "application/json" }
|
6
6
|
end
|
7
7
|
|
@@ -16,13 +16,13 @@ describe "Recipes", type: :request do
|
|
16
16
|
|
17
17
|
context "with valid condition (using Rack::Test)", autodoc: true do
|
18
18
|
before do
|
19
|
-
|
19
|
+
env_hash["Content-Type"] = "application/json"
|
20
20
|
end
|
21
21
|
|
22
22
|
include Rack::Test::Methods
|
23
23
|
|
24
24
|
it "returns the recipe" do
|
25
|
-
get "/recipes/#{recipe.id}", params,
|
25
|
+
get "/recipes/#{recipe.id}", params, env_hash
|
26
26
|
expect(last_response.status).to eq(200)
|
27
27
|
end
|
28
28
|
end
|
@@ -40,7 +40,7 @@ describe "Recipes", type: :request do
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it "returns 400" do
|
43
|
-
post "/recipes", params.to_json,
|
43
|
+
post "/recipes", params.to_json, env_hash
|
44
44
|
expect(response.status).to eq(400)
|
45
45
|
end
|
46
46
|
end
|
@@ -51,7 +51,7 @@ describe "Recipes", type: :request do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
it "returns 400" do
|
54
|
-
post "/recipes", params.to_json,
|
54
|
+
post "/recipes", params.to_json, env_hash
|
55
55
|
expect(response.status).to eq(400)
|
56
56
|
end
|
57
57
|
end
|
@@ -62,7 +62,7 @@ describe "Recipes", type: :request do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
it "creates a new recipe" do
|
65
|
-
post "/recipes", params.to_json,
|
65
|
+
post "/recipes", params.to_json, env_hash
|
66
66
|
expect(response.status).to eq(201)
|
67
67
|
end
|
68
68
|
end
|
@@ -78,7 +78,7 @@ describe "Recipes", type: :request do
|
|
78
78
|
end
|
79
79
|
|
80
80
|
it "creates a new recipe" do
|
81
|
-
post "/recipes", params.to_json,
|
81
|
+
post "/recipes", params.to_json, env_hash
|
82
82
|
expect(response.status).to eq(201)
|
83
83
|
end
|
84
84
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: autodoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- lib/autodoc/documents.rb
|
129
129
|
- lib/autodoc/rspec.rb
|
130
130
|
- lib/autodoc/templates/document.md.erb
|
131
|
+
- lib/autodoc/templates/toc.html.erb
|
131
132
|
- lib/autodoc/templates/toc.md.erb
|
132
133
|
- lib/autodoc/version.rb
|
133
134
|
- spec/autodoc/documents_spec.rb
|