autodoc 0.2.3 → 0.2.4
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/lib/autodoc.rb +4 -3
- data/lib/autodoc/document.rb +0 -2
- data/lib/autodoc/documents.rb +20 -0
- data/lib/autodoc/rspec.rb +2 -9
- data/lib/autodoc/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17b75404749690142753e26acbf21f0a6de60e55
|
4
|
+
data.tar.gz: f80c464a81660e905980d3d7320e13f456bc23ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a73209f5f781748ec290b6cbb3a440011badce544d33168ad88853d3ded1c3d440047a00939abb745b4afac35949e3ebb0fb60a1727b534964edddb6ff5151bb
|
7
|
+
data.tar.gz: 0d9b83795d1b0c116804ef78794d9a5de0081cac9f1a6d40cc736be125d8a0fc1637a5854f2cf4f70fd9912fc76fd0429d647ef9f6e3c01dc3472804874597b1
|
data/CHANGELOG.md
CHANGED
data/lib/autodoc.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
require "autodoc/configuration"
|
2
2
|
require "autodoc/document"
|
3
|
+
require "autodoc/documents"
|
3
4
|
require "autodoc/version"
|
4
5
|
require "autodoc/rspec" if ENV["AUTODOC"]
|
5
6
|
|
6
7
|
module Autodoc
|
7
8
|
class << self
|
8
|
-
def
|
9
|
-
@
|
9
|
+
def documents
|
10
|
+
@documents ||= Documents.new
|
10
11
|
end
|
11
12
|
|
12
13
|
def configuration
|
13
|
-
@configuration ||=
|
14
|
+
@configuration ||= Configuration.new
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
data/lib/autodoc/document.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Autodoc
|
2
|
+
class Documents
|
3
|
+
def initialize
|
4
|
+
@table = Hash.new {|table, key| table[key] = [] }
|
5
|
+
end
|
6
|
+
|
7
|
+
def append(context)
|
8
|
+
path = context.example.file_path.gsub(%r<\./spec/requests/(.+)_spec\.rb>, '\1.md')
|
9
|
+
key = Autodoc.configuration.base_path + path
|
10
|
+
@table[key] << Autodoc::Document.render(context)
|
11
|
+
end
|
12
|
+
|
13
|
+
def write
|
14
|
+
@table.each do |pathname, documents|
|
15
|
+
pathname.parent.mkpath
|
16
|
+
pathname.open("w") {|file| file << documents.join("\n").rstrip + "\n" }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/autodoc/rspec.rb
CHANGED
@@ -1,16 +1,9 @@
|
|
1
1
|
require "rspec"
|
2
2
|
|
3
3
|
RSpec.configuration.after(:each, autodoc: true) do
|
4
|
-
Autodoc.
|
4
|
+
Autodoc.documents.append(self)
|
5
5
|
end
|
6
6
|
|
7
7
|
RSpec.configuration.after(:suite) do
|
8
|
-
|
9
|
-
table.each do |path, contexts|
|
10
|
-
pathname = Autodoc.configuration.base_path + path.gsub("./spec/requests/", "").gsub("_spec.rb", ".md")
|
11
|
-
pathname.parent.mkpath
|
12
|
-
pathname.open("w") do |file|
|
13
|
-
file << contexts.map {|context| Autodoc::Document.render(context) }.join("\n").rstrip + "\n"
|
14
|
-
end
|
15
|
-
end
|
8
|
+
Autodoc.documents.write
|
16
9
|
end
|
data/lib/autodoc/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: autodoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- lib/autodoc.rb
|
112
112
|
- lib/autodoc/configuration.rb
|
113
113
|
- lib/autodoc/document.rb
|
114
|
+
- lib/autodoc/documents.rb
|
114
115
|
- lib/autodoc/rspec.rb
|
115
116
|
- lib/autodoc/template.md.erb
|
116
117
|
- lib/autodoc/version.rb
|