rake4latex 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/{lib/call_rake4latex.rb → call_rake4latex.rb} +21 -9
  2. data/lib/rake4latex.rb +113 -180
  3. data/lib/rake4latex/base.rb +205 -0
  4. data/lib/rake4latex/clean.rb +53 -0
  5. data/lib/rake4latex/latexdependencies.rb +2 -0
  6. data/lib/rake4latex/latexrunner.rb +31 -15
  7. data/lib/rake4latex/rake4latex.yaml +76 -0
  8. data/lib/rake4latex/rules.rb +90 -18
  9. data/lib/rake4latex/splitindex.rb +5 -2
  10. data/lib/rake4latex/template.rb +60 -0
  11. data/lib/rake4latex/tex_statistic.rb +8 -3
  12. data/lib/rake4latex_dvipdfm.rb +40 -0
  13. data/lib/rake4latex_lualatex.rb +22 -0
  14. data/lib/rake4latex_pdflatex.rb +22 -0
  15. data/lib/rake4latex_ps2pdf.rb +27 -0
  16. data/lib/rake4latex_xelatex.rb +22 -0
  17. data/license.txt +15 -0
  18. data/readme.html +70 -23
  19. data/readme.txt +58 -18
  20. data/readme_call_rake4latex.txt +25 -0
  21. data/test/_expected/bibtex_test.txt +10 -0
  22. data/test/_expected/bibtex_test_bib.txt +5 -0
  23. data/test/_expected/dvipdfm_test.txt +7 -0
  24. data/test/_expected/gloss_test.txt +16 -0
  25. data/test/_expected/gloss_test_bib.txt +8 -0
  26. data/test/_expected/includes_test.txt +8 -0
  27. data/test/_expected/index_test.txt +7 -0
  28. data/test/_expected/longtable_test.txt +6 -0
  29. data/test/_expected/minitoc_test.txt +8 -0
  30. data/test/_expected/ps2pdf_test.txt +8 -0
  31. data/test/_expected/rail_test.txt +7 -0
  32. data/test/_expected/rail_test_error.txt +10 -0
  33. data/test/_expected/splitindex_test.txt +8 -0
  34. data/test/_expected/supertabular_test.txt +6 -0
  35. data/test/_expected/supertabular_test_statistic.txt +30 -0
  36. data/test/_expected/z_complex_test.txt +12 -0
  37. data/test/_test_call/test_call.rb +14 -0
  38. data/test/_test_call/testdocument.tex +18 -0
  39. data/test/bibtex/rakefile.rb +11 -5
  40. data/test/bibtex/testdocument.bib +1 -0
  41. data/test/dvipdfm/rakefile.rb +43 -0
  42. data/test/dvipdfm/testdocument.tex +10 -0
  43. data/test/gloss/rakefile.rb +65 -0
  44. data/test/gloss/test_gloss.bib +4 -0
  45. data/test/gloss/testdocument.tex +31 -0
  46. data/test/includes/rakefile.rb +4 -4
  47. data/test/index/rakefile.rb +1 -1
  48. data/test/longtable/rakefile.rb +1 -1
  49. data/test/ps2pdf/rakefile.rb +43 -0
  50. data/test/ps2pdf/testdocument.tex +10 -0
  51. data/test/rail/rakefile.rb +10 -19
  52. data/test/rail/testrail.tex +2 -6
  53. data/test/rail/testrail_error.tex +58 -0
  54. data/test/supertabular/rakefile.rb +1 -1
  55. data/test/unittest_rake4latex.rb +66 -0
  56. data/test/z_complex/rakefile.rb +2 -2
  57. metadata +64 -6
@@ -0,0 +1,60 @@
1
+ #
2
+ #Little helper to build the initial rakefile
3
+ #
4
+
5
+
6
+ #
7
+ #Little helper to build the initial rakefile
8
+ #
9
+ module Rake4LaTeX
10
+ #
11
+ #Template for a basic rakefile
12
+ #
13
+ Template = <<Template
14
+ require 'rake4latex'
15
+
16
+ #Needed for some actions without a previous TeX-call
17
+ task :basefile => 'testdocument.tex'
18
+
19
+ file 'testdocument.pdf' => 'testdocument.tex' #prerequisite for a PDF-file
20
+ file 'testdocument.dvi' => 'testdocument.tex' #prerequisite for a DVI-file
21
+
22
+ #Force the compilation
23
+ task :touch => 'testdocument.tex'
24
+
25
+ #Define the default tasks
26
+ #~ task :default => :touch #Force the first TeX-call
27
+ task :default => 'testdocument.pdf' #build the pdf
28
+ #~ task :default => 'testdocument.dvi' #build the dvi
29
+ task :default => :statistic #Get an overview on errors and warnings
30
+ task :default => :clean #delete helpfiles
31
+
32
+ #Make the rakefile self-executable
33
+ if $0 == __FILE__
34
+ app = Rake.application
35
+ app[:default].invoke #start default tasks
36
+ end
37
+ Template
38
+
39
+ #~ rake4LaTeX.set_latexrunner_default(:maxruns, 1)
40
+ #~ rake4LaTeX.set_latexrunner_default(:loglevel, Log4r::DEBUG)
41
+ #~ rake4LaTeX.set_latexrunner_default(:texerrors_allowed, true)
42
+
43
+
44
+ =begin rdoc
45
+ Build atemplate for a rakefile.
46
+
47
+ =end
48
+ def self.template( basename = nil)
49
+ basename = basename.ext()
50
+ template = Template.dup
51
+ template.gsub!( /testdocument/, basename ) if basename
52
+ template
53
+ end #self.template( filename = nil)
54
+
55
+ end #Rake4LaTeX
56
+
57
+ if $0 == __FILE__
58
+ require 'rake'
59
+ puts Rake4LaTeX.template('testdokument.pdf')
60
+ end
@@ -2,9 +2,12 @@
2
2
  Build a quick overview on the logs for TeX-runs
3
3
  =end
4
4
 
5
-
6
- require 'knut_yaml' #fixme
7
-
5
+ begin
6
+ require 'knut_yaml' #fixme
7
+ rescue LoadError
8
+ require 'yaml'
9
+ end
10
+ module Rake4LaTeX
8
11
  class TeX_Statistic
9
12
  #Define the main file for the log-analyse.
10
13
  def initialize( filename )
@@ -273,6 +276,8 @@ class TeX_Statistic
273
276
  stat
274
277
  end
275
278
  end #TeX_Statistic
279
+ end #Rake4LaTeX
280
+
276
281
 
277
282
  if $0 == __FILE__
278
283
  require 'rake'
@@ -0,0 +1,40 @@
1
+ =begin rdoc
2
+ Special variant for rake4latex with ps2pdf
3
+ =end
4
+
5
+ #
6
+ #Load the base functions and load subfiles.
7
+ #
8
+ require 'rake4latex/base'
9
+
10
+ #
11
+ #Define the pdf-creation via pdflatex
12
+ #
13
+
14
+ #~ desc "Build a pdf-file with pdfLaTeX"
15
+ #~ rule '.pdf' => '.tex' do |t|
16
+ #~ runner = LaTeXRunner.new(
17
+ #~ :main_file => t.source,
18
+ #~ :program => :pdflatex,
19
+ #~ :dummy => nil
20
+ #~ )
21
+ #~ runner.execute #Does all the work and calls the "post-prerequisites"
22
+ #~ end
23
+
24
+ desc "Build a pdf-file via dvipdfm."
25
+ rule '.pdf' => '.dvi' do |t|
26
+ Rake4LaTeX::Logger.info("Call dvipdfm for <#{t.source}>")
27
+ cmd = Rake4LaTeX.build_cmd( 'dvipdfm', :filename => t.source )
28
+
29
+ stdout, stderr = catch_screen_output{
30
+ sh cmd
31
+ #stdout -> empty
32
+ #stderr -> "ps2pdf testdocument.ps"
33
+ puts stdout
34
+ puts '==========='
35
+ puts stderr
36
+ }
37
+ if $? != 0
38
+ Rake4LaTeX::Logger.fatal("There where dvipdfm errors. \n#{stdout}")
39
+ end
40
+ end
@@ -0,0 +1,22 @@
1
+ =begin rdoc
2
+ Special variant for rake4latex with lualatex.
3
+ =end
4
+
5
+ #
6
+ #Load the base functions and load subfiles.
7
+ #
8
+ require 'rake4latex/base'
9
+
10
+ #
11
+ #Define the pdf-creation via lualatex
12
+ #
13
+
14
+ desc "Build a pdf-file with luaLaTeX"
15
+ rule '.pdf' => '.tex' do |t|
16
+ runner = Rake4LaTeX::LaTeXRunner.new(
17
+ :main_file => t.source,
18
+ :program => :lualatex,
19
+ :dummy => nil
20
+ )
21
+ runner.execute #Does all the work and calls the "post-prerequisites"
22
+ end
@@ -0,0 +1,22 @@
1
+ =begin rdoc
2
+ Special variant for rake4latex with pdflatex.
3
+ =end
4
+
5
+ #
6
+ #Load the base functions and load subfiles.
7
+ #
8
+ require 'rake4latex/base'
9
+
10
+ #
11
+ #Define the pdf-creation via pdflatex
12
+ #
13
+
14
+ desc "Build a pdf-file with pdfLaTeX"
15
+ rule '.pdf' => '.tex' do |t|
16
+ runner = Rake4LaTeX::LaTeXRunner.new(
17
+ :main_file => t.source,
18
+ :program => :pdflatex,
19
+ :dummy => nil
20
+ )
21
+ runner.execute #Does all the work and calls the "post-prerequisites"
22
+ end
@@ -0,0 +1,27 @@
1
+ =begin rdoc
2
+ Special variant for rake4latex with ps2pdf
3
+ =end
4
+
5
+ #
6
+ #Load the base functions and load subfiles.
7
+ #
8
+ require 'rake4latex/base'
9
+
10
+ #
11
+ #Define the pdf-creation via dvips ps2dvi
12
+ #
13
+ desc "Build a pdf-file via ps2dvi"
14
+ rule '.pdf' => '.ps' do |t|
15
+ Rake4LaTeX::Logger.info("Call ps2pdf for <#{t.source}>")
16
+ cmd = Rake4LaTeX.build_cmd( 'ps2pdf', :filename => t.source )
17
+
18
+ stdout, stderr = catch_screen_output{
19
+ sh cmd
20
+ #stdout -> empty
21
+ #stderr -> "ps2pdf testdocument.ps"
22
+ }
23
+ if $? != 0
24
+ Rake4LaTeX::Logger.fatal("There where ps2pdf errors. \n#{stdout}")
25
+ end
26
+ end
27
+
@@ -0,0 +1,22 @@
1
+ =begin rdoc
2
+ Special variant for rake4latex with xelatex.
3
+ =end
4
+
5
+ #
6
+ #Load the base functions and load subfiles.
7
+ #
8
+ require 'rake4latex/base'
9
+
10
+ #
11
+ #Define the pdf-creation via xelatex
12
+ #
13
+
14
+ desc "Build a pdf-file with xeLaTeX"
15
+ rule '.pdf' => '.tex' do |t|
16
+ runner = Rake4LaTeX::LaTeXRunner.new(
17
+ :main_file => t.source,
18
+ :program => :xelatex,
19
+ :dummy => nil
20
+ )
21
+ runner.execute #Does all the work and calls the "post-prerequisites"
22
+ end
@@ -0,0 +1,15 @@
1
+ %% rake4latex
2
+ %% Copyright 2010 Knut Lickert
3
+ %
4
+ % This work may be distributed and/or modified under the
5
+ % conditions of the LaTeX Project Public License, either version 1.3
6
+ % of this license or (at your option) any later version.
7
+ % The latest version of this license is in
8
+ % http://www.latex-project.org/lppl.txt
9
+ % and version 1.3 or later is part of all distributions of LaTeX
10
+ % version 2005/12/01 or later.
11
+ %
12
+ % This work has the LPPL maintenance status `maintained'.
13
+ %
14
+ % The Current Maintainer of this work is Knut Lickert.
15
+ %
@@ -4,15 +4,14 @@
4
4
  Dir: C:/usr/Script/rake4latex
5
5
  Creator: rakefile_rake4latex.rb
6
6
  Target: readme.html
7
- 2010/01/03 21:19:00
7
+ 2010/01/08 19:25:32
8
8
 
9
9
  Generation-Info-End
10
10
  -->
11
11
  <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
12
12
  <html>
13
13
  <head ></head>
14
- <body ><h1 >rake4latex: TeX-Build-Tool</h1>
15
- <h2 >Introduction</h2>
14
+ <body ><h1 >rake4latex: TeX-Build-Tool 0.1.0==Introduction</h1>
16
15
  <p >
17
16
  This file contains definitions to build a rakefile for LaTeX-documents.
18
17
  </p>
@@ -42,13 +41,52 @@ A not-so minimal rakefile looks like this:
42
41
  end
43
42
  </pre>
44
43
  <p >
45
- You can generate this template with:
44
+ You can generate a rakefile template with: require 'rake4latex' puts Rake4LaTeX.template( [basename] )
45
+ </p>
46
+ <h3 >call_rake4latex.rb</h3>
47
+ <p >
48
+ When you think, your project is too small to create a rakefile, then try call_rake4latex.rb.
49
+ </p>
50
+ <p >
51
+ call_rake4latex.rb is a small programm where you can control rake4latex from your shell.
52
+ </p>
53
+ <p >
54
+ Example:
55
+ </p>
56
+ <pre>
57
+ call_rake4latex.rb my_file
58
+ call_rake4latex.rb -e my_file
59
+ </pre>
60
+ <h3 >rake4latex as lib in your application</h3>
61
+ <p >
62
+ You can use rake4latex as a lib inside your application.
63
+ </p>
64
+ <p >
65
+ Example:
46
66
  </p>
47
67
  <pre>
48
68
  require 'rake4latex'
49
- puts Rake4LaTeX.template( [basename] )
69
+ task :touch =&gt; 'testdocument.tex'
70
+ task :runtex =&gt; [:touch, 'testdocument.pdf', :clean]
71
+ Rake.application[:runtex].invoke
72
+ #~ task :basefile =&gt; 'testdocument.pdf'
73
+ #~ Rake.application[:clean].invoke
50
74
  </pre>
51
- <h2 >Multiple runs</h2>
75
+ <h2 >Document creation</h2>
76
+ <p >
77
+ rake4latex defines the tasks and rules to build documents with LaTeX.
78
+ </p>
79
+ <p >
80
+ pdf can be created in different ways. rake4latex uses pdflatex, but there are other rake-profile to create your pdf in different ways:
81
+ </p>
82
+ <ul >
83
+ <li > rake4latex_dvipdfm.rb </li>
84
+ <li > rake4latex_lualatex.rb </li>
85
+ <li > rake4latex_pdflatex.rb </li>
86
+ <li > rake4latex_ps2pdf.rb </li>
87
+ <li > rake4latex_xelatex.rb </li>
88
+ </ul>
89
+ <h3 >Multiple runs</h3>
52
90
  <p >
53
91
  One of the problems with writing a Makefile for LaTeX is that often latex
54
92
  needs to be run more than once on the same file, before obtaining the final
@@ -144,14 +182,6 @@ The rake process to generate the document is independent of any package. But so
144
182
  <li > supertabular </li>
145
183
  <li > splitindex (splitindex is replaced by internal routines) </li>
146
184
  </ul>
147
- <p >
148
- Untested packages:
149
- </p>
150
- <ul >
151
- <li > glossary </li>
152
- <li > multiind/index (not planned to check, please use splitindex or inform me
153
- about your need) </li>
154
- </ul>
155
185
  <h2 >Adding new tasks</h2>
156
186
  <h3 >Normal tasks</h3>
157
187
  <p >
@@ -208,29 +238,46 @@ See also section 'Multiple runs'
208
238
  </p>
209
239
  <h2 >Known Bugs and Problems</h2>
210
240
  <ul >
211
- <li >Only pdflatex/xelatex/lualatex/latex to create the target, no ps-files, no ps2pdf. <ul >
212
- <li >Intended for the next release </li>
241
+ <li > Two runs for new documents, when only one is needed. </li>
213
242
  </ul>
214
- </li>
215
- <li > Two runs for new documents, when only one is needed.<br />
216
- After the first run, the aux-file is created, so rake4latex detect a reason to rerun. Solution would be to make a log-file analyse. <ul >
243
+ <p >
244
+ After the first run, the aux-file is created, so rake4latex detect a reason to rerun. Solution would be to make a log-file analyse.
245
+ </p>
246
+ <ul >
217
247
  <li > No plan to solve it. Not a big problem, and why you need a rakefile for such simple
218
248
  tex-files? </li>
219
249
  </ul>
220
- </li>
221
- <li > No usage of kpsewhich<br />
222
- LaTeXDependencies#get_dependecies checks dependecies only relative to the file location. kpsewhich is not used. <ul >
250
+ <ul >
251
+ <li > No usage of kpsewhich. LaTeXDependencies#get_dependecies checks dependecies only relative to the file location. kpsewhich is not used. <ul >
223
252
  <li > Would be nice escpecially for BibTeX and scan for \bibliography{xxx} </li>
224
253
  <li > Low priority </li>
225
254
  </ul>
226
255
  </li>
227
256
  </ul>
257
+ <h3 >Packages with problems</h3>
258
+ <p >
259
+ There are additional packages requiring additonal runs.
260
+ </p>
261
+ <ul >
262
+ <li > glossaries (glossary based on makeindex) - support not planned. </li>
263
+ <li > multiind/index (multiple index) - support not planned. Please use splitindex or inform me about your need. </li>
264
+ </ul>
228
265
  <h2 >Version History</h2>
229
266
  <p >
230
267
  0.0.1 2010-01-03
231
268
  </p>
232
269
  <ul >
233
- <li > First release </li>
270
+ <li > First release published at gemcutter <a href = "http://gemcutter.org/gems/rake4latex" >http://gemcutter.org/gems/rake4latex</a> </li>
271
+ </ul>
272
+ <p >
273
+ 0.0.2 2010-01-04
274
+ </p>
275
+ <ul >
276
+ <li > rubyforge project rake4latex: <a href = "http://rubyforge.org/projects/rake4latex/" >http://rubyforge.org/projects/rake4latex/</a> </li>
277
+ <li > Add support dvips + ps2pdf (and dvipdfm, xelatex, lualatex) </li>
278
+ <li > Configurable programm settings (rake4latex.yaml) </li>
279
+ <li > Define a caller call_rake4latex </li>
280
+ <li > Support of gloss.sty </li>
234
281
  </ul>
235
282
  </body>
236
283
  </html>
data/readme.txt CHANGED
@@ -1,11 +1,8 @@
1
1
 
2
2
 
3
- rake4latex: TeX-Build-Tool
3
+ rake4latex: TeX-Build-Tool 0.1.0==Introduction
4
4
  ------------------------------
5
5
 
6
- Introduction
7
- ------------------------------
8
-
9
6
  This file contains definitions to build a rakefile for LaTeX-documents.
10
7
 
11
8
  A not-so minimal rakefile looks like this:
@@ -30,13 +27,47 @@ A not-so minimal rakefile looks like this:
30
27
  app[:default].invoke
31
28
  end
32
29
 
33
- You can generate this template with:
30
+ You can generate a rakefile template with: require 'rake4latex' puts Rake4LaTeX.template( [basename] )
31
+
32
+ call_rake4latex.rb
33
+ ------------------------------
34
+
35
+ When you think, your project is too small to create a rakefile, then try call_rake4latex.rb.
36
+
37
+ call_rake4latex.rb is a small programm where you can control rake4latex from your shell.
38
+
39
+ Example:
40
+ call_rake4latex.rb my_file
41
+ call_rake4latex.rb -e my_file
42
+
43
+ rake4latex as lib in your application
44
+ ------------------------------
45
+
46
+ You can use rake4latex as a lib inside your application.
47
+
48
+ Example:
34
49
  require 'rake4latex'
35
- puts Rake4LaTeX.template( [basename] )
50
+ task :touch => 'testdocument.tex'
51
+ task :runtex => [:touch, 'testdocument.pdf', :clean]
52
+ Rake.application[:runtex].invoke
53
+ #~ task :basefile => 'testdocument.pdf'
54
+ #~ Rake.application[:clean].invoke
36
55
 
37
- Multiple runs
56
+ Document creation
38
57
  ------------------------------
39
58
 
59
+ rake4latex defines the tasks and rules to build documents with LaTeX.
60
+
61
+ pdf can be created in different ways. rake4latex uses pdflatex, but there are other rake-profile to create your pdf in different ways:
62
+ - rake4latex_dvipdfm.rb
63
+ - rake4latex_lualatex.rb
64
+ - rake4latex_pdflatex.rb
65
+ - rake4latex_ps2pdf.rb
66
+ - rake4latex_xelatex.rb
67
+
68
+ Multiple runs
69
+ ------------------------------
70
+
40
71
  One of the problems with writing a Makefile for LaTeX is that often latex
41
72
  needs to be run more than once on the same file, before obtaining the final
42
73
  output. Moreover, every LaTeX package may require other runs basing on different
@@ -114,11 +145,6 @@ The rake process to generate the document is independent of any package. But so
114
145
  - supertabular
115
146
  - splitindex (splitindex is replaced by internal routines)
116
147
 
117
- Untested packages:
118
- - glossary
119
- - multiind/index (not planned to check, please use splitindex or inform me
120
- about your need)
121
-
122
148
  Adding new tasks
123
149
  ------------------------------
124
150
 
@@ -170,17 +196,31 @@ See also section 'Multiple runs'
170
196
  Known Bugs and Problems
171
197
  ------------------------------
172
198
 
173
- - Only pdflatex/xelatex/lualatex/latex to create the target, no ps-files, no ps2pdf. - Intended for the next release
174
- - Two runs for new documents, when only one is needed.
175
- After the first run, the aux-file is created, so rake4latex detect a reason to rerun. Solution would be to make a log-file analyse. - No plan to solve it. Not a big problem, and why you need a rakefile for such simple
199
+ - Two runs for new documents, when only one is needed.
200
+
201
+ After the first run, the aux-file is created, so rake4latex detect a reason to rerun. Solution would be to make a log-file analyse.
202
+ - No plan to solve it. Not a big problem, and why you need a rakefile for such simple
176
203
  tex-files?
177
- - No usage of kpsewhich
178
- LaTeXDependencies#get_dependecies checks dependecies only relative to the file location. kpsewhich is not used. - Would be nice escpecially for BibTeX and scan for \bibliography{xxx}
204
+ - No usage of kpsewhich. LaTeXDependencies#get_dependecies checks dependecies only relative to the file location. kpsewhich is not used. - Would be nice escpecially for BibTeX and scan for \bibliography{xxx}
179
205
  - Low priority
180
206
 
207
+ Packages with problems
208
+ ------------------------------
209
+
210
+ There are additional packages requiring additonal runs.
211
+ - glossaries (glossary based on makeindex) - support not planned.
212
+ - multiind/index (multiple index) - support not planned. Please use splitindex or inform me about your need.
213
+
181
214
  Version History
182
215
  ------------------------------
183
216
 
184
217
  0.0.1 2010-01-03
185
- - First release
218
+ - First release published at gemcutter http://gemcutter.org/gems/rake4latex (http://gemcutter.org/gems/rake4latex)
219
+
220
+ 0.0.2 2010-01-04
221
+ - rubyforge project rake4latex: http://rubyforge.org/projects/rake4latex/ (http://rubyforge.org/projects/rake4latex/)
222
+ - Add support dvips + ps2pdf (and dvipdfm, xelatex, lualatex)
223
+ - Configurable programm settings (rake4latex.yaml)
224
+ - Define a caller call_rake4latex
225
+ - Support of gloss.sty
186
226