doc_to_pdf 0.0.1 → 0.1.0
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.
- data/CHANGELOG.md +13 -1
- data/Gemfile +2 -1
- data/README.md +83 -3
- data/doc_to_pdf.gemspec +1 -0
- data/lib/doc_to_pdf/version.rb +1 -1
- data/lib/tasks/doc_to_pdf.rake +26 -8
- data/spec/wkhmtltopdf_spec.rb +1 -1
- metadata +20 -4
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,19 @@
|
|
1
1
|
|
2
2
|
#### [Current]
|
3
|
+
* [fe4b8e8](../../commit/fe4b8e8) readme updated __(Ruben Espinosa)__
|
4
|
+
* [508405c](../../commit/508405c) changelog __(Ruben Espinosa)__
|
5
|
+
* [dd02d98](../../commit/dd02d98) cleaning html, colorized output __(Ruben Espinosa)__
|
6
|
+
* [9b1ebf6](../../commit/9b1ebf6) Bump to 0.1.0 __(Ruben Espinosa)__
|
7
|
+
* [7aa86ac](../../commit/7aa86ac) test __(Ruben Espinosa)__
|
8
|
+
* [f373e04](../../commit/f373e04) test wkhtmltopfd binarie __(Ruben Espinosa)__
|
9
|
+
* [7d7be81](../../commit/7d7be81) fixing test __(Ruben Espinosa)__
|
10
|
+
* [429fc6a](../../commit/429fc6a) travis and coveralls badgets __(Ruben Espinosa)__
|
11
|
+
* [e5b7bea](../../commit/e5b7bea) updated readme __(Ruben Espinosa)__
|
12
|
+
* [6b9c215](../../commit/6b9c215) changelog and updated readme __(Ruben Espinosa)__
|
13
|
+
* [db25e78](../../commit/db25e78) readme updated __(Ruben Espinosa)__
|
3
14
|
|
4
|
-
####
|
15
|
+
#### v0.0.1
|
16
|
+
* [ee825b1](../../commit/ee825b1) changelog __(Ruben Espinosa)__
|
5
17
|
* [ea39a6c](../../commit/ea39a6c) path validation and colorize gem __(Ruben Espinosa)__
|
6
18
|
* [ab309b6](../../commit/ab309b6) fisrt step in task __(Ruben Espinosa)__
|
7
19
|
* [e9dbd9d](../../commit/e9dbd9d) changelog __(Ruben Espinosa)__
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,13 +1,23 @@
|
|
1
1
|
# DocToPdf
|
2
|
+
[](http://badge.fury.io/rb/doc_to_pdf)
|
3
|
+
[](https://codeclimate.com/github/rderoldan1/doc_to_pdf)
|
4
|
+
[](https://coveralls.io/r/rderoldan1/doc_to_pdf)
|
5
|
+
[](https://travis-ci.org/rderoldan1/doc_to_pdf)
|
2
6
|
|
3
|
-
|
7
|
+
GEM to export rdoc in a pdf file using [wkhtmltopdf libary](http://code.google.com/p/wkhtmltopdf/)
|
4
8
|
|
5
|
-
##
|
9
|
+
## Instalation
|
6
10
|
|
7
11
|
Add this line to your application's Gemfile:
|
8
12
|
|
9
13
|
gem 'doc_to_pdf'
|
10
14
|
|
15
|
+
if you like it works only in your dev env, include in your dev group in Gemfile:
|
16
|
+
|
17
|
+
group :development do
|
18
|
+
gem 'doc_to_pdf'
|
19
|
+
end
|
20
|
+
|
11
21
|
And then execute:
|
12
22
|
|
13
23
|
$ bundle
|
@@ -18,7 +28,77 @@ Or install it yourself as:
|
|
18
28
|
|
19
29
|
## Usage
|
20
30
|
|
21
|
-
|
31
|
+
First create rdoc documetation with rdoc as you actually do:
|
32
|
+
|
33
|
+
#all your app
|
34
|
+
rdoc
|
35
|
+
|
36
|
+
#only app/ folder
|
37
|
+
rake doc:app
|
38
|
+
|
39
|
+
The gem include a rake task under `doc` namespace
|
40
|
+
|
41
|
+
rake doc:pdf
|
42
|
+
|
43
|
+
If you like to change the default name "doc.pdf" call the programm with file param:
|
44
|
+
|
45
|
+
$ rake doc:pdf file=myNewFile
|
46
|
+
Loading pages (1/5)
|
47
|
+
Resolving links (2/5)
|
48
|
+
Counting pages (3/5)
|
49
|
+
Printing pages (5/5)
|
50
|
+
Done
|
51
|
+
|
52
|
+
[Imgur](http://i.imgur.com/w8agvbY.png)
|
53
|
+
|
54
|
+
In my case the menu based in the left is more than 4 pages, and the links doesn't work.
|
55
|
+
|
56
|
+
|
57
|
+
Also it offer an option to clean the "_innecessary_" html, only pass the param `clean=true (default is false)`
|
58
|
+
|
59
|
+
$ rake doc:pdf clean=true
|
60
|
+
clean html, this could take a while.
|
61
|
+
Loading pages (1/5)
|
62
|
+
Resolving links (2/5)
|
63
|
+
Counting pages (3/5)
|
64
|
+
Printing pages (5/5)
|
65
|
+
Done
|
66
|
+
|
67
|
+
[Imgur](http://i.imgur.com/SOq9nm7.png)
|
68
|
+
|
69
|
+
Now it looks cleanner :D
|
70
|
+
|
71
|
+
The pdf file is saved in your application root
|
72
|
+
|
73
|
+
## Recomendations
|
74
|
+
|
75
|
+
* use annotate to comment your models and routes files, [please take a look](https://github.com/ctran/annotate_models)
|
76
|
+
* I created a css for prettier in order to cusmotize more like gituh, the file is in (this gist)[https://gist.github.com/rderoldan1/6396578#file-rdoc-css-L1], if
|
77
|
+
you like to use it replace the custom css.
|
78
|
+
improvements:
|
79
|
+
- Code highlight
|
80
|
+
- Text formating
|
81
|
+
- Fresh colors
|
82
|
+
|
83
|
+
How the css looks?
|
84
|
+
|
85
|
+
[Imgur](http://i.imgur.com/bQGrVCa.png)
|
86
|
+
|
87
|
+
## Tested with
|
88
|
+
|
89
|
+
|
90
|
+
##### OS
|
91
|
+
Mac OS - Mountain Lion
|
92
|
+
Ubuntu - 12.04
|
93
|
+
|
94
|
+
#### Ruby env
|
95
|
+
Ruby 1.9.3
|
96
|
+
Rails 3.2.13
|
97
|
+
|
98
|
+
#### Binaries
|
99
|
+
wkhtmltopdf 0.0.9
|
100
|
+
|
101
|
+
|
22
102
|
|
23
103
|
## Contributing
|
24
104
|
|
data/doc_to_pdf.gemspec
CHANGED
data/lib/doc_to_pdf/version.rb
CHANGED
data/lib/tasks/doc_to_pdf.rake
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'colorize'
|
1
3
|
desc "Turn rdoc files in a pdf document"
|
2
4
|
namespace :doc do
|
3
5
|
task :pdf do
|
4
|
-
if
|
6
|
+
if validate_binary
|
5
7
|
file_name = ENV['file'] || 'doc'
|
6
|
-
|
8
|
+
clean = ENV["clean"] || "false"
|
9
|
+
create(file_name, clean)
|
7
10
|
else
|
8
|
-
puts "Error!\nPlease install wkhtmltopdf\nThis gem is tested in Mac and Linux"
|
11
|
+
puts "Error!\nPlease install wkhtmltopdf\nThis gem is tested in Mac and Linux".red
|
9
12
|
end
|
10
13
|
|
11
14
|
end
|
@@ -13,22 +16,37 @@ end
|
|
13
16
|
|
14
17
|
private
|
15
18
|
|
16
|
-
def create(name)
|
19
|
+
def create(name, clean)
|
17
20
|
path = "#{Rails.root}/doc"
|
18
21
|
files = get_files(path)
|
22
|
+
if clean.eql? "true"
|
23
|
+
puts "clean html, this could take a while.".green
|
24
|
+
files.each {|file| clean_html(file)}
|
25
|
+
end
|
19
26
|
if files.empty?
|
20
|
-
puts "Documentation not found in doc/ folder, please create it with rake doc:app or rdoc"
|
27
|
+
puts "Documentation not found in doc/ folder, please create it with rake doc:app or rdoc".orange
|
21
28
|
else
|
22
|
-
`wkhtmltopdf -O Landscape #{files} #{name}.pdf`
|
29
|
+
`wkhtmltopdf -O Landscape #{files.join(" ")} #{name}.pdf`
|
23
30
|
end
|
24
31
|
|
25
32
|
end
|
26
33
|
|
27
34
|
def get_files(path)
|
28
|
-
Dir["#{path}/**/*.htm*"]
|
35
|
+
Dir["#{path}/**/*.htm*"]
|
29
36
|
end
|
30
37
|
|
31
|
-
def
|
38
|
+
def validate_binary
|
32
39
|
which = `which wkhtmltopdf`
|
33
40
|
$?.success?
|
34
41
|
end
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
def clean_html(path)
|
46
|
+
doc = Nokogiri::HTML(open(path))
|
47
|
+
doc.search("#classindex-section").try(:remove)
|
48
|
+
doc.search("#project-metadata").try(:remove)
|
49
|
+
doc.search("#home-metadata").try(:remove)
|
50
|
+
doc.search("#search-metadata").try(:remove)
|
51
|
+
File.open(path, "w"){|f| f.puts(doc)}
|
52
|
+
end
|
data/spec/wkhmtltopdf_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doc_to_pdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: nokogiri
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
62
78
|
description: Turn documentation stored in doc folder in your rails app in a pdf file
|
63
79
|
using wkhtmltopdf
|
64
80
|
email:
|
@@ -99,7 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
115
|
version: '0'
|
100
116
|
segments:
|
101
117
|
- 0
|
102
|
-
hash:
|
118
|
+
hash: -1393820445308166564
|
103
119
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
120
|
none: false
|
105
121
|
requirements:
|
@@ -108,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
124
|
version: '0'
|
109
125
|
segments:
|
110
126
|
- 0
|
111
|
-
hash:
|
127
|
+
hash: -1393820445308166564
|
112
128
|
requirements:
|
113
129
|
- wkhtmltopdf
|
114
130
|
rubyforge_project:
|