fetcher-documentator 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/bin/documentator +9 -0
- data/fetcher-documentator.gemspec +21 -0
- data/lib/fetcher-documentator/version.rb +5 -0
- data/lib/fetcher-documentator.rb +92 -0
- metadata +73 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Luciano Bertenasco
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Fetcher::Documentator
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'fetcher-documentator'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install fetcher-documentator
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/documentator
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fetcher-documentator/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "fetcher-documentator"
|
8
|
+
gem.version = Fetcher::Documentator::VERSION
|
9
|
+
gem.authors = ["Luciano Bertenasco", "Xavier Via"]
|
10
|
+
gem.email = ["lbertenasco@gmail.com", "fernando.via@gmail.com"]
|
11
|
+
gem.description = %q{A documentator gem for Fetcher}
|
12
|
+
gem.summary = %q{A documentator gem for Fetcher}
|
13
|
+
gem.homepage = "https://github.com/Fetcher/documentator"
|
14
|
+
|
15
|
+
gem.add_dependency 'fast'
|
16
|
+
|
17
|
+
gem.files = `git ls-files`.split($/)
|
18
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
19
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
20
|
+
gem.require_paths = ["lib"]
|
21
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'fast'
|
2
|
+
require 'fetcher-documentator/version'
|
3
|
+
|
4
|
+
module Fetcher
|
5
|
+
|
6
|
+
class Documentator
|
7
|
+
def initialize path
|
8
|
+
@name = "doc/" + path[4..-4] + ".md"
|
9
|
+
|
10
|
+
@text_flat = flatten File.read path
|
11
|
+
|
12
|
+
@doc = []
|
13
|
+
class_name_parts = path[0..-4].split("/").last.split "_"
|
14
|
+
class_name = ""
|
15
|
+
class_name_parts.each do |part|
|
16
|
+
class_name += part.capitalize
|
17
|
+
end
|
18
|
+
|
19
|
+
@text_flat.length.times do |i|
|
20
|
+
if @text_flat[i].start_with? "##"
|
21
|
+
if @text_flat[i].start_with? "###"
|
22
|
+
method = @text_flat[i][4..-1].split(" ").first
|
23
|
+
@doc << ""
|
24
|
+
@doc << method
|
25
|
+
@doc << ("-" * method.length)
|
26
|
+
@doc << ""
|
27
|
+
@doc << (" " + @text_flat[i][4..-1])
|
28
|
+
elsif @text_flat[i].start_with? "## @"
|
29
|
+
transform_to_link(@text_flat[i][4..-1]).each do |line|
|
30
|
+
@doc << line
|
31
|
+
end
|
32
|
+
else
|
33
|
+
@doc << @text_flat[i][3..-1]
|
34
|
+
if @doc.last.nil?
|
35
|
+
@doc[-1] = ""
|
36
|
+
else
|
37
|
+
unless @doc.last.end_with? ":"
|
38
|
+
@doc[-1] = " #{@doc.last}"
|
39
|
+
else
|
40
|
+
last = @doc.last
|
41
|
+
if @doc[-2] == ""
|
42
|
+
@doc[-1] = "### #{last}"
|
43
|
+
else
|
44
|
+
@doc[-1] = ""
|
45
|
+
@doc << "### #{last}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
unless @text_flat[i] == @text_flat.last
|
50
|
+
@doc << "" unless @text_flat[i + 1].start_with? "##"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
unless @doc.empty?
|
57
|
+
@doc.unshift ("=" * class_name.length)
|
58
|
+
@doc.unshift class_name
|
59
|
+
file.write @name, @doc.join("\n")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def flatten text
|
64
|
+
flat = []
|
65
|
+
text.lines.to_a.each do |line|
|
66
|
+
flat << line.strip
|
67
|
+
end
|
68
|
+
flat
|
69
|
+
end
|
70
|
+
|
71
|
+
def transform_to_link text
|
72
|
+
method = text.split(".").last
|
73
|
+
hierarchy = text.split(".")[0..-2].join(".")
|
74
|
+
hierarchy_parts = hierarchy.split "/"
|
75
|
+
domain = hierarchy_parts.shift
|
76
|
+
capitalized_parts = []
|
77
|
+
hierarchy_parts.each do |part|
|
78
|
+
snaked = part.split "_"
|
79
|
+
up_snaked = []
|
80
|
+
snaked.each do |sn|
|
81
|
+
up_snaked << sn.capitalize
|
82
|
+
end
|
83
|
+
capitalized_parts << up_snaked.join("")
|
84
|
+
end
|
85
|
+
data = []
|
86
|
+
data << "### #{domain}"
|
87
|
+
data << ""
|
88
|
+
data << "[#{method.upcase} #{domain}/#{capitalized_parts.join("/")}](https://github.com/Fetcher/#{domain}/blob/master/doc/#{domain}/#{hierarchy_parts.join("/")}.md##{method})"
|
89
|
+
data
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fetcher-documentator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Luciano Bertenasco
|
9
|
+
- Xavier Via
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2013-02-12 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: fast
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
description: A documentator gem for Fetcher
|
32
|
+
email:
|
33
|
+
- lbertenasco@gmail.com
|
34
|
+
- fernando.via@gmail.com
|
35
|
+
executables:
|
36
|
+
- documentator
|
37
|
+
extensions: []
|
38
|
+
extra_rdoc_files: []
|
39
|
+
files:
|
40
|
+
- .gitignore
|
41
|
+
- Gemfile
|
42
|
+
- LICENSE.txt
|
43
|
+
- README.md
|
44
|
+
- Rakefile
|
45
|
+
- bin/documentator
|
46
|
+
- fetcher-documentator.gemspec
|
47
|
+
- lib/fetcher-documentator.rb
|
48
|
+
- lib/fetcher-documentator/version.rb
|
49
|
+
homepage: https://github.com/Fetcher/documentator
|
50
|
+
licenses: []
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
requirements: []
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.8.23
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: A documentator gem for Fetcher
|
73
|
+
test_files: []
|