dokkit 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/CONTRIBUTORS +0 -0
  2. data/DONE +0 -0
  3. data/LICENSE +20 -0
  4. data/README +0 -0
  5. data/Rakefile +62 -0
  6. data/TODO +0 -0
  7. data/bin/dokkit +53 -0
  8. data/lib/dokkit/app.rb +305 -0
  9. data/lib/dokkit/builtin.rake +55 -0
  10. data/lib/dokkit/deplate/fmt/html-notemplate.rb +21 -0
  11. data/lib/dokkit/deplate/fmt/latex-notemplate.rb +22 -0
  12. data/lib/dokkit/dokkittasks.rb +69 -0
  13. data/lib/dokkit/filters/deplate.rb +37 -0
  14. data/lib/dokkit/filters.rb +26 -0
  15. data/lib/dokkit/page.rb +54 -0
  16. data/lib/dokkit/projects/invoice/README +49 -0
  17. data/lib/dokkit/projects/invoice/Rakefile +100 -0
  18. data/lib/dokkit/projects/invoice/doc/config/company.yaml +12 -0
  19. data/lib/dokkit/projects/invoice/doc/config/customer.yaml +4 -0
  20. data/lib/dokkit/projects/invoice/doc/layouts/invoice.dpltex +90 -0
  21. data/lib/dokkit/projects/invoice/doc/pages/COMMON.rb +12 -0
  22. data/lib/dokkit/projects/invoice/doc/pages/invoice.rb +5 -0
  23. data/lib/dokkit/projects/invoice/doc/pages/invoice.yamltex +16 -0
  24. data/lib/dokkit/projects/invoice/doc/res/tex/deplate.sty +46 -0
  25. data/lib/dokkit/projects/invoice/doc/res/tex/images/logo.eps +209 -0
  26. data/lib/dokkit/projects/invoice/doc/res/tex/include/deplate.sty +46 -0
  27. data/lib/dokkit/projects/invoice/doc/res/tex/include/layout.inc +24 -0
  28. data/lib/dokkit/projects/invoice/doc/res/tex/include/macro.inc +67 -0
  29. data/lib/dokkit/projects/invoice/doc/res/tex/include/packages.inc +51 -0
  30. data/lib/dokkit/projects/invoice/lib/invoice.rb +104 -0
  31. data/lib/dokkit/projects/tech_report/README +49 -0
  32. data/lib/dokkit/projects/tech_report/Rakefile +102 -0
  33. data/lib/dokkit/projects/tech_report/doc/config/company.yaml +13 -0
  34. data/lib/dokkit/projects/tech_report/doc/config/tech_report.yaml +3 -0
  35. data/lib/dokkit/projects/tech_report/doc/layouts/report.dpltex +40 -0
  36. data/lib/dokkit/projects/tech_report/doc/pages/COMMON.rb +12 -0
  37. data/lib/dokkit/projects/tech_report/doc/pages/report.dpltex +37 -0
  38. data/lib/dokkit/projects/tech_report/doc/pages/report.inc +2 -0
  39. data/lib/dokkit/projects/tech_report/doc/pages/report.rb +3 -0
  40. data/lib/dokkit/projects/tech_report/doc/res/attachments/attachment_1 +0 -0
  41. data/lib/dokkit/projects/tech_report/doc/res/attachments/attachment_2 +0 -0
  42. data/lib/dokkit/projects/tech_report/doc/res/tex/images/logo.eps +311 -0
  43. data/lib/dokkit/projects/tech_report/doc/res/tex/include/deplate.sty +46 -0
  44. data/lib/dokkit/projects/tech_report/doc/res/tex/include/layout.inc +24 -0
  45. data/lib/dokkit/projects/tech_report/doc/res/tex/include/macro.inc +67 -0
  46. data/lib/dokkit/projects/tech_report/doc/res/tex/include/packages.inc +48 -0
  47. data/lib/dokkit/projects/tech_report/doc/res/tex/report.bib +4 -0
  48. data/lib/dokkit/projects/tech_report/lib/tech_report.rb +17 -0
  49. data/lib/dokkit/projects/website/README +49 -0
  50. data/lib/dokkit/projects/website/Rakefile +81 -0
  51. data/lib/dokkit/projects/website/doc/layouts/normal.thtml +38 -0
  52. data/lib/dokkit/projects/website/doc/pages/COMMON.rb +9 -0
  53. data/lib/dokkit/projects/website/doc/pages/deplate.dplhtml +9 -0
  54. data/lib/dokkit/projects/website/doc/pages/index.rb +10 -0
  55. data/lib/dokkit/projects/website/doc/pages/index.thtml +12 -0
  56. data/lib/dokkit/projects/website/doc/res/images/rote-tiny.png +0 -0
  57. data/lib/dokkit/projects/website/html/deplate.html +21 -0
  58. data/lib/dokkit/projects/website/html/images/rote-tiny.png +0 -0
  59. data/lib/dokkit/projects/website/html/index.html +37 -0
  60. data/lib/dokkit.rb +71 -0
  61. data/tests/gem_tests.rb +4 -0
  62. data/tests/test_filters.rb +46 -0
  63. metadata +177 -0
@@ -0,0 +1,67 @@
1
+ % macro.inc
2
+ % ----------
3
+ %
4
+ % Copyright (C)2005 Alca Coop. a r. l.
5
+ %
6
+ % This program is free software; you can redistribute it and/or modify
7
+ % it under the terms of the GNU General Public License as published by
8
+ % the Free Software Foundation; either version 2 of the License, or
9
+ % (at your option) any later version.
10
+ %
11
+ % This program is distributed in the hope that it will be useful,
12
+ % but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ % GNU General Public License for more details.
15
+ %
16
+ % You should have received a copy of the GNU General Public License
17
+ % along with this program; if not, write to the Free Software
18
+ % Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
+ %
20
+
21
+
22
+ % ENVIRONMENT
23
+ % -----------------------------------------------------------------------------
24
+
25
+ % checkboxize
26
+ % ------------
27
+ % Ambiente per creare elenchi con checkbox (ad esempio per i test di valutazione)
28
+ %
29
+ \newenvironment{checkboxize}{\renewcommand{\labelitemi}{\(\Box\)}\begin{itemize}}{\end{itemize}}
30
+
31
+
32
+ % COMANDI
33
+ % -----------------------------------------------------------------------------
34
+
35
+ % \firma[lunghezza]{firmatario}
36
+ % -------------------
37
+ % Argomenti:
38
+ % - lunghezza (opzionale, default 7cm)
39
+ % - firmatario: ci� che va scritto sopra la linea orizzontale
40
+ %
41
+ \newcommand{\firma}[2][7cm]{\begin{minipage}{#1}\begin{center}{#2}\\\vspace{1cm}\rule{\textwidth}{0.1mm}\end{center}\end{minipage}}
42
+
43
+ % \luogoedata[luogo]
44
+ % -------------------
45
+ % Argomenti:
46
+ % - luogo (opzionale, default linea orizz. di 4 cm)
47
+ %
48
+ \newcommand{\luogoedata}[1][\rule{4cm}{0.1mm}]{{#1}, l� \rule{0.6cm}{0.1mm}/\rule{0.6cm}{0.1mm}/200\rule{0.3cm}{0.1mm}}
49
+
50
+ % \textbox[lunghezza]{testo}
51
+ % --------------------
52
+ % Argomenti:
53
+ % - lunghezza (opzionale, default 7cm)
54
+ % - testo
55
+ %
56
+ \newcommand{\textbox}[2][7cm]{{#2}~\rule{#1}{0.1mm}}
57
+
58
+ % \oggetto{oggetto}
59
+ % ------------------
60
+ % Argomenti:
61
+ % - oggetto: l'oggetto...
62
+ %
63
+ \newcommand{\oggetto}[1]{\noindent\textbf{\underline{OGGETTO: {#1}.}}}
64
+
65
+ % ALTRO
66
+ % -----------------------------------------------------------------------------
67
+ \definecolor{gray50}{gray}{.5}
@@ -0,0 +1,51 @@
1
+ % Packages
2
+ % -----------------------------------------------------------------------------
3
+
4
+ % http://www.tug.org/tex-archive/info/italian/fancyhdr/itfancyhdr.pdf
5
+ %
6
+ \usepackage{fancyhdr}
7
+
8
+ % A nice font
9
+ %
10
+ \usepackage{palatino}
11
+
12
+ \usepackage{setspace}
13
+
14
+ % http://www.tug.org/teTeX/tetex-texmfdist/doc/latex/geometry/geometry.pdf
15
+ %
16
+ \usepackage{geometry}
17
+
18
+ % http://www.comp.leeds.ac.uk/andyr/misc/latex/latextutorial4.html
19
+ %
20
+ \usepackage{multirow}
21
+
22
+ % Symbols
23
+ %
24
+ \usepackage{latexsym}
25
+
26
+ \usepackage{lastpage}
27
+
28
+ % http://www.ctan.org/tex-archive/macros/latex/required/graphics/grfguide.ps
29
+ %
30
+ \usepackage{color}
31
+
32
+ \usepackage{longtable}
33
+
34
+ % http://www.linux.it/~salve/TeX-FAQ/TeX-FAQ-tex.html
35
+ %
36
+ \usepackage{graphicx}
37
+
38
+ % Euro symbol
39
+ %
40
+ \usepackage{eurosym}
41
+
42
+ \usepackage{array}
43
+
44
+ % compatibility packages for deplate
45
+ \usepackage{hyperref}
46
+ \usepackage[square,numbers,sort,super]{natbib}
47
+
48
+ \usepackage[italian]{babel}
49
+ \usepackage[latin1]{inputenc}
50
+
51
+ % -----------------------------------------------------------------------------
@@ -0,0 +1,104 @@
1
+ #--
2
+ # Invoice class for Dokkit
3
+ # (c)2006 Andrea Fazzi (and contributors)
4
+ #
5
+ # See 'dokkit.rb' or LICENSE for licence information.
6
+ #++
7
+
8
+ require 'rote'
9
+ require 'rote/format'
10
+ require 'dokkit/page'
11
+
12
+ module Rote
13
+
14
+ class Page
15
+
16
+ alias dokkitpage_initialize initialize
17
+
18
+ def initialize(template_name, pages_dir = '.', layout_dir = pages_dir, config_dir = pages_dir, &block)
19
+
20
+ invoice = YAML::load( File.open(template_name) )
21
+
22
+ @services = invoice['services']
23
+
24
+ @id = invoice['invoice']['id']
25
+ @vat = invoice['invoice']['vat']
26
+ @date = invoice['invoice']['date'] || today
27
+
28
+ @basic_price = 0
29
+ @total_price = 0
30
+ @vat_price = 0
31
+
32
+ dokkitpage_initialize(template_name, pages_dir, layout_dir, config_dir, &block)
33
+ calc_prices
34
+ end
35
+
36
+ def do_render!
37
+ # Render the page content into the @content_for_layout
38
+ unless @template_text.nil?
39
+ render_services_tex
40
+ end
41
+
42
+ # FIXME: Quick fix for incorrect COMMON.rb layout nesting.
43
+ # All we do here is reset the layout to be the last layout
44
+ # added.
45
+ #
46
+ # If it turns out that the ability to nest from COMMON/page
47
+ # really is useless, we should remove the layout queue entirely,
48
+ # and then just have the render layout loop run until
49
+ # layout at end == layout at start.
50
+ @layout_names = [@layout_names.last] unless layout_names.empty?
51
+
52
+ # Do layout _after_ page eval. As we go through this, the layouts
53
+ # we load may add to the end of the layout names array, so nested
54
+ # layout is supported by just chasing the end of the array until
55
+ # it's empty. The process is basically
56
+ #
57
+ # Page is loaded, calls 'layout' with it's layout.
58
+ # During render, that fn is taken, and loaded. Layout code
59
+ # again calls 'layout'.
60
+ # On next loop iteration, that new filename is loaded, and it's
61
+ # code is executed ... and so on.
62
+ #
63
+ # Each loop puts the result into @content_for_layout, so that
64
+ # nested layouts can work just the same as regular.
65
+ @layout_names.each do |fn|
66
+ txt = load_layout(fn)
67
+
68
+ @layout_text ||= txt # legacy support vv0.3.2 v-0.4
69
+
70
+ # render into the layout if supplied.
71
+ if txt
72
+ erb = ERB.new(txt)
73
+ erb.filename = fn
74
+ @content_for_layout = erb.result(binding)
75
+ end
76
+ end
77
+
78
+ @result = render_post_filters(@content_for_layout)
79
+ freeze
80
+
81
+ @result
82
+ end
83
+
84
+ private
85
+
86
+ def calc_prices
87
+ @services.each { |service| @basic_price += service['service']['quantity'] * service['service']['price'] }
88
+ @vat_price = @basic_price / 100 * @vat
89
+ @total_price = @basic_price + @vat_price
90
+ end
91
+
92
+ def today
93
+ "#{Date.today.day}.#{Date.today.month}.#{Date.today.year}"
94
+ end
95
+
96
+ def render_services_tex
97
+ @content_for_layout = ""
98
+ @services.each do |service|
99
+ @content_for_layout += "#{ render_page_filters(service['service']['description'].to_s)} & #{service['service']['quantity']} & #{service['service']['price']} & #{service['service']['price'] * service['service']['quantity']}\\\\ \\hline "
100
+ end
101
+ end
102
+
103
+ end
104
+ end
@@ -0,0 +1,49 @@
1
+ This is the auto-generated Rote documentation source.
2
+
3
+ To render it using Rote's command-line wrapper (ignoring the included
4
+ Rakefile), type:
5
+
6
+ rote doc
7
+
8
+ from the top-level directory (this one).
9
+
10
+ To render using the included Rakefile (the result is the same in either
11
+ case) type instead:
12
+
13
+ rake doc
14
+
15
+ If you prefer, you can omit the 'doc' task, since it is configured
16
+ as the default.
17
+
18
+ In either case, you should see some output as the pages are rendered
19
+ and resources copied, and get output in a (created) 'html' directory.
20
+ Once you have rendered the site, running the command again will appear
21
+ to do nothing, because only changed resources are re-rendered. To
22
+ start over:
23
+
24
+ (rote|rake) clobber
25
+
26
+ Alternatively, modify the page or resource files, and rerun the first
27
+ command to transform only the modified resource.
28
+
29
+ WHAT NEXT?
30
+
31
+ + See what else you can do by typing:
32
+
33
+ (rote|rake) --tasks
34
+
35
+ rote --usage ( with the command-line wrapper )
36
+
37
+ + Modify the included page template and layout to suit your needs.
38
+
39
+ + Edit the included Rakefile to add or change tasks, or delete it
40
+ if you're sticking with the command-line wrapper.
41
+
42
+ + Add more pages and layouts.
43
+
44
+ + Start Rote in monitor mode, and have your changes rendered as
45
+ you work:
46
+
47
+ (rote|rake) doc_monitor
48
+
49
+
@@ -0,0 +1,102 @@
1
+ # Standard Rakefile for dokkit documentation build
2
+ #
3
+ #
4
+ begin
5
+ require 'rubygems'
6
+ rescue LoadError
7
+ nil # optional
8
+ end
9
+
10
+ require 'rake'
11
+ require 'rake/clean'
12
+ require 'rote/format'
13
+ require 'dokkit'
14
+ require 'dokkit/filters'
15
+ require 'lib/tech_report'
16
+
17
+ include Rote
18
+ include Dokkit
19
+
20
+ CMD_LATEX = "latex -interaction=batchmode"
21
+ CMD_BIBTEX = "bibtex"
22
+
23
+ # Check if bibliography exists.
24
+
25
+ def bib_exists?
26
+ if Dir["*.bib"].empty?
27
+ false
28
+ else
29
+ true
30
+ end
31
+ end
32
+
33
+ # Create a set of tasks with the prefix 'doc' to build the
34
+ # documentation set. The directory layout is as for the
35
+ # command-line wrapper (but can be changed of course).
36
+ #
37
+ # This creates the following tasks:
38
+ #
39
+ # * doc - transform/copy all modified pages / resources
40
+ # * doc_pages - transform all modified pages
41
+ # * doc_res - copy all modified resources
42
+ # * doc_monitor - Start monitor mode, transform changed files automatically
43
+ #
44
+ # * [html/**/*] - Transform single page / resource unconditionally
45
+ #
46
+ # * clobber_doc - Remove output (hooks into main 'clobber' task)
47
+ #
48
+ # In addition to these tasks, you may also wish to define a 'doc_refresh' task
49
+ # to be run whenever modified resources are processed in monitor mode.
50
+
51
+ doc = Rote::DocTask.new(:doc) do |site|
52
+ site.output_dir = 'tex'
53
+ site.layout_dir = 'doc/layouts'
54
+ site.config_dir = 'doc/config'
55
+
56
+ site.pages.dir = 'doc/pages'
57
+ site.pages.include('**/*')
58
+ site.pages.exclude('**/*.yaml')
59
+
60
+ site.res.dir = 'doc/res/tex'
61
+ site.res.include('**/*')
62
+
63
+ site.ext_mapping(/dpltex/, 'tex') do |page|
64
+ page.page_filter Dokkit::Filters::Deplate.new('latex-notemplate') do |dpltex|
65
+ dpltex.options.pdftex = true
66
+ end
67
+ end
68
+
69
+ end
70
+
71
+ doc_dvi = Rote::DocTask.new(:doc_dvi) do |site|
72
+
73
+ site.output_dir = 'tex'
74
+ site.pages.dir = 'doc/pages'
75
+ end
76
+
77
+ task :doc_dvi => [:doc] do
78
+ pwd = Dir.getwd
79
+ Dir.chdir(doc_dvi.output_dir)
80
+ Dir["*.tex"].each { |file| 2.times { sh "#{CMD_LATEX} #{file}" } }
81
+
82
+ if bib_exists? then
83
+ Dir["*.aux"].each do |file|
84
+ if File.exists?(File.basename(file).sub(/.aux$/,".bib"))
85
+ sh "#{CMD_BIBTEX} #{file}"
86
+ 2.times { sh "#{CMD_LATEX} #{File.basename(file).sub(/.aux$/,".tex")}" }
87
+ end
88
+ end
89
+ end
90
+
91
+ Dir.chdir(pwd)
92
+ end
93
+
94
+ task :default => [:doc]
95
+
96
+ # import user-level tasks
97
+ #import "#{ENV['HOME']}/.rotetasks.rf" if File.exists?("#{ENV['HOME']}/.rotetasks.rf")
98
+ #import 'local.rf' if File.exists?('local.rf')
99
+
100
+ # TODO Define your custom tasks here
101
+
102
+
@@ -0,0 +1,13 @@
1
+ company:
2
+ name: MyCompany
3
+ address: Address
4
+ vat_number: 1234
5
+ telephone: (+39)666666
6
+ fax: (+39)777777
7
+ email: info@company.com
8
+ website: www.company.com
9
+ bank_name: MyBank
10
+ bank_current_account: 1234
11
+ bank_abi: 1234
12
+ bank_cab: 1234
13
+ bank_cin: X
@@ -0,0 +1,3 @@
1
+ title: Techinical Report
2
+ author: john Doe
3
+
@@ -0,0 +1,40 @@
1
+ \documentclass[a4paper,10pt]{article}
2
+
3
+ \input{include/packages.inc}
4
+
5
+ \usepackage{include/deplate}
6
+
7
+ \newcommand{\layout}[1][]{
8
+ \geometry{
9
+ left=2cm,
10
+ right=2cm,
11
+ top=2cm,
12
+ bottom=1.7cm,
13
+ headheight=1cm,
14
+ headsep=1cm,
15
+ footskip=1cm,
16
+ includeheadfoot}
17
+ \pagestyle{fancy}
18
+ \fancyhead{}
19
+ \fancyfoot{}
20
+ \lhead{\includegraphics[height=1cm]{images/logo.eps}}
21
+ \rhead{\fontfamily{cmss}\large\textbf{#1}\vspace*{\stretch{1}}\normalsize}
22
+ \lfoot{
23
+ \fontfamily{cmss}\scriptsize\textbf{<%= @config['company']['name'] %>} $\star$ \textbf{Address} <%= @config['company']['address'] %> $\star$ \textbf{Tel.} <%= @config['company']['telephone'] %>\\\textbf{Fax} <%= @config['company']['fax'] %> $\star$ \textbf{E-mail} <%= @config['company']['email'] %> $\star$ \textbf{Web} <%= @config['company']['website'] %> \normalsize
24
+ }
25
+ \rfoot{
26
+ \fontfamily{cmss}\textit{pag. \thepage\ / \pageref{LastPage}}
27
+ }
28
+ \renewcommand{\footrulewidth}{0.4pt}
29
+ }
30
+
31
+ \layout[<%= @config['title'] %>]
32
+
33
+ \sffamily
34
+ \parindent=0pt
35
+
36
+ \begin{document}
37
+
38
+ <%= @content_for_layout %>
39
+
40
+ \end{document}
@@ -0,0 +1,12 @@
1
+ # Shared code for all pages below this directory.
2
+ #
3
+ # This is executed for every file transformed, in the binding of
4
+ # the appropriate Rote::Page instance. Individual page sources
5
+ # ([pagename].rb) override anything defined here.
6
+ #
7
+ # Any COMMON.rb files found in directories above this will also
8
+ # be loaded.
9
+
10
+
11
+ # Apply the 'report' layout to all project's document
12
+ layout 'report.dpltex'
@@ -0,0 +1,37 @@
1
+ #INCLUDE: doc/pages/report.inc
2
+
3
+ #BIB: report.bib
4
+
5
+ #TITLE: <%= @config['title'] %>
6
+ #AUTHOR: <%= @config['author'] %>
7
+
8
+ #MAKETITLE
9
+ ----8<----
10
+
11
+ #LIST: toc
12
+ ----8<----
13
+
14
+ * Abstract
15
+ From a document of Jim{cite: author:jim}
16
+
17
+ * Introduction
18
+
19
+ * Main section
20
+
21
+ ** Subsection One
22
+ ** Subsection Two
23
+
24
+ * Conclusions
25
+
26
+ ----8<----
27
+
28
+ #MAKEBIB: ieeetr
29
+ ----8<----
30
+
31
+ * Appendices
32
+
33
+ ** Attachement One
34
+ #WITH file=doc/res/attachments/attachment_1: Verbatim
35
+
36
+ ** Attachement Two
37
+ #WITH file=doc/res/attachments/attachment_2: Verbatim
@@ -0,0 +1,2 @@
1
+ #VAR: _var_1=''var 1''
2
+ #VAR: _var_2=''var 2''
@@ -0,0 +1,3 @@
1
+ config 'tech_report.yaml'
2
+ config 'company.yaml'
3
+