dokkit 0.1.1 → 0.2.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/CHANGES +15 -1
- data/LICENSE +673 -19
- data/README +32 -0
- data/Rakefile +59 -25
- data/bin/dokkit +48 -38
- data/lib/dokkit/#render_task_factory.rb# +94 -0
- data/lib/dokkit/app.rb +212 -257
- data/lib/dokkit/deplate/fmt/latex-notemplate.rb +3 -1
- data/lib/dokkit/dokkittasks.rb +45 -15
- data/lib/dokkit/filters/deplate.rb +11 -5
- data/lib/dokkit/hash.rb +41 -0
- data/lib/dokkit/models/Rakefile.tpl +9 -0
- data/lib/dokkit/models/share/builtin.rf +28 -0
- data/lib/dokkit/page.rb +161 -20
- data/lib/dokkit/render_task_factory.rb +91 -0
- data/lib/dokkit.rb +35 -42
- data/tests/data/output/simple_document/README +57 -0
- data/tests/data/output/simple_document/Rakefile +7 -0
- data/tests/data/output/simple_document/doc/config/simple_document.yaml +5 -0
- data/tests/data/output/simple_document/doc/pages/simple_document.dpl +12 -0
- data/{lib/dokkit/projects/website → tests/data/output/website_project}/Rakefile +2 -1
- data/tests/data/projects/simple-document/README +57 -0
- data/tests/data/projects/simple-document/Rakefile +22 -0
- data/tests/data/projects/simple-document/doc/config/author.yaml +4 -0
- data/tests/data/projects/simple-document/doc/config/model.yaml +18 -0
- data/tests/data/projects/simple-document/doc/config/simple_document.yaml +6 -0
- data/tests/data/projects/simple-document/doc/layouts/another_simple_document.html +8 -0
- data/tests/data/projects/simple-document/doc/layouts/another_simple_document.tex +10 -0
- data/tests/data/projects/simple-document/doc/layouts/layout_with_custom_name.html +8 -0
- data/tests/data/projects/simple-document/doc/layouts/semantic.cache +23 -0
- data/tests/data/projects/simple-document/doc/pages/COMMON.yaml +23 -0
- data/tests/data/projects/simple-document/doc/pages/another_simple_document.dpl +12 -0
- data/tests/data/projects/simple-document/doc/pages/simple_document.dpl +12 -0
- data/tests/data/projects/simple-document/doc/pages/simple_document_without_layout.dpl +12 -0
- data/tests/data/projects/simple-document/doc/pages/subdir/COMMON.yaml +4 -0
- data/tests/data/projects/simple-document/doc/pages/subdir/simple_document_in_subdir.dpl +12 -0
- data/tests/data/projects/simple-document/doc/pages/subdir/simple_document_in_subdir.yaml +3 -0
- data/tests/data/projects/simple-document/doc/pages/subdir/subdir/COMMON.yaml +2 -0
- data/tests/data/projects/simple-document/doc/pages/subdir/subdir/another_simple_document_in_subdir.dpl +12 -0
- data/tests/data/projects/simple-document/doc/pages/yet_another_simple_document.dpl +12 -0
- data/tests/data/projects/simple-document/doc/pages/yet_another_simple_document.yaml +8 -0
- data/tests/spec_page.rb +25 -0
- data/tests/test.rb +2 -0
- data/tests/test_application.rb +40 -0
- data/tests/test_builtin_tasks.rb +37 -0
- data/tests/test_config.rb +108 -0
- data/tests/test_core.rb +12 -0
- data/tests/test_dokkit_commandline.rb +18 -0
- data/tests/test_exception.rb +7 -0
- data/tests/test_filters.rb +1 -1
- data/tests/test_layout.rb +64 -0
- data/tests/test_options.rb +33 -0
- data/tests/test_project_tasks.rb +48 -0
- data/tests/test_recursive_merge.rb +42 -0
- data/tests/test_task_factory.rb +38 -0
- metadata +138 -94
- data/Rakefile.old +0 -62
- data/lib/dokkit/builtin.rake +0 -55
- data/lib/dokkit/projects/invoice/Rakefile +0 -100
- data/lib/dokkit/projects/invoice/doc/config/company.yaml +0 -12
- data/lib/dokkit/projects/invoice/doc/config/customer.yaml +0 -4
- data/lib/dokkit/projects/invoice/doc/layouts/invoice.dpltex +0 -90
- data/lib/dokkit/projects/invoice/doc/pages/COMMON.rb +0 -12
- data/lib/dokkit/projects/invoice/doc/pages/invoice.rb +0 -5
- data/lib/dokkit/projects/invoice/doc/pages/invoice.yamltex +0 -16
- data/lib/dokkit/projects/invoice/doc/res/tex/deplate.sty +0 -46
- data/lib/dokkit/projects/invoice/doc/res/tex/images/logo.eps +0 -209
- data/lib/dokkit/projects/invoice/doc/res/tex/include/deplate.sty +0 -46
- data/lib/dokkit/projects/invoice/doc/res/tex/include/layout.inc +0 -24
- data/lib/dokkit/projects/invoice/doc/res/tex/include/macro.inc +0 -67
- data/lib/dokkit/projects/invoice/doc/res/tex/include/packages.inc +0 -51
- data/lib/dokkit/projects/invoice/lib/invoice.rb +0 -104
- data/lib/dokkit/projects/tech_report/README +0 -49
- data/lib/dokkit/projects/tech_report/Rakefile +0 -102
- data/lib/dokkit/projects/tech_report/doc/config/company.yaml +0 -13
- data/lib/dokkit/projects/tech_report/doc/config/tech_report.yaml +0 -3
- data/lib/dokkit/projects/tech_report/doc/layouts/report.dpltex +0 -40
- data/lib/dokkit/projects/tech_report/doc/pages/COMMON.rb +0 -12
- data/lib/dokkit/projects/tech_report/doc/pages/report.dpltex +0 -37
- data/lib/dokkit/projects/tech_report/doc/pages/report.inc +0 -2
- data/lib/dokkit/projects/tech_report/doc/pages/report.rb +0 -3
- data/lib/dokkit/projects/tech_report/doc/res/attachments/attachment_2 +0 -0
- data/lib/dokkit/projects/tech_report/doc/res/tex/images/logo.eps +0 -311
- data/lib/dokkit/projects/tech_report/doc/res/tex/include/deplate.sty +0 -46
- data/lib/dokkit/projects/tech_report/doc/res/tex/include/layout.inc +0 -24
- data/lib/dokkit/projects/tech_report/doc/res/tex/include/macro.inc +0 -67
- data/lib/dokkit/projects/tech_report/doc/res/tex/include/packages.inc +0 -48
- data/lib/dokkit/projects/tech_report/doc/res/tex/report.bib +0 -4
- data/lib/dokkit/projects/tech_report/lib/tech_report.rb +0 -17
- data/lib/dokkit/projects/website/README +0 -49
- /data/{lib/dokkit/projects/invoice → tests/data/output/website_project}/README +0 -0
- /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/layouts/normal.thtml +0 -0
- /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/pages/COMMON.rb +0 -0
- /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/pages/deplate.dplhtml +0 -0
- /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/pages/index.rb +0 -0
- /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/pages/index.thtml +0 -0
- /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/res/images/rote-tiny.png +0 -0
- /data/{lib/dokkit/projects/tech_report/doc/res/attachments/attachment_1 → tests/pages/test.dpltex} +0 -0
data/lib/dokkit/hash.rb
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#
|
|
2
|
+
# File 'hash.rb' created on 09 ott 2007 at 15:59:11.
|
|
3
|
+
#
|
|
4
|
+
# See 'dokkit.rb' or LICENSE for licence information.
|
|
5
|
+
#
|
|
6
|
+
# (c)2006, 2007 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
class Hash
|
|
10
|
+
# Set the default values for keyword arguments.
|
|
11
|
+
# See http://www.lukeredpath.co.uk/2006/7/27/using-ruby-hashes-as-keyword-arguments-with-easy-defaults
|
|
12
|
+
# for a complete discussion.
|
|
13
|
+
def with_defaults!(defaults)
|
|
14
|
+
self.merge!(defaults) { |key, old, new| old.nil? ? new : old }
|
|
15
|
+
end
|
|
16
|
+
# Non-desctructive version of Hash#with_defaults method.
|
|
17
|
+
def with_defaults(defaults)
|
|
18
|
+
self.merge(defaults) { |key, old, new| old.nil? ? new : old }
|
|
19
|
+
end
|
|
20
|
+
# Hash#recursive_merge merges two arbitrarily deep hashes into a single hash.
|
|
21
|
+
# The hash is followed recursively, so that deeply nested hashes that are at
|
|
22
|
+
# the same level will be merged when the parent hashes are merged.
|
|
23
|
+
def recursive_merge!(other_hash)
|
|
24
|
+
merge!(other_hash) do |key, value, other_value|
|
|
25
|
+
if(value.class == Hash && other_value.class == Hash)
|
|
26
|
+
value.recursive_merge other_value
|
|
27
|
+
elsif(value.class == Array && other_value.class == Array)
|
|
28
|
+
value.concat(other_value)
|
|
29
|
+
else
|
|
30
|
+
store(key, other_value)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
# Non-destructive version of Hash#recursive_merge method.
|
|
35
|
+
def recursive_merge(other_hash)
|
|
36
|
+
dup.recursive_merge!(other_hash)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'dokkit'
|
|
3
|
+
require 'dokkit/app'
|
|
4
|
+
|
|
5
|
+
EXCLUDE_FL = /TEMPLATE/
|
|
6
|
+
|
|
7
|
+
desc "Bootstrap a new documentation project based on #{ENV['PROJECT']} model."
|
|
8
|
+
task :create do
|
|
9
|
+
rule '' do |t|
|
|
10
|
+
base_path = File.join(Dokkit.fetch_models[ENV['PROJECT']], 'lib/model')
|
|
11
|
+
file_to_copy = FileList.new(["#{base_path}/doc/**/*", "#{base_path}/[A-Z]*"]) do |fl|
|
|
12
|
+
fl.exclude(EXCLUDE_FL).to_a
|
|
13
|
+
end
|
|
14
|
+
copy_model_files base_path, file_to_copy, t.name
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def copy_model_files(base_path, source_fl, dest_dir)
|
|
19
|
+
puts "Creating model structure on directory '#{dest_dir}'"
|
|
20
|
+
source_fl.each do |complete_fn|
|
|
21
|
+
next if File.directory?(complete_fn)
|
|
22
|
+
complete_fn.scan(/#{base_path}\/(.*)/) do |file_to_copy|
|
|
23
|
+
dirname = File.join(dest_dir, File.dirname(file_to_copy.to_s))
|
|
24
|
+
mkdir_p(dirname, :verbose => false) unless File.exists?(dirname)
|
|
25
|
+
cp complete_fn, dirname, :verbose => true
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
data/lib/dokkit/page.rb
CHANGED
|
@@ -1,38 +1,107 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
1
|
+
#
|
|
2
|
+
# File 'page.rb' created on 09 ott 2007 at 15:56:08.
|
|
3
3
|
#
|
|
4
|
-
# See 'dokkit.rb' or LICENSE for licence information.
|
|
4
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
|
5
|
+
#
|
|
6
|
+
# (C) 2006, 2007 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
|
7
|
+
#
|
|
5
8
|
|
|
6
9
|
require 'yaml'
|
|
10
|
+
require 'dokkit/hash'
|
|
11
|
+
|
|
12
|
+
class Module
|
|
13
|
+
def track_methods
|
|
14
|
+
@methods_in_order = []
|
|
15
|
+
class << self
|
|
16
|
+
attr_reader :methods_in_order
|
|
17
|
+
def method_added( method_name )
|
|
18
|
+
@methods_in_order << method_name.id2name
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
7
23
|
|
|
8
24
|
module DokkitPage
|
|
9
25
|
|
|
10
26
|
# The base path for config resolution
|
|
11
27
|
attr_reader :config_path
|
|
12
28
|
|
|
13
|
-
def
|
|
14
|
-
|
|
29
|
+
def init(config_page, &blk)
|
|
30
|
+
self.class.methods_in_order.each do |init_meth|
|
|
31
|
+
self.send(init_meth, config_page, &blk) if init_meth =~ /init\_/
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def load_model_config
|
|
36
|
+
load_config('model.yaml')
|
|
15
37
|
end
|
|
38
|
+
|
|
39
|
+
def config(basename)
|
|
40
|
+
basename.each { |fn| @config_files.push "#{fn}#{@config_defext if File.extname(fn).empty?}" } if basename
|
|
41
|
+
end
|
|
16
42
|
|
|
17
43
|
def load_configs
|
|
18
|
-
@config_files.each
|
|
19
|
-
load_config(fn)
|
|
20
|
-
end
|
|
44
|
+
@config_files.each { |fn| load_config(fn) }
|
|
21
45
|
@config
|
|
22
46
|
end
|
|
23
47
|
|
|
24
48
|
def load_config(fn)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
Rake.register_dependency(
|
|
28
|
-
@config.
|
|
49
|
+
complete_fn = config_fn(fn)
|
|
50
|
+
if File.exists?(complete_fn)
|
|
51
|
+
Rake.register_dependency(complete_fn)
|
|
52
|
+
result = @config.recursive_merge!( YAML::load( File.open(complete_fn) ) )
|
|
53
|
+
if result.has_key?('document')
|
|
54
|
+
if result['document'].has_key?('config')
|
|
55
|
+
config(result['document'].delete('config'))
|
|
56
|
+
end
|
|
57
|
+
if result['document'].has_key?('layout')
|
|
58
|
+
layout(result['document'].delete('layout'))
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
result
|
|
62
|
+
else
|
|
63
|
+
nil
|
|
29
64
|
end
|
|
30
65
|
end
|
|
31
66
|
|
|
32
67
|
def config_fn(fn)
|
|
33
|
-
File.
|
|
68
|
+
if File.exists?( complete_fn = fn)
|
|
69
|
+
return complete_fn
|
|
70
|
+
elsif File.exists?( complete_fn = File.join(base_path, File.dirname(template_name), fn) )
|
|
71
|
+
return complete_fn
|
|
72
|
+
elsif File.exists?( complete_fn = File.join(config_path, fn))
|
|
73
|
+
return complete_fn
|
|
74
|
+
elsif File.exists?( complete_fn = File.join(Dokkit.model_config_dir(@config['model']['name']), fn))
|
|
75
|
+
return complete_fn
|
|
76
|
+
elsif File.exists?( complete_fn = File.join(Dokkit.model_config_dir(@config['model']['name']), @config['model']['name'] + @config_defext))
|
|
77
|
+
return complete_fn
|
|
78
|
+
else
|
|
79
|
+
# warn "WARNING: Config file #{fn} not found!"
|
|
80
|
+
return fn
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Find all COMMON.yaml files from given dir up to FS root.
|
|
85
|
+
def resolve_common_configs(dir, arr = []) # :nodoc:
|
|
86
|
+
# defer to parent dir first
|
|
87
|
+
parent = File.expand_path(File.join(dir, '..'))
|
|
88
|
+
resolve_common_configs(parent,arr) unless parent == dir # at root
|
|
89
|
+
fn = File.join(dir,'COMMON.yaml')
|
|
90
|
+
arr << fn if (File.exists?(fn) && File.readable?(fn))
|
|
91
|
+
arr
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def config_hash(key)
|
|
95
|
+
return @config[key] if @config.has_key?(key)
|
|
96
|
+
nil
|
|
34
97
|
end
|
|
35
98
|
|
|
99
|
+
# Find and evaluate all COMMON.yaml files from page dir up to FS root.
|
|
100
|
+
def eval_common_configs
|
|
101
|
+
common_configs = resolve_common_configs(File.expand_path(File.dirname(template_filename)))
|
|
102
|
+
common_configs.each { |fn| @config_files.push fn }
|
|
103
|
+
end # method
|
|
104
|
+
|
|
36
105
|
end
|
|
37
106
|
|
|
38
107
|
module Rote
|
|
@@ -40,15 +109,87 @@ module Rote
|
|
|
40
109
|
class Page
|
|
41
110
|
|
|
42
111
|
include DokkitPage
|
|
112
|
+
|
|
113
|
+
track_methods
|
|
43
114
|
alias page_initialize initialize
|
|
44
115
|
|
|
45
|
-
def initialize(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
116
|
+
def initialize(config_page, &blk)
|
|
117
|
+
init(config_page, &blk)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def page_initialize(config_page)
|
|
121
|
+
config_page = { :pages_dir => '.', :layout_dir => '.' }.merge(config_page)
|
|
122
|
+
@template_text = nil
|
|
123
|
+
@template_name = nil
|
|
124
|
+
@layout_names = []
|
|
125
|
+
@content_for_layout = nil
|
|
126
|
+
@result = nil
|
|
127
|
+
@layout_defext = config_page[:layout_defext]
|
|
128
|
+
@layout_path = config_page[:layout_dir][STRIP_SLASHES,1]
|
|
129
|
+
@layout_text = nil
|
|
130
|
+
@base_path = config_page[:pages_dir][STRIP_SLASHES,1]
|
|
131
|
+
|
|
132
|
+
@page_filters, @post_filters = [], []
|
|
133
|
+
|
|
134
|
+
# read in the template. Layout _may_ get configured later in page code
|
|
135
|
+
# We only add the pages_dir if it's not already there, because it's
|
|
136
|
+
# easier to pass the whole relative fn from rake...
|
|
137
|
+
# template_name always needs with no prefix.
|
|
138
|
+
tfn = @template_name = config_page[:fn]
|
|
139
|
+
read_template(tfn)
|
|
140
|
+
|
|
141
|
+
layout(File.basename(tfn, config_page[:template_defext]))
|
|
142
|
+
|
|
143
|
+
# Yield to the (extension mapping) block
|
|
144
|
+
yield self if block_given?
|
|
145
|
+
|
|
146
|
+
# Eval COMMON.rb's
|
|
147
|
+
eval_common_rubys
|
|
148
|
+
|
|
149
|
+
# get script filenames, and eval them if found
|
|
150
|
+
tfn = ruby_filename # nil if no file
|
|
151
|
+
instance_eval(File.read(tfn),tfn) if tfn
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
def init_dokkit_page(config_page, &blk)
|
|
155
|
+
config_page.with_defaults!(
|
|
156
|
+
{ :pages_dir => '.',
|
|
157
|
+
:layout_dir => '.',
|
|
158
|
+
:config_dir => '.',
|
|
159
|
+
:layout_defext => '.html',
|
|
160
|
+
:config_defext => '.yaml',
|
|
161
|
+
:template_defext => '.dpl'
|
|
162
|
+
}
|
|
163
|
+
)
|
|
164
|
+
@config_files = []
|
|
165
|
+
@config = { }
|
|
166
|
+
@config_path = config_page[:config_dir][STRIP_SLASHES,1]
|
|
167
|
+
@config_defext = config_page[:config_defext]
|
|
168
|
+
|
|
169
|
+
@template_name = tfn = config_page[:fn]
|
|
170
|
+
@base_path = config_page[:pages_dir][STRIP_SLASHES,1]
|
|
171
|
+
|
|
172
|
+
page_initialize(config_page, &blk)
|
|
173
|
+
|
|
174
|
+
load_model_config
|
|
175
|
+
eval_common_configs
|
|
176
|
+
config(File.basename(tfn, config_page[:template_defext]))
|
|
177
|
+
@config = load_configs
|
|
51
178
|
end
|
|
52
|
-
end
|
|
53
179
|
|
|
180
|
+
private
|
|
181
|
+
|
|
182
|
+
def layout_fn(fn = nil)
|
|
183
|
+
if File.exists?(complete_fn = File.join(layout_path,fn))
|
|
184
|
+
return complete_fn
|
|
185
|
+
elsif File.exists?(complete_fn = File.join(Dokkit.model_layout_dir(@config['model']['name']), fn))
|
|
186
|
+
return complete_fn
|
|
187
|
+
elsif File.exists?(complete_fn = File.join(Dokkit.model_layout_dir(@config['model']['name']), @config['model']['name'] + @layout_defext))
|
|
188
|
+
return complete_fn
|
|
189
|
+
else
|
|
190
|
+
raise "Layout file #{fn} not found!"
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
end
|
|
54
195
|
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
#
|
|
2
|
+
# File 'render_task_factory.rb' created on 18 Nov 2007 at 16:01:42.
|
|
3
|
+
#
|
|
4
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
|
5
|
+
#
|
|
6
|
+
# (C) 2006, 2007 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'singleton'
|
|
10
|
+
require 'rote/format/html'
|
|
11
|
+
require 'dokkit/filters'
|
|
12
|
+
require 'dokkit/dokkittasks'
|
|
13
|
+
|
|
14
|
+
module Dokkit
|
|
15
|
+
class RenderTaskFactory
|
|
16
|
+
include Singleton
|
|
17
|
+
def create_render_html(name = :render_html)
|
|
18
|
+
Rote::DocTask.new(name) do |task|
|
|
19
|
+
task.output_dir = 'html'
|
|
20
|
+
|
|
21
|
+
task.layout_dir = 'doc/layouts'
|
|
22
|
+
task.config_dir = 'doc/config'
|
|
23
|
+
|
|
24
|
+
task.pages.dir = 'doc/pages'
|
|
25
|
+
task.pages.include('**/*')
|
|
26
|
+
task.pages.exclude('**/*.yaml')
|
|
27
|
+
|
|
28
|
+
task.res.dir = 'doc/res/html'
|
|
29
|
+
task.res.include('**/*')
|
|
30
|
+
|
|
31
|
+
yield task if block_given?
|
|
32
|
+
|
|
33
|
+
task.ext_mapping(/dpl/, 'html', task.output_dir) do |page|
|
|
34
|
+
page.extend Rote::Format::HTML
|
|
35
|
+
page.page_filter Dokkit::Filters::Deplate.new('html-notemplate')
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
def create_render_tex(name = :render_tex)
|
|
40
|
+
Rote::DocTask.new(name) do |task|
|
|
41
|
+
task.output_dir = 'tex'
|
|
42
|
+
|
|
43
|
+
task.layout_dir = 'doc/layouts'
|
|
44
|
+
task.layout_defext = '.tex'
|
|
45
|
+
|
|
46
|
+
task.config_dir = 'doc/config'
|
|
47
|
+
|
|
48
|
+
task.pages.dir = 'doc/pages'
|
|
49
|
+
task.pages.include('**/*')
|
|
50
|
+
task.pages.exclude('**/*.yaml')
|
|
51
|
+
|
|
52
|
+
task.res.dir = 'doc/res/tex'
|
|
53
|
+
task.res.include('**/*')
|
|
54
|
+
|
|
55
|
+
yield task if block_given?
|
|
56
|
+
|
|
57
|
+
task.ext_mapping(/dpl/, 'tex', task.output_dir) do |page|
|
|
58
|
+
#FIXME: render_tex task must have its own format extension
|
|
59
|
+
page.extend Rote::Format::HTML
|
|
60
|
+
page.page_filter Dokkit::Filters::Deplate.new('latex-notemplate')
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
def create_render_text(name = :render_text)
|
|
65
|
+
Rote::DocTask.new(name) do |task|
|
|
66
|
+
task.output_dir = 'text'
|
|
67
|
+
|
|
68
|
+
task.layout_dir = 'doc/layouts'
|
|
69
|
+
task.layout_defext = '.text'
|
|
70
|
+
|
|
71
|
+
task.config_dir = 'doc/config'
|
|
72
|
+
|
|
73
|
+
task.pages.dir = 'doc/pages'
|
|
74
|
+
task.pages.include('**/*')
|
|
75
|
+
task.pages.exclude('**/*.yaml')
|
|
76
|
+
|
|
77
|
+
task.res.dir = 'doc/res/text'
|
|
78
|
+
task.res.include('**/*')
|
|
79
|
+
|
|
80
|
+
yield task if block_given?
|
|
81
|
+
|
|
82
|
+
task.ext_mapping(/dpl/, 'text', task.output_dir) do |page|
|
|
83
|
+
#FIXME: render_text task must have its own format extension
|
|
84
|
+
page.extend Rote::Format::HTML
|
|
85
|
+
page.page_filter Dokkit::Filters::Deplate.new('plain')
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
data/lib/dokkit.rb
CHANGED
|
@@ -1,25 +1,38 @@
|
|
|
1
1
|
# dokkit.rb - main Dokkit module
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2
|
+
|
|
3
|
+
#####
|
|
4
|
+
## *Dokkit* is a Rote (http://rote.rubyforge.it) and Rake (http://rake.rubyforge.org)
|
|
5
|
+
## based documentation building tool. It uses the deplate rendering engine to produce
|
|
6
|
+
## very polished tex file, page-based documentation, websites, and general textual templates.
|
|
7
|
+
## It enables embedded Ruby code, layouts, YAML config files and rake tasks
|
|
8
|
+
## to be used to automatically generate output in any
|
|
9
|
+
## (textual) format from a directory tree containing template files.
|
|
10
|
+
##
|
|
11
|
+
## Dokkit was created to manage the documentation produced by Alca Coop (http://alca.le.it/) for its customers
|
|
12
|
+
## and it is a fairly flexible tool.
|
|
13
|
+
##
|
|
14
|
+
## Dokkit can be used from the command-line, or in your own +Rakefile+. It
|
|
15
|
+
## supports both manual and automatic rendering of modified resources, and
|
|
16
|
+
## can be configured to monitor your source tree for changes.
|
|
17
|
+
##
|
|
18
|
+
## See +README+ and http://dokkit.rubyforge.org for general usage information.
|
|
19
|
+
##
|
|
20
|
+
## Copyright (C) 2006, 2007 Andrea Fazzi (and contributors).
|
|
21
|
+
##
|
|
22
|
+
## This program is free software: you can redistribute it and/or modify
|
|
23
|
+
## it under the terms of the GNU General Public License as published by
|
|
24
|
+
## the Free Software Foundation, either version 3 of the License, or
|
|
25
|
+
## (at your option) any later version.
|
|
26
|
+
##
|
|
27
|
+
## This program is distributed in the hope that it will be useful,
|
|
28
|
+
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
29
|
+
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
30
|
+
## GNU General Public License for more details.
|
|
31
|
+
##
|
|
32
|
+
## You should have received a copy of the GNU General Public License
|
|
33
|
+
## along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
34
|
+
##
|
|
35
|
+
## See +LICENSE+ for details.
|
|
23
36
|
|
|
24
37
|
# require these before gems, because we want to use them from
|
|
25
38
|
# lib/ , or from normal install, if that's how Dokkit was started.
|
|
@@ -42,28 +55,8 @@ end
|
|
|
42
55
|
require 'rake'
|
|
43
56
|
|
|
44
57
|
# Master Dokkit version. Manage this from the Rake release support.
|
|
45
|
-
DOKKITVERSION = '0.
|
|
58
|
+
DOKKITVERSION = '0.2.0'
|
|
46
59
|
|
|
47
|
-
#####
|
|
48
|
-
## *Dokkit* is a Rote (http://rote.rubyforge.it) and Rake (http://rake.rubyforge.org)
|
|
49
|
-
## based documentation building tool. It uses the deplate rendering engine to produce
|
|
50
|
-
## very polished tex file.
|
|
51
|
-
## page-based documentation, websites, and general textual templates.
|
|
52
|
-
## It enables embedded Ruby code, layout, and optionally plain-text formatting
|
|
53
|
-
## (HTML-only at present) to be used to automatically generate output in any
|
|
54
|
-
## (textual) format from a directory tree containing template files.
|
|
55
|
-
##
|
|
56
|
-
## Dokkit was created to manage the documentation of Alca Coop (http://alca.le.it/)
|
|
57
|
-
## and it is a fairly flexible tool. Dokkit can handle the internal documentation of
|
|
58
|
-
## your software house.
|
|
59
|
-
##
|
|
60
|
-
## Dokkit can be used from the command-line, or in your own +Rakefile+. It
|
|
61
|
-
## supports both manual and automatic rendering of modified resources, and
|
|
62
|
-
## can be configured to monitor your source tree for changes.
|
|
63
|
-
##
|
|
64
|
-
## See +README+ for general usage information.
|
|
65
|
-
##
|
|
66
|
-
## Dokkit is (c)2006 Andrea Fazzi (and contributors). See +LICENSE+ for details.
|
|
67
60
|
module Dokkit
|
|
68
61
|
|
|
69
62
|
# this space intentionally left blank
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
This is 'simple_document' a simple document model included in the core
|
|
2
|
+
distribution of dokkit. Check http://rubyforge.org/dokkit/ for other
|
|
3
|
+
models.
|
|
4
|
+
|
|
5
|
+
To modify this document simply edit 'doc/pages/simple_document.dpl'. To get further
|
|
6
|
+
information about the wiki syntax to be used please check http://deplate.sf.net/
|
|
7
|
+
|
|
8
|
+
To render this document in html, type:
|
|
9
|
+
|
|
10
|
+
dokkit render_html
|
|
11
|
+
|
|
12
|
+
from any subdirectory contained in the top-level directory (this one).
|
|
13
|
+
|
|
14
|
+
To render this document in TeX, type:
|
|
15
|
+
|
|
16
|
+
dokkit render_tex
|
|
17
|
+
|
|
18
|
+
In either case, you should get the output in a (created) 'output'
|
|
19
|
+
directory:
|
|
20
|
+
|
|
21
|
+
in 'output/html' you get html output
|
|
22
|
+
in 'output/tex' you get tex output
|
|
23
|
+
|
|
24
|
+
... and so on...
|
|
25
|
+
|
|
26
|
+
Once you have rendered the document, running the command again will appear
|
|
27
|
+
to do nothing, because only changed resources are re-rendered. To
|
|
28
|
+
clean the output and start over:
|
|
29
|
+
|
|
30
|
+
dokkit clobber
|
|
31
|
+
|
|
32
|
+
Alternatively, modify the page or resource files, and rerun
|
|
33
|
+
|
|
34
|
+
dokkit render_html
|
|
35
|
+
|
|
36
|
+
or
|
|
37
|
+
|
|
38
|
+
dokkit render_tex
|
|
39
|
+
|
|
40
|
+
to transform only the modified resource.
|
|
41
|
+
|
|
42
|
+
* WHAT'S NEXT?
|
|
43
|
+
|
|
44
|
+
- See what else you can do by typing:
|
|
45
|
+
|
|
46
|
+
dokkit --tasks
|
|
47
|
+
|
|
48
|
+
- Modify the configuration of the document by editing
|
|
49
|
+
'doc/config/simple_document.yaml'
|
|
50
|
+
|
|
51
|
+
- Create a new document by typing:
|
|
52
|
+
|
|
53
|
+
dokkit create_new_page new_document
|
|
54
|
+
|
|
55
|
+
For further information about dokkit see http://dokkit.rubyforge.org/
|
|
56
|
+
|
|
57
|
+
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
This is 'simple_document' a simple document model included in the core
|
|
2
|
+
distribution of dokkit. Check http://rubyforge.org/dokkit/ for other
|
|
3
|
+
models.
|
|
4
|
+
|
|
5
|
+
To modify this document simply edit 'doc/pages/simple_document.dpl'. To get further
|
|
6
|
+
information about the wiki syntax to be used please check http://deplate.sf.net/
|
|
7
|
+
|
|
8
|
+
To render this document in html, type:
|
|
9
|
+
|
|
10
|
+
dokkit render_html
|
|
11
|
+
|
|
12
|
+
from any subdirectory contained in the top-level directory (this one).
|
|
13
|
+
|
|
14
|
+
To render this document in TeX, type:
|
|
15
|
+
|
|
16
|
+
dokkit render_tex
|
|
17
|
+
|
|
18
|
+
In either case, you should get the output in a (created) 'output'
|
|
19
|
+
directory:
|
|
20
|
+
|
|
21
|
+
in 'output/html' you get html output
|
|
22
|
+
in 'output/tex' you get tex output
|
|
23
|
+
|
|
24
|
+
... and so on...
|
|
25
|
+
|
|
26
|
+
Once you have rendered the document, running the command again will appear
|
|
27
|
+
to do nothing, because only changed resources are re-rendered. To
|
|
28
|
+
clean the output and start over:
|
|
29
|
+
|
|
30
|
+
dokkit clobber
|
|
31
|
+
|
|
32
|
+
Alternatively, modify the page or resource files, and rerun
|
|
33
|
+
|
|
34
|
+
dokkit render_html
|
|
35
|
+
|
|
36
|
+
or
|
|
37
|
+
|
|
38
|
+
dokkit render_tex
|
|
39
|
+
|
|
40
|
+
to transform only the modified resource.
|
|
41
|
+
|
|
42
|
+
* WHAT'S NEXT?
|
|
43
|
+
|
|
44
|
+
- See what else you can do by typing:
|
|
45
|
+
|
|
46
|
+
dokkit --tasks
|
|
47
|
+
|
|
48
|
+
- Modify the configuration of the document by editing
|
|
49
|
+
'doc/config/simple_document.yaml'
|
|
50
|
+
|
|
51
|
+
- Create a new document by typing:
|
|
52
|
+
|
|
53
|
+
dokkit create_new_page new_document
|
|
54
|
+
|
|
55
|
+
For further information about dokkit see http://dokkit.rubyforge.org/
|
|
56
|
+
|
|
57
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#
|
|
2
|
+
# File 'Rakefile' created on 09 ott 2007 at 16:06:57.
|
|
3
|
+
#
|
|
4
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
|
5
|
+
#
|
|
6
|
+
# (C) 2006, 2007 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
|
7
|
+
#
|
|
8
|
+
# Rakefile for simpledocument project model
|
|
9
|
+
|
|
10
|
+
require 'dokkit'
|
|
11
|
+
require 'dokkit/app'
|
|
12
|
+
require 'dokkit/render_task_factory'
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
factory = Dokkit::RenderTaskFactory.instance
|
|
16
|
+
|
|
17
|
+
factory.create_render_html
|
|
18
|
+
factory.create_render_tex
|
|
19
|
+
|
|
20
|
+
task :default => [:render_html]
|
|
21
|
+
|
|
22
|
+
|