doc_to_pdf 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6952265d27f85e1d07741f051da2e53238ed6f93
4
- data.tar.gz: 60a576fb8b452014d52dd12b87297d2cd7fb931d
3
+ metadata.gz: 6eec2c10af1dfdb89da6ea78f1705f6e8b4b8bbe
4
+ data.tar.gz: 849fc5ed65b353560fc061632b8f625671ff7ff2
5
5
  SHA512:
6
- metadata.gz: 7d4fe33ad09b690132372e67a6db864c28fff486ea1c94c1578196e9ed9c974fa8d6c44ffb08d92b854db89f9c00a751eaa5bb87b8df28e6866da821d56faf8b
7
- data.tar.gz: b16cbd6c9076a163ea4a791338bc7c7f1742ead96f0885202ea4df907de3fff3728998729b6ca6705eaec8803af981083d6c2986685a3420421f650966990310
6
+ metadata.gz: 1812e673c80311545c6063241733159c4333c99a62e88985256cf06364aaaf8decbf066b3f61b4c10d5a1f2577a0e705d06fca0a0dadcbe1891942b25f83f5e1
7
+ data.tar.gz: e72d4bab6395de39d795b626892bb7029803b92bd20b8b98f2d7735bf06b7b8d20cbd6af788171e9c27b024da53223aa30dccce9b48dc9879c9ece391568278a
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .ruby-version
@@ -1,5 +1,25 @@
1
1
 
2
2
  #### [Current]
3
+ * [6b5a763](../../commit/6b5a763) css url __(Ruben Espinosa)__
4
+ * [02b228e](../../commit/02b228e) readme __(Ruben Espinosa)__
5
+ * [0272737](../../commit/0272737) changelog __(Ruben Espinosa)__
6
+ * [483dde9](../../commit/483dde9) Downloading css and help command __(Ruben Espinosa)__
7
+ * [0caad8b](../../commit/0caad8b) Bump to 0.2.0 __(Ruben Espinosa)__
8
+ * [e862b4d](../../commit/e862b4d) Merge pull request [#2](../../issues/2) from rderoldan1/nokigiri __(Ruben Espinosa)__
9
+ * [43828b7](../../commit/43828b7) Update README.md __(Ruben Espinosa)__
10
+ * [8cb608b](../../commit/8cb608b) changelog __(Ruben Espinosa)__
11
+ * [c1e3178](../../commit/c1e3178) Update README.md __(Ruben Espinosa)__
12
+ * [ecb1ce5](../../commit/ecb1ce5) Update README.md __(Ruben Espinosa)__
13
+ * [1fe1251](../../commit/1fe1251) Update README.md __(Ruben Espinosa)__
14
+ * [38c6928](../../commit/38c6928) Update README.md __(Ruben Espinosa)__
15
+ * [15f8234](../../commit/15f8234) Update README.md __(Ruben Espinosa)__
16
+ * [3e4f1da](../../commit/3e4f1da) Merge pull request [#1](../../issues/1) from rderoldan1/nokigiri __(Ruben Espinosa)__
17
+
18
+ #### v0.1.3
19
+ * [f970a4f](../../commit/f970a4f) table of contents support __(Ruben Espinosa)__
20
+ * [d440443](../../commit/d440443) Bump to 0.1.3 __(Ruben Espinosa)__
21
+ * [2a6eaca](../../commit/2a6eaca) Bump to 0.1.2 __(Ruben Espinosa)__
22
+ * [7b6af43](../../commit/7b6af43) changelog __(Ruben Espinosa)__
3
23
  * [3408a4c](../../commit/3408a4c) Bump to 0.1.1 __(Ruben Espinosa)__
4
24
  * [5b05208](../../commit/5b05208) delete serach and header __(Ruben Espinosa)__
5
25
 
data/Gemfile CHANGED
@@ -6,4 +6,5 @@ gem 'rspec'
6
6
  gem 'coveralls', :require => false
7
7
  gem 'rails', '3.2.12'
8
8
  gem 'colorize'
9
- gem 'nokogiri'
9
+ gem 'nokogiri'
10
+ gem 'httparty'
data/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  [![Code Climate](https://codeclimate.com/github/rderoldan1/doc_to_pdf.png)](https://codeclimate.com/github/rderoldan1/doc_to_pdf)
4
4
  [![Coverage Status](https://coveralls.io/repos/rderoldan1/doc_to_pdf/badge.png)](https://coveralls.io/r/rderoldan1/doc_to_pdf)
5
5
  [![Build Status](https://travis-ci.org/rderoldan1/doc_to_pdf.png?branch=master)](https://travis-ci.org/rderoldan1/doc_to_pdf)
6
+ [![Dependency Status](https://gemnasium.com/rderoldan1/doc_to_pdf.png)](https://gemnasium.com/rderoldan1/doc_to_pdf)
6
7
 
7
8
  GEM to export rdoc in a pdf file using [wkhtmltopdf libary](http://code.google.com/p/wkhtmltopdf/)
8
9
 
@@ -49,12 +50,12 @@ If you like to change the default name "doc.pdf" call the programm with file par
49
50
  Printing pages (5/5)
50
51
  Done
51
52
 
52
- [Imgur](http://i.imgur.com/w8agvbY.png)
53
+ ![Imgur](http://i.imgur.com/w8agvbY.png)
53
54
 
54
55
  In my case the menu based in the left is more than 4 pages, and the links doesn't work.
55
56
 
56
57
 
57
- Also it offer an option to clean the "_innecessary_" html, only pass the param `clean=true (default is false)`
58
+ Also it offer an option to clean the _"innecessary"_ html, only pass the param `clean=true (default is false)`
58
59
 
59
60
  $ rake doc:pdf clean=true
60
61
  clean html, this could take a while.
@@ -63,41 +64,70 @@ Also it offer an option to clean the "_innecessary_" html, only pass the param `
63
64
  Counting pages (3/5)
64
65
  Printing pages (5/5)
65
66
  Done
67
+
68
+ _WARNING_: This option change your html files
69
+
66
70
 
67
- [Imgur](http://i.imgur.com/SOq9nm7.png)
71
+ ![Imgur](http://i.imgur.com/SOq9nm7.png)
68
72
 
69
73
  Now it looks cleanner :D
70
74
 
75
+ Now the gem will change the css file by the passing css param.
76
+ The css is more prettier in order to cusmotize more like github:
77
+
78
+ $ rake doc:pdf clean=true css=true
79
+ Changing default css created, this could take a while.
80
+ Creating PDF documentation.
81
+
82
+ ![Imgur](http://i.imgur.com/bQGrVCa.png)
83
+
84
+ Help command
85
+
86
+ $ rake doc:pdf help
87
+ Usage: rake doc:pdf <options>
88
+ options:
89
+ --file=yourName: change default pdf output name
90
+ --clean=true,false: default is false, this delete "unnecessary" hmtl, like menu and search, please be careful, this option modify doc html files
91
+ --css=tue,false: default false, this change default css for a prettier one
92
+ --help, show this message
93
+
94
+
71
95
  The pdf file is saved in your application root
72
96
 
73
- ## Recomendations
74
97
 
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
98
+ ## PDF Layout
82
99
 
83
- How the css looks?
100
+ All the pages include the number of the page, the format is page/total i.e (12/100)
84
101
 
85
- [Imgur](http://i.imgur.com/bQGrVCa.png)
102
+ Table of content
103
+ ![Imgur](http://i.imgur.com/riQ0xqZ.png)
104
+
105
+ Class Documentation
106
+ ![Imgur](http://i.imgur.com/dwU3TBD.png)
107
+
108
+ ## Recomendations
109
+
110
+ * use annotate to comment your models and routes files, [please take a look](https://github.com/ctran/annotate_models)
86
111
 
87
112
  ## Tested with
88
113
 
89
114
 
90
115
  ##### OS
91
- Mac OS - Mountain Lion
92
- Ubuntu - 12.04
116
+ * Mac OS - Mountain Lion
117
+
118
+ * Ubuntu - 12.04
93
119
 
94
120
  #### Ruby env
95
- Ruby 1.9.3
96
- Rails 3.2.13
121
+ * Ruby 1.9.3 - 2.0
122
+
123
+ * Rails 3.2.13
97
124
 
98
125
  #### Binaries
99
- wkhtmltopdf 0.0.9
126
+ * wkhtmltopdf 0.0.9
100
127
 
128
+ ### Requirements GEMS
129
+ * Nokogiri 1.6
130
+ * Colorige
101
131
 
102
132
 
103
133
  ## Contributing
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "rake"
24
24
  spec.add_runtime_dependency "colorize"
25
25
  spec.add_runtime_dependency "nokogiri"
26
+ spec.add_runtime_dependency "httparty"
26
27
  end
@@ -1,3 +1,3 @@
1
1
  module DocToPdf
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,12 +1,20 @@
1
1
  require 'nokogiri'
2
2
  require 'colorize'
3
+ require 'httparty'
4
+
3
5
  desc "Turn rdoc files in a pdf document"
4
6
  namespace :doc do
5
7
  task :pdf do
6
8
  if validate_binary
7
- file_name = ENV['file'] || 'doc'
8
- clean = ENV["clean"] || "false"
9
- create(file_name, clean)
9
+ if ARGV.include?("help")
10
+ puts help
11
+ exit
12
+ else
13
+ file_name = ENV['file'] || 'doc'
14
+ clean = ENV["clean"] || "false"
15
+ css = ENV["css"] || "false"
16
+ create(file_name, clean, css)
17
+ end
10
18
  else
11
19
  puts "Error!\nPlease install wkhtmltopdf\nThis gem is tested in Mac and Linux".red
12
20
  end
@@ -16,23 +24,35 @@ end
16
24
 
17
25
  private
18
26
 
19
- def create(name, clean)
27
+ def create(name, clean, css)
20
28
  path = "#{Rails.root}/doc"
21
- files = get_files(path)
29
+ files = get_files(path, "html")
22
30
  if clean.eql? "true"
23
31
  puts "clean html, this could take a while.".green
24
32
  files.each {|file| clean_html(file)}
25
33
  end
34
+ if css.eql? "true"
35
+ pretty_css
36
+ end
26
37
  if files.empty?
27
38
  puts "Documentation not found in doc/ folder, please create it with rake doc:app or rdoc".orange
28
39
  else
29
- `wkhtmltopdf -t --footer-center [page]/[topage] -O Landscape #{files.join(" ")} #{name}.pdf`
40
+ puts "Creating PDF documentation.".green
41
+ `wkhtmltopdf -q -t --footer-center [page]/[topage] -O Landscape #{files.join(" ")} #{name}.pdf`
30
42
  end
31
43
 
32
44
  end
33
45
 
34
- def get_files(path)
35
- Dir["#{path}/**/*.htm*"]
46
+ def get_files(path, ext)
47
+ Dir["#{path}/**/*.#{ext}*"]
48
+ end
49
+
50
+ def pretty_css
51
+ puts "Changing default css created, this could take a while.".green
52
+ path = "#{Rails.root}/doc"
53
+ css = HTTParty.get("https://gist.github.com/rderoldan1/6396578/raw/rdoc.css").body
54
+ css_file = get_files(path, "css")
55
+ File.open(css_file.first, 'w'){|f| f.write(css)}
36
56
  end
37
57
 
38
58
  def validate_binary
@@ -52,3 +72,15 @@ def clean_html(path)
52
72
 
53
73
  File.open(path, "w"){|f| f.puts(doc)}
54
74
  end
75
+
76
+ def help
77
+ puts <<-EOF
78
+ Usage: rake doc:pdf <options>
79
+ options:
80
+ --file=yourName: change default pdf output name
81
+ --clean=true,false: default is false, this delete "unnecessary" hmtl, like menu and search, please be careful, this option modify doc html files
82
+ --css=tue,false: default false, this change default css for a prettier one
83
+ --help, show this message
84
+ EOF
85
+ end
86
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doc_to_pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruben Espinosa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-04 00:00:00.000000000 Z
11
+ date: 2013-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: httparty
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: Turn documentation stored in doc folder in your rails app in a pdf file
70
84
  using wkhtmltopdf
71
85
  email: