docify 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -1
- data/bin/docify +5 -0
- data/docify.gemspec +1 -0
- data/lib/docify.rb +6 -1
- data/lib/docify/markup.rb +13 -9
- data/lib/docify/version.rb +1 -1
- data/spec/fixtures/README.markdown +2 -0
- data/spec/fixtures/README.markdown.html +5 -0
- data/spec/fixtures/README.rdoc +9 -0
- data/spec/fixtures/README.rdoc.html +15 -0
- data/spec/fixtures/README.textile +2 -0
- data/spec/fixtures/README.textile.html +4 -0
- data/spec/markup_spec.rb +15 -0
- data/spec/spec_helper.rb +9 -1
- metadata +27 -2
data/Rakefile
CHANGED
data/bin/docify
CHANGED
@@ -49,6 +49,8 @@ begin
|
|
49
49
|
optparse.parse!
|
50
50
|
file = ARGV.shift.to_s.strip
|
51
51
|
unless file.empty?
|
52
|
+
file = File.expand_path(file)
|
53
|
+
|
52
54
|
begin
|
53
55
|
options[:format] = Docify.detect_format(file)
|
54
56
|
doc = Docify::Document.new(file)
|
@@ -61,6 +63,9 @@ begin
|
|
61
63
|
rescue ArgumentError => e
|
62
64
|
puts "Error: #{e.message}"
|
63
65
|
exit
|
66
|
+
rescue Exception => e
|
67
|
+
puts "Error: #{e.message}"
|
68
|
+
exit
|
64
69
|
end
|
65
70
|
else
|
66
71
|
puts optparse.to_s
|
data/docify.gemspec
CHANGED
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
|
18
18
|
s.add_runtime_dependency 'rdiscount', '~> 1.6.8'
|
19
19
|
s.add_runtime_dependency 'RedCloth', '~> 4.2.3'
|
20
|
+
s.add_runtime_dependency 'rdoc', '~> 3.5'
|
20
21
|
|
21
22
|
s.files = `git ls-files`.split("\n")
|
22
23
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/lib/docify.rb
CHANGED
data/lib/docify/markup.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
-
if RUBY_VERSION
|
1
|
+
if RUBY_VERSION >= '1.9'
|
2
2
|
require 'rdoc/markup/to_html'
|
3
3
|
else
|
4
4
|
require 'rdoc/generators/html_generator'
|
5
5
|
require 'ostruct'
|
6
6
|
end
|
7
7
|
|
8
|
+
require 'RedCloth'
|
9
|
+
require 'rdiscount'
|
10
|
+
|
8
11
|
module Docify
|
9
12
|
module Markup
|
10
13
|
extend self
|
@@ -17,15 +20,11 @@ module Docify
|
|
17
20
|
format == :text ? content : self.send(format, content)
|
18
21
|
end
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
Markdown.new(content).to_html
|
23
|
-
end
|
24
|
-
|
25
|
-
if RUBY_VERSION.include?('1.9')
|
26
|
-
# Render content for RDoc
|
23
|
+
if RUBY_VERSION >= '1.9'
|
24
|
+
# Render content for RDoc on Ruby 1.9
|
27
25
|
def rdoc(content)
|
28
|
-
RDoc::Markup::ToHtml.new
|
26
|
+
markup = RDoc::Markup::ToHtml.new
|
27
|
+
markup.convert(content)
|
29
28
|
end
|
30
29
|
else
|
31
30
|
# Render content for RDoc
|
@@ -38,6 +37,11 @@ module Docify
|
|
38
37
|
end
|
39
38
|
end
|
40
39
|
|
40
|
+
# Render content for Markdown
|
41
|
+
def markdown(content)
|
42
|
+
Markdown.new(content).to_html
|
43
|
+
end
|
44
|
+
|
41
45
|
# Render content for Textile
|
42
46
|
def textile(content)
|
43
47
|
RedCloth.new(content).to_html
|
data/lib/docify/version.rb
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
<p>
|
2
|
+
<a href="RDoc.html">RDoc.html</a>
|
3
|
+
</p>
|
4
|
+
<p>
|
5
|
+
<a href="http://rdoc.rubyforge.org">rdoc.rubyforge.org</a>
|
6
|
+
</p>
|
7
|
+
<p>
|
8
|
+
<a href="mailto:user@example.com">user@example.com</a>
|
9
|
+
</p>
|
10
|
+
<p>
|
11
|
+
<a href="http://rdoc.rubyforge.org">RDoc Documentation</a>
|
12
|
+
</p>
|
13
|
+
<p>
|
14
|
+
<a href="../RDoc/Markup.html">RDoc Markup</a>
|
15
|
+
</p>
|
data/spec/markup_spec.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Docify::Markup do
|
4
|
+
it 'should render RDoc' do
|
5
|
+
Docify::Markup.render('README.rdoc', fixture('README.rdoc')).should == fixture('README.rdoc.html')
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should render Markdown' do
|
9
|
+
Docify::Markup.render('README.markdown', fixture('README.markdown')).should == fixture('README.markdown.html')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should render Textile' do
|
13
|
+
Docify::Markup.render('README.textile', fixture('README.textile')).should == fixture('README.textile.html')
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -15,4 +15,12 @@ README_FILES = {
|
|
15
15
|
'README.textile' => 'textile',
|
16
16
|
'README.txt' => 'rdoc',
|
17
17
|
'README.foo' => 'rdoc'
|
18
|
-
}
|
18
|
+
}
|
19
|
+
|
20
|
+
def fixture_path
|
21
|
+
File.expand_path("../fixtures", __FILE__)
|
22
|
+
end
|
23
|
+
|
24
|
+
def fixture(file)
|
25
|
+
File.read(File.join(fixture_path, file))
|
26
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: docify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.0.
|
5
|
+
version: 1.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Dan Sosedoff
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-06-
|
13
|
+
date: 2011-06-23 00:00:00 -05:00
|
14
14
|
default_executable: docify
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -90,6 +90,17 @@ dependencies:
|
|
90
90
|
version: 4.2.3
|
91
91
|
type: :runtime
|
92
92
|
version_requirements: *id007
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: rdoc
|
95
|
+
prerelease: false
|
96
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: "3.5"
|
102
|
+
type: :runtime
|
103
|
+
version_requirements: *id008
|
93
104
|
description: Docify provides a command line tool to render documentation files (RDoc, Markdown, Textile) into nice-looking html.
|
94
105
|
email:
|
95
106
|
- dan.sosedoff@gmail.com
|
@@ -115,6 +126,13 @@ files:
|
|
115
126
|
- lib/docify/version.rb
|
116
127
|
- spec/docify_spec.rb
|
117
128
|
- spec/document_spec.rb
|
129
|
+
- spec/fixtures/README.markdown
|
130
|
+
- spec/fixtures/README.markdown.html
|
131
|
+
- spec/fixtures/README.rdoc
|
132
|
+
- spec/fixtures/README.rdoc.html
|
133
|
+
- spec/fixtures/README.textile
|
134
|
+
- spec/fixtures/README.textile.html
|
135
|
+
- spec/markup_spec.rb
|
118
136
|
- spec/spec_helper.rb
|
119
137
|
has_rdoc: true
|
120
138
|
homepage: http://github.com/sosedoff/docify
|
@@ -147,4 +165,11 @@ summary: Terminal tool to render markups into html
|
|
147
165
|
test_files:
|
148
166
|
- spec/docify_spec.rb
|
149
167
|
- spec/document_spec.rb
|
168
|
+
- spec/fixtures/README.markdown
|
169
|
+
- spec/fixtures/README.markdown.html
|
170
|
+
- spec/fixtures/README.rdoc
|
171
|
+
- spec/fixtures/README.rdoc.html
|
172
|
+
- spec/fixtures/README.textile
|
173
|
+
- spec/fixtures/README.textile.html
|
174
|
+
- spec/markup_spec.rb
|
150
175
|
- spec/spec_helper.rb
|