dokkit 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +5 -0
- data/Manifest.txt +90 -105
- data/README.txt +27 -7
- data/Rakefile +2 -3
- data/bin/dokkit +3 -2
- data/lib/dokkit/application.rb +159 -0
- data/lib/dokkit/cache/cache.rb +53 -0
- data/lib/dokkit/{models/simpledocument/model/Rakefile → cache.rb} +3 -15
- data/lib/dokkit/environment/basic.rb +156 -0
- data/lib/dokkit/environment/helpers/extmap.rb +29 -0
- data/lib/dokkit/environment/helpers/fileselection.rb +53 -0
- data/lib/dokkit/environment/helpers.rb +20 -0
- data/{spec/data/test_build/Rakefile → lib/dokkit/environment.rb} +4 -15
- data/lib/dokkit/factory/factory.rb +56 -0
- data/lib/dokkit/factory.rb +9 -0
- data/lib/dokkit/filters/deplate.rb +25 -20
- data/lib/dokkit/filters/maruku.rb +6 -5
- data/lib/dokkit/filters/nil.rb +7 -6
- data/lib/dokkit/filters.rb +5 -27
- data/lib/dokkit/hash.rb +82 -0
- data/lib/dokkit/{logger.rb → logging/logger.rb} +30 -24
- data/lib/dokkit/logging/observers/console.rb +52 -0
- data/lib/dokkit/{extension/extension.rb → logging/observers.rb} +7 -5
- data/lib/dokkit/logging.rb +11 -0
- data/lib/dokkit/models/simple/Rakefile +6 -0
- data/lib/dokkit/models/simple/doc/data/html/css/style.css +3 -0
- data/lib/dokkit/models/simple/doc/data/latex/deplate.sty +46 -0
- data/lib/dokkit/models/simple/doc/layouts/simple.html +9 -0
- data/lib/dokkit/models/simple/doc/layouts/simple.latex +11 -0
- data/lib/dokkit/models/simple/doc/pages/simple.deplate +80 -0
- data/lib/dokkit/models/simple/setup/setup.rb +10 -0
- data/lib/dokkit/resource/data.rb +36 -0
- data/lib/dokkit/resource/document.rb +385 -0
- data/lib/dokkit/resource/extensions/builtin.rb +19 -0
- data/lib/dokkit/resource/extensions/html.rb +22 -0
- data/lib/dokkit/resource/extensions/url.rb +25 -0
- data/lib/dokkit/{filters/base.rb → resource/extensions.rb} +7 -8
- data/lib/dokkit/resource/filenamehelper.rb +28 -0
- data/lib/dokkit/resource.rb +11 -0
- data/lib/dokkit/tasklib/clean.rb +73 -0
- data/lib/dokkit/tasklib/render.rb +137 -0
- data/lib/dokkit/tasklib.rb +11 -0
- data/lib/dokkit.rb +26 -29
- data/spec/dokkit/application_spec.rb +141 -0
- data/spec/dokkit/cache/cache_spec.rb +87 -0
- data/spec/dokkit/dokkit_spec.rb +20 -0
- data/spec/dokkit/environment/basic_spec.rb +135 -0
- data/spec/dokkit/environment/helpers/extmap_spec.rb +52 -0
- data/spec/dokkit/environment/helpers/fileselection_spec.rb +80 -0
- data/spec/dokkit/environment/test_data/doc/pages/document_1.yaml +3 -0
- data/spec/dokkit/factory/factory_spec.rb +69 -0
- data/spec/{filter_deplate_spec.rb → dokkit/filters/deplate_spec.rb} +7 -8
- data/spec/{filter_maruku_spec.rb → dokkit/filters/maruku_spec.rb} +3 -4
- data/spec/{filter_nil_spec.rb → dokkit/filters/nil_spec.rb} +3 -4
- data/spec/{recursivemerge_spec.rb → dokkit/hash_spec.rb} +25 -27
- data/spec/{logger_spec.rb → dokkit/logging/logger_spec.rb} +35 -47
- data/spec/{consolelog_spec.rb → dokkit/logging/observers/console_spec.rb} +14 -15
- data/spec/dokkit/resource/data_spec.rb +32 -0
- data/spec/dokkit/resource/document_spec.rb +485 -0
- data/spec/dokkit/resource/extensions/html_spec.rb +35 -0
- data/spec/dokkit/resource/extensions/url_spec.rb +29 -0
- data/spec/{filehelper_spec.rb → dokkit/resource/filenamehelper_spec.rb} +12 -13
- data/spec/dokkit/resource/test_data/doc/configs/config_1.yaml +3 -0
- data/spec/dokkit/resource/test_data/doc/configs/config_2.yaml +3 -0
- data/spec/dokkit/resource/test_data/doc/configs/required.yaml +3 -0
- data/spec/dokkit/resource/test_data/doc/configs/subdir/document.yaml +3 -0
- data/spec/dokkit/resource/test_data/doc/layouts/container.html +6 -0
- data/spec/dokkit/resource/test_data/doc/layouts/layout.html +6 -0
- data/spec/{data/test_build/doc/layouts → dokkit/resource/test_data/doc/layouts/nested}/nested.html +2 -1
- data/spec/dokkit/resource/test_data/doc/layouts/subdir/document.html +6 -0
- data/spec/dokkit/resource/test_data/doc/pages/COMMON.yaml +4 -0
- data/spec/dokkit/resource/test_data/doc/pages/document_with_many_config.ext +7 -0
- data/spec/dokkit/resource/test_data/doc/pages/document_with_many_errors.ext +12 -0
- data/spec/dokkit/resource/test_data/doc/pages/document_with_many_targets.ext +19 -0
- data/spec/dokkit/resource/test_data/doc/pages/document_with_nested_layout.ext +13 -0
- data/spec/dokkit/resource/test_data/doc/pages/document_with_nil_target.ext +5 -0
- data/spec/dokkit/resource/test_data/doc/pages/document_with_not_defined_target.ext +6 -0
- data/spec/dokkit/resource/test_data/doc/pages/document_with_one_target.ext +8 -0
- data/spec/dokkit/resource/test_data/doc/pages/subdir/COMMON.yaml +3 -0
- data/spec/dokkit/resource/test_data/doc/pages/subdir/document.ext +8 -0
- data/spec/dokkit/resource/test_data/doc/pages/subdir/document.yaml +5 -0
- data/spec/dokkit/tasklib/clean_spec.rb +75 -0
- data/spec/dokkit/tasklib/render_spec.rb +125 -0
- data/spec/dokkit/tasklib/test_data/doc/pages/document_2 +0 -0
- data/spec/dokkit/test_data/dokkit/models/model1/doc/pages/model1 +0 -0
- data/spec/dokkit/test_data/dokkit/models/model2/doc/pages/model2 +0 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +120 -47
- metadata +94 -117
- data/lib/dokkit/app.rb +0 -131
- data/lib/dokkit/builtintask.rb +0 -85
- data/lib/dokkit/cachemanager.rb +0 -61
- data/lib/dokkit/cleantask.rb +0 -51
- data/lib/dokkit/consolelog.rb +0 -42
- data/lib/dokkit/defaults.rb +0 -19
- data/lib/dokkit/deplate/fmt/html-notemplate.rb +0 -21
- data/lib/dokkit/deplate/fmt/latex-notemplate.rb +0 -24
- data/lib/dokkit/document.rb +0 -221
- data/lib/dokkit/dokkitlib.rb +0 -68
- data/lib/dokkit/extension/filehelper.rb +0 -25
- data/lib/dokkit/fileselection.rb +0 -44
- data/lib/dokkit/filters/all.rb +0 -18
- data/lib/dokkit/model.rb +0 -34
- data/lib/dokkit/models/simpledocument/model/doc/layouts/simpledocument.html +0 -9
- data/lib/dokkit/models/simpledocument/model/doc/pages/simpledocument.deplate +0 -102
- data/lib/dokkit/models/simpledocument/model/tasks/all.rb +0 -3
- data/lib/dokkit/models/simpledocument/model/tasks/clean.rake +0 -3
- data/lib/dokkit/models/simpledocument/model/tasks/render.rake +0 -8
- data/lib/dokkit/models/simpledocument/model/tasks/setup.rb +0 -9
- data/lib/dokkit/modeltask.rb +0 -83
- data/lib/dokkit/pathhelper.rb +0 -46
- data/lib/dokkit/recursivemerge.rb +0 -59
- data/lib/dokkit/rendertask.rb +0 -101
- data/lib/dokkit/resourcemanager.rb +0 -177
- data/lib/dokkit/taskconfig.rb +0 -39
- data/lib/dokkit/templatetask.rb +0 -37
- data/spec/app_spec.rb +0 -55
- data/spec/builtintask_spec.rb +0 -114
- data/spec/cachemanager_spec.rb +0 -107
- data/spec/cleantask_spec.rb +0 -72
- data/spec/data/test_build/doc/configs/document_1.yaml +0 -3
- data/spec/data/test_build/doc/configs/required.yaml +0 -3
- data/spec/data/test_build/doc/configs/subdir/document_4.yaml +0 -3
- data/spec/data/test_build/doc/layouts/document_1.html +0 -9
- data/spec/data/test_build/doc/layouts/document_with_partials.html +0 -9
- data/spec/data/test_build/doc/layouts/layout.html +0 -8
- data/spec/data/test_build/doc/layouts/layout.html.backup +0 -8
- data/spec/data/test_build/doc/layouts/partials/partial.html +0 -4
- data/spec/data/test_build/doc/pages/COMMON.yaml +0 -6
- data/spec/data/test_build/doc/pages/document_1 +0 -20
- data/spec/data/test_build/doc/pages/document_1.dep +0 -4
- data/spec/data/test_build/doc/pages/document_1.yaml +0 -11
- data/spec/data/test_build/doc/pages/document_2 +0 -9
- data/spec/data/test_build/doc/pages/document_2.yaml +0 -6
- data/spec/data/test_build/doc/pages/document_3 +0 -13
- data/spec/data/test_build/doc/pages/document_7 +0 -4
- data/spec/data/test_build/doc/pages/document_7.yaml +0 -5
- data/spec/data/test_build/doc/pages/document_extended +0 -1
- data/spec/data/test_build/doc/pages/document_nested +0 -6
- data/spec/data/test_build/doc/pages/document_nested.yaml +0 -5
- data/spec/data/test_build/doc/pages/document_nolayout.ext +0 -3
- data/spec/data/test_build/doc/pages/document_nolayout.yaml +0 -2
- data/spec/data/test_build/doc/pages/document_with_partials +0 -3
- data/spec/data/test_build/doc/pages/document_with_partials.yaml +0 -2
- data/spec/data/test_build/doc/pages/partials/COMMON.yaml +0 -5
- data/spec/data/test_build/doc/pages/partials/circular_partial +0 -2
- data/spec/data/test_build/doc/pages/partials/circular_partial.yaml +0 -3
- data/spec/data/test_build/doc/pages/partials/partial +0 -2
- data/spec/data/test_build/doc/pages/subdir/COMMON.yaml +0 -2
- data/spec/data/test_build/doc/pages/subdir/document_4 +0 -11
- data/spec/data/test_build/doc/pages/subdir/subdir/COMMON.yaml +0 -2
- data/spec/data/test_build/doc/pages/subdir/subdir/document_6 +0 -3
- data/spec/data/test_build/tasks/all.rb +0 -3
- data/spec/data/test_build/tasks/clean.rake +0 -3
- data/spec/data/test_build/tasks/render.rake +0 -8
- data/spec/data/test_build/tasks/setup.rb +0 -9
- data/spec/data/test_build/tasks/template.rake +0 -3
- data/spec/document_spec.rb +0 -321
- data/spec/dokkitlib_spec.rb +0 -63
- data/spec/fileselection_spec.rb +0 -101
- data/spec/filter_base_spec.rb +0 -29
- data/spec/filters_spec.rb +0 -37
- data/spec/model_spec.rb +0 -45
- data/spec/pathhelper_spec.rb +0 -62
- data/spec/rendertask_spec.rb +0 -374
- data/spec/taskconfig_spec.rb +0 -45
- data/spec/templatetask_spec.rb +0 -72
- /data/lib/dokkit/models/{simpledocument/model/doc/configs/simpledocument.yaml → simple/doc/configs/simple.yaml} +0 -0
- /data/lib/dokkit/models/{simpledocument/model/doc/layouts/simpledocument.text → simple/doc/layouts/simple.text} +0 -0
- /data/{lib/dokkit/models/simpledocument/model/doc/data/css/style.css → spec/dokkit/environment/helpers/test_data/doc/pages/document_1.ext_1} +0 -0
- /data/spec/{data/test_build/doc/data/resource → dokkit/environment/helpers/test_data/doc/pages/document_2} +0 -0
- /data/spec/{data/test_build/doc/data/resource.exclude → dokkit/environment/helpers/test_data/doc/pages/document_3.ext_3} +0 -0
- /data/spec/{data/test_build/doc/data/subdir/resource.insubdir → dokkit/environment/test_data/doc/data/data} +0 -0
- /data/spec/{data/test_build/doc/layouts/layout → dokkit/environment/test_data/doc/pages/document_1} +0 -0
- /data/spec/{data/test_build/doc/pages/document_2.dep → dokkit/environment/test_data/doc/pages/document_2} +0 -0
- /data/spec/{data/test_build/doc/pages/document_5.exclude → dokkit/environment/test_data/doc/pages/subdir/document_1} +0 -0
- /data/{lib/dokkit/models/simpledocument/model/doc/layouts/simpledocument.latex → spec/dokkit/resource/test_data/doc/layouts/layout.latex} +0 -0
- /data/spec/{data/test_build/doc/layouts/document_1.latex → dokkit/resource/test_data/doc/layouts/subdir/document.latex} +0 -0
- /data/spec/{data/test_build/templates/layouts/layout → dokkit/tasklib/test_data/doc/data/data_1} +0 -0
- /data/spec/{data/test_build/templates/pages/template → dokkit/tasklib/test_data/doc/pages/document_1} +0 -0
@@ -1,21 +0,0 @@
|
|
1
|
-
# latex-notemplate.rb
|
2
|
-
# @Author: Andrea Fazzi (andrea.fazzi AT alca.le.it)
|
3
|
-
# @Website: http://alca.le.it/
|
4
|
-
# @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
5
|
-
# @Created: 04-Dic-2006.
|
6
|
-
# @Last Change: 04-Dic-2006.
|
7
|
-
# @Revision: 0.1
|
8
|
-
|
9
|
-
require 'deplate/fmt/html'
|
10
|
-
|
11
|
-
class Deplate::Formatter::HTMLNoTemplate < Deplate::Formatter::HTML
|
12
|
-
self.myname = "html-notemplate"
|
13
|
-
self.rx = /html?(-notemplate)?/i
|
14
|
-
|
15
|
-
|
16
|
-
def prepare
|
17
|
-
end
|
18
|
-
|
19
|
-
def add_package(pkg, *options)
|
20
|
-
end
|
21
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# latex-notemplate.rb
|
2
|
-
# @Author: Luca Greco (luca.greco AT alca.le.it)
|
3
|
-
# @Website: http://alca.le.it/
|
4
|
-
# @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
5
|
-
# @Created: 16-Oct-2006.
|
6
|
-
# @Last Change: 16-Oct-2006.
|
7
|
-
# @Revision: 0.1
|
8
|
-
|
9
|
-
require 'deplate/fmt/latex'
|
10
|
-
|
11
|
-
class Deplate::Formatter::LatexNoTemplate < Deplate::Formatter::LaTeX
|
12
|
-
self.myname = "latex-notemplate"
|
13
|
-
self.rx = /(la)?tex(-notemplate)?/i
|
14
|
-
|
15
|
-
def prepare
|
16
|
-
end
|
17
|
-
|
18
|
-
def initialize_deplate_sty
|
19
|
-
end
|
20
|
-
|
21
|
-
def add_package(pkg, *options)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
data/lib/dokkit/document.rb
DELETED
@@ -1,221 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# File 'document.rb' created on 13 gen 2008 at 18:49: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
|
-
|
9
|
-
require 'ostruct'
|
10
|
-
require 'yaml'
|
11
|
-
require 'erb'
|
12
|
-
require 'dokkit/logger'
|
13
|
-
require 'dokkit/consolelog'
|
14
|
-
require 'dokkit/pathhelper'
|
15
|
-
require 'dokkit/cachemanager'
|
16
|
-
require 'dokkit/recursivemerge'
|
17
|
-
require 'dokkit/pathhelper'
|
18
|
-
require 'dokkit/filters/all'
|
19
|
-
require 'dokkit/extension/filehelper'
|
20
|
-
|
21
|
-
module Dokkit
|
22
|
-
class Document
|
23
|
-
DEFAULT_FILTER_CHAIN = {
|
24
|
-
'html' => ['deplate-html'],
|
25
|
-
'latex' => ['deplate-latex'],
|
26
|
-
'text' => ['deplate-text'],
|
27
|
-
'nil' => ['nil']
|
28
|
-
}
|
29
|
-
include Extension::FileHelper, PathHelper
|
30
|
-
attr_reader :document, :taskconfig
|
31
|
-
attr_reader :document_basename
|
32
|
-
attr_reader :configs, :targets, :layouts
|
33
|
-
attr_reader :filter_chain
|
34
|
-
attr_reader :configuration
|
35
|
-
attr_reader :source_text
|
36
|
-
attr_reader :prerequisites
|
37
|
-
attr_reader :logger
|
38
|
-
def initialize(document, taskconfig, rendered = [], &blk)
|
39
|
-
@logger = Log::ConsoleLog.consolelog
|
40
|
-
@document, @taskconfig, @rendered = document, taskconfig, rendered
|
41
|
-
@document_basename = File.basename(document)
|
42
|
-
@stripped_document = strip_ext(@document)
|
43
|
-
@layouts, @targets, @prerequisites, @filter_chain = { }, { }, { }, { }
|
44
|
-
@configs = []
|
45
|
-
@configuration = Hash.new do |h, k|
|
46
|
-
@logger.warn("Configuration key '#{k}' not defined in '#{targets[@format]}'!")
|
47
|
-
h[k] = "'#{k}' not defined!"
|
48
|
-
end
|
49
|
-
@configuration.extend ConfigHash
|
50
|
-
@source_text = read_source
|
51
|
-
@cache = CacheManager.instance
|
52
|
-
|
53
|
-
yield self if block_given?
|
54
|
-
|
55
|
-
collect_resources
|
56
|
-
end
|
57
|
-
def render(format)
|
58
|
-
@format = format
|
59
|
-
unless @source_text.nil?
|
60
|
-
erb = ERB.new(@source_text)
|
61
|
-
erb.filename = @document
|
62
|
-
@content_for_layout = apply_filters(erb.result(binding), format)
|
63
|
-
end
|
64
|
-
unless @layouts[format].empty?
|
65
|
-
@layouts[format].each do |layout_fn|
|
66
|
-
erb = ERB.new(File.read(layout_fn))
|
67
|
-
erb.filename = layout_fn
|
68
|
-
@content_for_layout = erb.result(binding)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
@content_for_layout
|
72
|
-
end
|
73
|
-
|
74
|
-
private
|
75
|
-
|
76
|
-
def extract_meta!(text)
|
77
|
-
meta_regexp = /\A-{3}$(.*?)-{3}$/m
|
78
|
-
meta = text.scan(meta_regexp).to_s
|
79
|
-
text.sub!(meta_regexp, '')
|
80
|
-
return meta
|
81
|
-
end
|
82
|
-
def render_partial(document_fn, format = @format, &blk)
|
83
|
-
unless @rendered.include?(document)
|
84
|
-
result = Document.new(File.join(@taskconfig.document_dir, document_fn), @taskconfig, @rendered << document, &blk).render(format)
|
85
|
-
@cache.add_dependency(targets[format], File.join(@taskconfig.document_dir, document_fn))
|
86
|
-
@rendered.clear
|
87
|
-
else
|
88
|
-
@logger.error("Circular dependency detected in '#{document}', aborting.")
|
89
|
-
end
|
90
|
-
result
|
91
|
-
end
|
92
|
-
def collect_resources
|
93
|
-
collect_configs
|
94
|
-
collect_targets
|
95
|
-
collect_layouts
|
96
|
-
collect_prerequisites
|
97
|
-
end
|
98
|
-
def collect_prerequisites
|
99
|
-
@targets.each_key do |format|
|
100
|
-
@prerequisites[format] = []
|
101
|
-
@prerequisites[format] << document
|
102
|
-
@prerequisites[format].concat @configs
|
103
|
-
@prerequisites[format].concat(@layouts[format]) if @layouts[format]
|
104
|
-
@prerequisites
|
105
|
-
end
|
106
|
-
end
|
107
|
-
def collect_configs
|
108
|
-
@configs << (config_fn_helper(@stripped_document, @taskconfig)) if File.exists?(config_fn_helper(@stripped_document, @taskconfig))
|
109
|
-
@configs.concat(resolve_common_configs(File.dirname(@document)))
|
110
|
-
@configs << (@stripped_document + '.yaml') if File.exists?(@stripped_document + '.yaml')
|
111
|
-
|
112
|
-
meta_configuration = YAML::load(extract_meta!(@source_text))
|
113
|
-
if meta_configuration
|
114
|
-
if meta_configuration.has_key?('config')
|
115
|
-
(@configs << get_config_fns(meta_configuration['config'])).flatten!
|
116
|
-
meta_configuration.delete('config')
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
@configs.each do |config_fn|
|
121
|
-
@configuration.recursive_merge!(YAML::load(File.open(config_fn)))
|
122
|
-
if @configuration.has_key?('config')
|
123
|
-
(@configs << get_config_fns(@configuration['config'])).flatten!
|
124
|
-
@configuration.delete('config')
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
@configuration.recursive_merge!(meta_configuration) if meta_configuration
|
129
|
-
end
|
130
|
-
def resolve_common_configs(dir, arr = [])
|
131
|
-
parent = File.expand_path(File.join(dir, '..'))
|
132
|
-
resolve_common_configs(parent, arr) unless parent == dir # at root
|
133
|
-
fn = File.join(dir,'COMMON.yaml')
|
134
|
-
arr << fn if (File.exists?(fn) && File.readable?(fn))
|
135
|
-
arr
|
136
|
-
end
|
137
|
-
def build_config_fn(fn)
|
138
|
-
result_fn = fn
|
139
|
-
if File.extname(fn).empty?
|
140
|
-
result_fn += '.yaml'
|
141
|
-
end
|
142
|
-
result_fn = File.join(@taskconfig.config_dir, result_fn)
|
143
|
-
end
|
144
|
-
def get_config_fns(configuration)
|
145
|
-
if configuration.is_a?(String)
|
146
|
-
result = build_config_fn(configuration)
|
147
|
-
elsif configuration.is_a?(Array)
|
148
|
-
result = configuration.collect do |fn|
|
149
|
-
fn = build_config_fn(fn)
|
150
|
-
end
|
151
|
-
else
|
152
|
-
@logger.fail('Invalid config file value.')
|
153
|
-
end
|
154
|
-
result
|
155
|
-
end
|
156
|
-
def collect_targets
|
157
|
-
if @configuration.has_key?('render_in')
|
158
|
-
@configuration['render_in'].each do |fmt|
|
159
|
-
if fmt.class != Hash
|
160
|
-
@targets[fmt] = output_fn_helper(@stripped_document, ".#{fmt}", @taskconfig)
|
161
|
-
@filter_chain[fmt] = DEFAULT_FILTER_CHAIN[fmt]
|
162
|
-
else
|
163
|
-
fmt.each do |format, configuration|
|
164
|
-
if(configuration.empty?)
|
165
|
-
@targets[format] = output_fn_helper(@stripped_document, ".#{format}")
|
166
|
-
@filter_chain[fmt] = DEFAULT_FILTER_CHAIN[fmt]
|
167
|
-
else
|
168
|
-
output, ext = @taskconfig.output_dir, ".#{format}"
|
169
|
-
ext = configuration['ext'] if configuration.has_key?('ext')
|
170
|
-
output = File.join(@taskconfig.output_dir, configuration['output']) if configuration.has_key?('output')
|
171
|
-
@targets[format] = File.join(output, strip_ext(@document_basename) + ext)
|
172
|
-
if configuration.has_key?('filters')
|
173
|
-
@filter_chain[format] = configuration['filters']
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
178
|
-
end
|
179
|
-
else
|
180
|
-
@targets['html'] = output_fn_helper(@stripped_document, '.html', @taskconfig)
|
181
|
-
@filter_chain['html'] = DEFAULT_FILTER_CHAIN['html']
|
182
|
-
end
|
183
|
-
end
|
184
|
-
def collect_layouts
|
185
|
-
@targets.each do |format, target|
|
186
|
-
layout_fn = []
|
187
|
-
layout_ext = File.extname(target)
|
188
|
-
layout_fn << (layout_fn_helper(@stripped_document, layout_ext, @taskconfig)) if File.exists?(layout_fn_helper(@stripped_document, layout_ext, @taskconfig))
|
189
|
-
layout_fn << (@stripped_document + layout_ext) if File.exists?(@stripped_document + layout_ext)
|
190
|
-
if @configuration.has_key?('layout')
|
191
|
-
@configuration['layout'].each do |layout|
|
192
|
-
config_layout_fn = strip_ext(layout)
|
193
|
-
layout_fn << File.join(@taskconfig.layout_dir, config_layout_fn + layout_ext) if File.exists?(File.join(@taskconfig.layout_dir, config_layout_fn + layout_ext))
|
194
|
-
layout_fn << (config_layout_fn + layout_ext) if File.exists?(config_layout_fn + layout_ext)
|
195
|
-
end
|
196
|
-
end
|
197
|
-
@logger.warn("Layout not found for '#{target}'!") if layout_fn.empty?
|
198
|
-
@layouts[format] = layout_fn.uniq.reverse
|
199
|
-
end
|
200
|
-
end
|
201
|
-
def read_source
|
202
|
-
File.read(document)
|
203
|
-
end
|
204
|
-
def apply_filters(text, target)
|
205
|
-
filters = []
|
206
|
-
chain = @filter_chain[target]
|
207
|
-
if chain
|
208
|
-
@filter_chain[target].each do |name|
|
209
|
-
begin
|
210
|
-
filters << Filters[name]
|
211
|
-
rescue
|
212
|
-
@logger.warn("Filter '#{name}' not found, ignored.")
|
213
|
-
end
|
214
|
-
end
|
215
|
-
filters.inject(text) { |s, f| f.filter(s) }
|
216
|
-
else
|
217
|
-
@logger.error("Don't know how to render in '#{target}' format!")
|
218
|
-
end
|
219
|
-
end
|
220
|
-
end
|
221
|
-
end
|
data/lib/dokkit/dokkitlib.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# File 'dokkitlib.rb' created on 18 feb 2008 at 17:54:20.
|
3
|
-
#
|
4
|
-
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
5
|
-
#
|
6
|
-
# (C) 2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'ostruct'
|
10
|
-
require 'rake'
|
11
|
-
require 'rake/tasklib'
|
12
|
-
require 'dokkit/defaults'
|
13
|
-
require 'dokkit/taskconfig'
|
14
|
-
require 'dokkit/pathhelper'
|
15
|
-
require 'dokkit/consolelog'
|
16
|
-
|
17
|
-
module Dokkit
|
18
|
-
class DokkitLib < Rake::TaskLib
|
19
|
-
include PathHelper, Rake::TaskManager
|
20
|
-
attr_reader :ns
|
21
|
-
attr_reader :logger
|
22
|
-
attr_reader :model
|
23
|
-
attr_accessor :config
|
24
|
-
def initialize(model, namespace = 'dokkit', opts = { })
|
25
|
-
@ns = namespace
|
26
|
-
@model = model
|
27
|
-
@config = model.config
|
28
|
-
@logger = Log::ConsoleLog.consolelog
|
29
|
-
|
30
|
-
pre_block_configuration
|
31
|
-
|
32
|
-
yield self if block_given?
|
33
|
-
|
34
|
-
post_block_configuration
|
35
|
-
|
36
|
-
check_directories if opts[:check_dir]
|
37
|
-
define_dokkit_tasks
|
38
|
-
end
|
39
|
-
def dokkit_task(*args, &block)
|
40
|
-
task_name, arg_names, needs = resolve_args(args.dup)
|
41
|
-
task(*args, &block) unless Rake::Task.task_defined?("#{@ns}:#{task_name}")
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
def check_directories
|
47
|
-
unless @config.directories.empty?
|
48
|
-
@config.directories.each_value do |dir|
|
49
|
-
@logger.error("Directory '#{dir}' does not exist") unless (dir =~ /output|cache/ || File.exists?(dir))
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
def pre_block_configuration
|
54
|
-
nil
|
55
|
-
end
|
56
|
-
def post_block_configuration
|
57
|
-
nil
|
58
|
-
end
|
59
|
-
def define_dokkit_tasks
|
60
|
-
namespace @ns do
|
61
|
-
private_methods.select { |meth| meth =~ /define_dokkit_/ and not meth =~ /define_dokkit_tasks/ }.each do |method|
|
62
|
-
self.send(method)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
@@ -1,25 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# File 'filehelper.rb' created on 28 feb 2008 at 16:40:57.
|
3
|
-
#
|
4
|
-
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
5
|
-
#
|
6
|
-
# (C) 2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'dokkit/extension/extension'
|
10
|
-
|
11
|
-
module Dokkit
|
12
|
-
module Extension
|
13
|
-
module FileHelper
|
14
|
-
def relative(href)
|
15
|
-
thr = href
|
16
|
-
if thr.is_a?(String) && href[0,1] == '/'
|
17
|
-
dtfn = File.dirname(document[/^#{taskconfig.document_dir}\/(.*)/,1]) + '/'
|
18
|
-
count = dtfn == './' ? 0 : dtfn.split('/').length
|
19
|
-
thr = ('../' * count) + href[1..href.length]
|
20
|
-
end
|
21
|
-
thr
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
data/lib/dokkit/fileselection.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# File 'fileselection.rb' created on 07 feb 2008 at 15:52: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 'rake'
|
10
|
-
|
11
|
-
module Dokkit
|
12
|
-
module ExtMapping
|
13
|
-
attr_reader :extmapping
|
14
|
-
def extend(regexp=/.*/, &blk)
|
15
|
-
@extmapping ||= { }
|
16
|
-
(files.select { |file| file =~ regexp }).each do |file|
|
17
|
-
@extmapping[file] = blk
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
class FileSelection
|
22
|
-
attr_accessor :base_dir
|
23
|
-
alias :dir :base_dir
|
24
|
-
alias :dir= :base_dir=
|
25
|
-
def initialize(base_dir = '.')
|
26
|
-
@base_dir = base_dir
|
27
|
-
@includes = []
|
28
|
-
@excludes = []
|
29
|
-
yield self if block_given?
|
30
|
-
end
|
31
|
-
def include(*patterns)
|
32
|
-
patterns.each { |pattern| @includes << pattern }
|
33
|
-
end
|
34
|
-
def exclude(*patterns)
|
35
|
-
patterns.each { |pattern| @excludes << pattern }
|
36
|
-
end
|
37
|
-
def files
|
38
|
-
FileList.new(@base_dir) do |fl|
|
39
|
-
fl.exclude *@excludes.collect { |exclude| File.join(@base_dir, exclude) } unless @excludes.empty?
|
40
|
-
fl.include *@includes.collect { |include| File.join(@base_dir, include) } unless @includes.empty?
|
41
|
-
end.uniq.select { |fn| not File.directory?(fn) }
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/lib/dokkit/filters/all.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# File 'all_filters.rb' created on 18 feb 2008 at 17:13:12.
|
3
|
-
#
|
4
|
-
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
5
|
-
#
|
6
|
-
# (C) 2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'dokkit/filters/base'
|
10
|
-
|
11
|
-
Dir[File.join(File.dirname(__FILE__), '*.rb')].each do |fn|
|
12
|
-
begin
|
13
|
-
require fn unless fn =~ /[\\\/]base.rb$/ or fn == 'all.rb'
|
14
|
-
rescue LoadError
|
15
|
-
nil
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
data/lib/dokkit/model.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# File 'model.rb' created on 10 mar 2008 at 13:39:48.
|
3
|
-
#
|
4
|
-
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
5
|
-
#
|
6
|
-
# (C) 2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'yaml'
|
10
|
-
require 'dokkit/taskconfig'
|
11
|
-
require 'dokkit/cachemanager'
|
12
|
-
|
13
|
-
module Dokkit
|
14
|
-
class Model
|
15
|
-
class << self
|
16
|
-
def init(name = 'model', &blk)
|
17
|
-
@model ||= Model.new(name, &blk)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
attr_accessor :config
|
21
|
-
attr_reader :name, :cache
|
22
|
-
def initialize(name, &blk)
|
23
|
-
@name = name
|
24
|
-
@config = TaskConfig.new
|
25
|
-
|
26
|
-
yield self if block_given?
|
27
|
-
|
28
|
-
@cache = CacheManager.instance
|
29
|
-
@cache.init('deps.yaml', @config.cache_dir)
|
30
|
-
|
31
|
-
self
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,102 +0,0 @@
|
|
1
|
-
---
|
2
|
-
title: The simpledocument model
|
3
|
-
render_in:
|
4
|
-
- html
|
5
|
-
- latex
|
6
|
-
- text
|
7
|
-
---
|
8
|
-
|
9
|
-
%% Dynamic generation of the Table of Contents.
|
10
|
-
%% Generate TOC only if formatter is different from html.
|
11
|
-
|
12
|
-
#IF: fmt==html-notemplate
|
13
|
-
#VAR: headings=plain
|
14
|
-
#ELSE
|
15
|
-
#LIST: toc
|
16
|
-
----8<----
|
17
|
-
#ENDIF
|
18
|
-
|
19
|
-
|
20
|
-
* Description of the model
|
21
|
-
|
22
|
-
This is a simple document model for ''dokkit''. You can use this model
|
23
|
-
as a base to create simple documents like tutorials, howtos, technical
|
24
|
-
reports, etc.
|
25
|
-
|
26
|
-
* Edit and render your document
|
27
|
-
|
28
|
-
To edit the content of the document simply edit
|
29
|
-
''simpledocument.deplate'' in ''doc/pages'' folder or create a new
|
30
|
-
file in ''doc/pages'' directory.
|
31
|
-
|
32
|
-
To get further information about the deplate wiki syntax please check
|
33
|
-
[[http://deplate.sf.net/deplate.html][deplate]] homepage.
|
34
|
-
|
35
|
-
To render this document in ''html'', ''tex'' and ''plain text'', open a terminal and type:
|
36
|
-
|
37
|
-
#Verbatim <<EOB
|
38
|
-
$ dokkit ## or rake
|
39
|
-
EOB
|
40
|
-
|
41
|
-
from the top-level directory or from any subdirectory contained in it.
|
42
|
-
|
43
|
-
You should get the output files in the 'output' folder.
|
44
|
-
|
45
|
-
* Rendering the modified parts of the document and cleaning up
|
46
|
-
|
47
|
-
Once you have rendered the document, running the ''dokkit'' command again will
|
48
|
-
appear to do nothing, because only changed resources are re-rendered.
|
49
|
-
To clean the output and start over run:
|
50
|
-
|
51
|
-
#Verbatim <<EOB
|
52
|
-
$ dokkit clobber
|
53
|
-
EOB
|
54
|
-
|
55
|
-
Note that if you modify any part of the document then you must re-run
|
56
|
-
''dokkit'' command in order to apply changes and to re-generate the
|
57
|
-
desidered output.
|
58
|
-
|
59
|
-
So, once you have modified your document, run:
|
60
|
-
|
61
|
-
#Verbatim <<EOB
|
62
|
-
$ dokkit ## or rake
|
63
|
-
EOB
|
64
|
-
|
65
|
-
Only the modified resources will be transformed.
|
66
|
-
|
67
|
-
* Configure the documentation environment
|
68
|
-
|
69
|
-
To configure your documentation environment edit the *.rake files in
|
70
|
-
''tasks'' folder.
|
71
|
-
|
72
|
-
* How to get other ''dokkit'' models
|
73
|
-
|
74
|
-
To search for other document models open a terminal and type:
|
75
|
-
|
76
|
-
#Verbatim <<EOB
|
77
|
-
$ gem list dokkit-model
|
78
|
-
EOB
|
79
|
-
|
80
|
-
To get a particular model named <model_name> run:
|
81
|
-
|
82
|
-
#Verbatim <<EOB
|
83
|
-
$ gem install dokkit-model-<model_name>
|
84
|
-
EOB
|
85
|
-
|
86
|
-
or check http://rubyforge.org/projects/dokkit/.
|
87
|
-
|
88
|
-
* What's next?
|
89
|
-
|
90
|
-
* See what else you can do by typing:
|
91
|
-
|
92
|
-
''$ dokkit --tasks''
|
93
|
-
|
94
|
-
|
95
|
-
- Modify the configuration of the document by editing
|
96
|
-
''doc/config/simpledocument.yaml''.
|
97
|
-
|
98
|
-
- Override the default layout creating in custom layouts in ''doc/layouts''.
|
99
|
-
|
100
|
-
For further information about ''dokkit'' see http://dokkit.rubyforge.org/.
|
101
|
-
|
102
|
-
|
@@ -1,9 +0,0 @@
|
|
1
|
-
require 'dokkit/model'
|
2
|
-
|
3
|
-
MODEL = Dokkit::Model.init('simpledocument') do |model|
|
4
|
-
model.config.document_dir = 'doc/pages'
|
5
|
-
model.config.config_dir = 'doc/configs'
|
6
|
-
model.config.layout_dir = 'doc/layouts'
|
7
|
-
model.config.output_dir = 'output'
|
8
|
-
model.config.cache_dir = '.cache'
|
9
|
-
end
|
data/lib/dokkit/modeltask.rb
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# File 'modeltask.rb' created on 23 feb 2008 at 20:45:10.
|
3
|
-
#
|
4
|
-
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
5
|
-
#
|
6
|
-
# (C) 2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
7
|
-
#
|
8
|
-
|
9
|
-
require 'yaml'
|
10
|
-
require 'dokkit'
|
11
|
-
require 'dokkit/dokkitlib'
|
12
|
-
|
13
|
-
module Dokkit
|
14
|
-
class ModelTask < DokkitLib
|
15
|
-
attr_reader :models
|
16
|
-
def initialize(model, namespace = 'model')
|
17
|
-
super(model, namespace)
|
18
|
-
end
|
19
|
-
def pre_block_configuration
|
20
|
-
@config.local_dir ||= DEFAULT_LOCAL_DIR
|
21
|
-
@config.search_in ||= [:dokkit_dir, :local_dir]
|
22
|
-
end
|
23
|
-
def post_block_configuration
|
24
|
-
fetch_models
|
25
|
-
end
|
26
|
-
def dokkit_dir
|
27
|
-
lib = nil
|
28
|
-
unless lib = ENV['DOKKIT_LIB']
|
29
|
-
$:.each do |it|
|
30
|
-
if File.exists?(File.join(it, 'dokkit/app.rb'))
|
31
|
-
lib = it
|
32
|
-
break
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
lib
|
37
|
-
end
|
38
|
-
def builtin_model_dir
|
39
|
-
File.join(dokkit_dir, 'dokkit/models')
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def from_location(location)
|
45
|
-
return builtin_model_dir if location == :dokkit_dir
|
46
|
-
return File.expand_path(File.join('~', @config.local_dir)) if location == :local_dir
|
47
|
-
end
|
48
|
-
def fetch_models
|
49
|
-
@models = { }
|
50
|
-
config.search_in.each do |location|
|
51
|
-
Dir.glob(File.join(from_location(location), '**/Rakefile')).each do |model|
|
52
|
-
@models[model.scan(/models\/(.*)\/Rakefile/).flatten.to_s] = File.dirname(model)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
def define_dokkit_list_model_task
|
57
|
-
desc 'List the installed models'
|
58
|
-
dokkit_task 'list' do
|
59
|
-
@models.each do |modelname, path|
|
60
|
-
@logger.info("Found model '#{modelname}' in #{path}")
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
def define_dokkit_create_task
|
65
|
-
desc 'Bootstrap a new documentation project'
|
66
|
-
dokkit_task 'create', :model do |t, args|
|
67
|
-
model = args.model || DEFAULT_MODEL
|
68
|
-
if ARGV.size == 2
|
69
|
-
dest_dir = t.application.top_level_tasks.pop
|
70
|
-
else
|
71
|
-
@logger.error('A target directory must be provided.')
|
72
|
-
end
|
73
|
-
@logger.error("Directory '#{dest_dir}' exists.") if File.exists?(dest_dir)
|
74
|
-
@logger.error("Model '#{model}' not found.") unless @models[model]
|
75
|
-
@logger.info("Create '#{dest_dir}' based on '#{model}' model.")
|
76
|
-
cp_r(@models[model], dest_dir)
|
77
|
-
File.open(File.join(dest_dir, 'tasks/model.yaml'), 'w') do |file|
|
78
|
-
file << { 'name' => model, 'from' => @models[model] }.to_yaml
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|