documentary 0.1.0 → 0.1.1
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/Gemfile.lock +4 -4
- data/README.md +13 -14
- data/documentary.gemspec +2 -1
- data/lib/default_layout.erb +4 -0
- data/lib/documentary/version.rb +1 -1
- data/lib/documentary/view/helpers.rb +23 -4
- data/test/integration_helper.rb +4 -4
- data/test/integration_test.rb +10 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cd2c7bca305075774d21b7fe6aaa73a5c8adc4c
|
4
|
+
data.tar.gz: 7de58c814f31b1c2c0ae0d17ad21b2656143b0a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0153f941656a662f53108687263880f8774aa9aa4a5df018b44a11776525482912cc8110c608f8dd70f5a4503ddb8dde30b851e1046002924023898bff99c75
|
7
|
+
data.tar.gz: afb5123c1d0b2c7e1bb4fb40ae5234df835401a5ca256a742ee00cde3717aa935377cbdc36ed80c6513840bb723a2711a91c50bfaf26694e31fb5efdc770190d
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
documentary (0.1.
|
4
|
+
documentary (0.1.1)
|
5
5
|
activesupport
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activesupport (4.2.
|
10
|
+
activesupport (4.2.6)
|
11
11
|
i18n (~> 0.7)
|
12
12
|
json (~> 1.7, >= 1.7.7)
|
13
13
|
minitest (~> 5.1)
|
@@ -15,10 +15,10 @@ GEM
|
|
15
15
|
tzinfo (~> 1.1)
|
16
16
|
byebug (9.0.5)
|
17
17
|
i18n (0.7.0)
|
18
|
-
json (1.8.
|
18
|
+
json (1.8.3)
|
19
19
|
minitest (5.4.3)
|
20
20
|
rake (10.3.2)
|
21
|
-
thread_safe (0.3.
|
21
|
+
thread_safe (0.3.5)
|
22
22
|
tzinfo (1.2.2)
|
23
23
|
thread_safe (~> 0.1)
|
24
24
|
|
data/README.md
CHANGED
@@ -6,20 +6,19 @@ A simple tool that will allow you to generate API runnable documentation quickly
|
|
6
6
|
>
|
7
7
|
> -- <cite>Kathy Sierra</cite>
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
* [ ] Create testing suite
|
9
|
+
[Example of the documentation generated](https://gist.github.com/bangline/edeb0201b13b2721be3764f5fa0c76d5)
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
```
|
14
|
+
gem install documentary
|
15
|
+
```
|
16
|
+
|
17
|
+
Or in your Gemfile:
|
18
|
+
|
19
|
+
```
|
20
|
+
gem 'documentary'
|
21
|
+
```
|
23
22
|
|
24
23
|
## Specification
|
25
24
|
|
data/documentary.gemspec
CHANGED
@@ -5,7 +5,8 @@ Gem::Specification.new do |s|
|
|
5
5
|
s.name = 'documentary'
|
6
6
|
s.version = Documentary::VERSION
|
7
7
|
s.summary = 'Documentary'
|
8
|
-
s.
|
8
|
+
s.homepage = 'https://github.com/bangline/documentary'
|
9
|
+
s.description = 'Simple, useable, maintainable API documentation'
|
9
10
|
s.authors = ['Dave Kennedy']
|
10
11
|
s.email = 'david@bangline.co.uk'
|
11
12
|
s.files = `git ls-files`.split("\n")
|
data/lib/default_layout.erb
CHANGED
data/lib/documentary/version.rb
CHANGED
@@ -2,6 +2,21 @@ module Documentary
|
|
2
2
|
module View
|
3
3
|
require 'stringio'
|
4
4
|
|
5
|
+
def toc
|
6
|
+
io = StringIO.new
|
7
|
+
io.puts "### [Resources](#resources)"
|
8
|
+
io.puts new_line
|
9
|
+
docblocks.resources.each do |resource|
|
10
|
+
io.puts "* #{link_to(resource.title)}"
|
11
|
+
end
|
12
|
+
io.puts new_line
|
13
|
+
io.puts "### [Endpoints](#endpoints)"
|
14
|
+
docblocks.endpoints.each do |endpoint|
|
15
|
+
io.puts "* #{link_to(endpoint.title)}"
|
16
|
+
end
|
17
|
+
io.string
|
18
|
+
end
|
19
|
+
|
5
20
|
def title_blocks
|
6
21
|
io = StringIO.new
|
7
22
|
docblocks.title_blocks.each do |title_block|
|
@@ -15,10 +30,10 @@ module Documentary
|
|
15
30
|
|
16
31
|
def resource_blocks
|
17
32
|
io = StringIO.new
|
18
|
-
io.puts
|
33
|
+
io.puts "## #{link_to('Resources')}"
|
19
34
|
io.puts new_line
|
20
35
|
docblocks.resources.each do |resource|
|
21
|
-
io.puts "### #{resource.title}"
|
36
|
+
io.puts "### #{link_to(resource.title)}"
|
22
37
|
io.puts new_line
|
23
38
|
io.puts resource.description
|
24
39
|
io.puts new_line
|
@@ -30,10 +45,10 @@ module Documentary
|
|
30
45
|
|
31
46
|
def endpoint_blocks
|
32
47
|
io = StringIO.new
|
33
|
-
io.puts
|
48
|
+
io.puts "## #{link_to('Endpoints')}"
|
34
49
|
io.puts new_line
|
35
50
|
docblocks.endpoints.each do |endpoint|
|
36
|
-
io.puts "### #{endpoint.title}"
|
51
|
+
io.puts "### #{link_to(endpoint.title)}"
|
37
52
|
io.puts new_line
|
38
53
|
io.puts endpoint.notes if endpoint.notes
|
39
54
|
io.puts new_line
|
@@ -85,6 +100,10 @@ module Documentary
|
|
85
100
|
|
86
101
|
private
|
87
102
|
|
103
|
+
def link_to(title)
|
104
|
+
"[#{title}](##{title.downcase.gsub(' ', '-')})"
|
105
|
+
end
|
106
|
+
|
88
107
|
def resource_attributes(resource, io)
|
89
108
|
io.puts '#### Attributes'
|
90
109
|
io.puts new_line
|
data/test/integration_helper.rb
CHANGED
@@ -16,11 +16,11 @@ class Minitest::Test
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def assert_has_resource_title
|
19
|
-
assert_includes generated_docs, "## Resources"
|
19
|
+
assert_includes generated_docs, "## [Resources](#resources)"
|
20
20
|
end
|
21
21
|
|
22
22
|
def assert_has_enpoints_title
|
23
|
-
assert_includes generated_docs, "## Endpoints"
|
23
|
+
assert_includes generated_docs, "## [Endpoints](#endpoints)"
|
24
24
|
end
|
25
25
|
|
26
26
|
def assert_has_third_level_heading(heading)
|
@@ -28,10 +28,10 @@ class Minitest::Test
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def assert_content_for_resource(resource, content)
|
31
|
-
assert_match /### #{resource}\n\n#{content}/, generated_docs
|
31
|
+
assert_match /### \[#{resource}\]\(##{resource.downcase.gsub(' ', '-')}\)\n\n#{content}/, generated_docs
|
32
32
|
end
|
33
33
|
|
34
34
|
def assert_table_entry_for_resource(resource, row_content)
|
35
35
|
assert_match /### #{resource}[.+]#{row_content[:name]} | #{row_content[:required]} | #{row_content[:type]}/, generated_docs
|
36
36
|
end
|
37
|
-
end
|
37
|
+
end
|
data/test/integration_test.rb
CHANGED
@@ -35,7 +35,7 @@ class Documentary::IntegrationTest < MiniTest::Test
|
|
35
35
|
end
|
36
36
|
|
37
37
|
test 'named resources are correctly generated' do
|
38
|
-
|
38
|
+
assert_includes generated_docs, '### [A Resource](#a-resource)'
|
39
39
|
end
|
40
40
|
|
41
41
|
test 'named resources descriptions are correctly generated' do
|
@@ -51,7 +51,7 @@ class Documentary::IntegrationTest < MiniTest::Test
|
|
51
51
|
end
|
52
52
|
|
53
53
|
test 'named enpoints are correctly generated' do
|
54
|
-
assert_includes generated_docs, '### List endpoint'
|
54
|
+
assert_includes generated_docs, '### [List endpoint](#list-endpoint)'
|
55
55
|
end
|
56
56
|
|
57
57
|
test 'enpoint url is generated' do
|
@@ -77,4 +77,12 @@ class Documentary::IntegrationTest < MiniTest::Test
|
|
77
77
|
assert_includes generated_docs, "#### Example Response\n\n```\n"
|
78
78
|
assert_includes generated_docs, "\"page\": 1,\n"
|
79
79
|
end
|
80
|
+
|
81
|
+
test 'TOC is generated' do
|
82
|
+
assert_includes generated_docs, "## Contents\n"
|
83
|
+
assert_includes generated_docs, "### [Resources](#resources)\n"
|
84
|
+
assert_includes generated_docs, "* [A Resource](#a-resource)\n"
|
85
|
+
assert_includes generated_docs, "### [Endpoints](#endpoints)\n"
|
86
|
+
assert_includes generated_docs, "* [List endpoint](#list-endpoint)\n"
|
87
|
+
end
|
80
88
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: documentary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave Kennedy
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 10.3.2
|
55
|
-
description: Simple, useable,
|
55
|
+
description: Simple, useable, maintainable API documentation
|
56
56
|
email: david@bangline.co.uk
|
57
57
|
executables:
|
58
58
|
- documentary
|