dokkit 0.3.0 → 0.4.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/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
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
#
|
|
2
|
+
# File 'basic.rb' created on 01 mag 2008 at 15:37:33.
|
|
3
|
+
#
|
|
4
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
|
5
|
+
#
|
|
6
|
+
# (C)2006-2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'ostruct'
|
|
10
|
+
require 'rake'
|
|
11
|
+
require 'dokkit'
|
|
12
|
+
require 'dokkit/environment'
|
|
13
|
+
require 'dokkit/logging'
|
|
14
|
+
require 'dokkit/factory'
|
|
15
|
+
require 'dokkit/resource'
|
|
16
|
+
require 'dokkit/tasklib'
|
|
17
|
+
require 'dokkit/filters'
|
|
18
|
+
require 'dokkit/cache'
|
|
19
|
+
|
|
20
|
+
module Dokkit
|
|
21
|
+
module Environment
|
|
22
|
+
module Basic
|
|
23
|
+
|
|
24
|
+
# When included in a container, initialize it.
|
|
25
|
+
def initialize
|
|
26
|
+
add_lib_to_load_path
|
|
27
|
+
yield self if block_given?
|
|
28
|
+
define_tasks
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Add lib folder to the load path.
|
|
32
|
+
def add_lib_to_load_path
|
|
33
|
+
$: << 'lib'
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Define rake tasks for the environment.
|
|
37
|
+
def define_tasks
|
|
38
|
+
render
|
|
39
|
+
clean
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Setup a console logger.
|
|
43
|
+
def logger
|
|
44
|
+
@logger ||= Logging::Observer::Console.logger
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Setup cache.
|
|
48
|
+
def cache
|
|
49
|
+
@cache ||= Cache.new
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Return an OpenStruct object to setup documentation
|
|
53
|
+
# directories. Instantiate the object only once.
|
|
54
|
+
#
|
|
55
|
+
# configuration.document_dir :: set/get documents folder.
|
|
56
|
+
# configuration.config_dir :: set/get configs folder.
|
|
57
|
+
# configuration.layout_dir :: set/get layouts folder.
|
|
58
|
+
# configuration.data_dir :: set/get data folder.
|
|
59
|
+
# configuration.output_dir :: set/get output folder.
|
|
60
|
+
# configuration.cache_dir :: set/get cache folder.
|
|
61
|
+
#
|
|
62
|
+
def configuration
|
|
63
|
+
@configuration ||= OpenStruct.new({
|
|
64
|
+
:document_dir => 'doc/pages',
|
|
65
|
+
:config_dir => 'doc/configs',
|
|
66
|
+
:layout_dir => 'doc/layouts',
|
|
67
|
+
:data_dir => 'doc/data',
|
|
68
|
+
:output_dir => 'output',
|
|
69
|
+
:cache_dir => '.cache'
|
|
70
|
+
})
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Return a Dokkit::Environment::Helper::FileSelection object
|
|
74
|
+
# with the list of documents in configuration.document_dir
|
|
75
|
+
# folder and its subdir. The object is instantiated only
|
|
76
|
+
# once. By default all files in configuration.document_dir and
|
|
77
|
+
# subdirs are included.
|
|
78
|
+
def documents
|
|
79
|
+
@documents ||= Environment::Helper::FileSelection.new(configuration.document_dir) do |fs|
|
|
80
|
+
fs.include('**/*')
|
|
81
|
+
fs.exclude('**/*.yaml')
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Return a Dokkit::Environment::Helper::FileSelection object
|
|
86
|
+
# with the list of data files in configuration.data_dir folder
|
|
87
|
+
# and its subdir. The object is instantiated only once.
|
|
88
|
+
def data
|
|
89
|
+
@data ||= Environment::Helper::FileSelection.new(configuration.data_dir).include('**/*')
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Return a Dokkit::Environment::Helper::ExtMap object that map
|
|
93
|
+
# an extension code block to document files using glob patterns.
|
|
94
|
+
def extmap
|
|
95
|
+
@extmap ||= Helper::ExtMap.new(configuration.document_dir)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Construct a filter factory and register filters.
|
|
99
|
+
def filter_factory
|
|
100
|
+
@filter_factory ||= Dokkit::Factory.new do |factory|
|
|
101
|
+
factory.add('maruku-html' => lambda { Dokkit::Filter::MarukuHTML.new } )
|
|
102
|
+
factory.add('deplate-latex' => lambda { Dokkit::Filter::DeplateLatex.new } )
|
|
103
|
+
factory.add('deplate-html' => lambda { Dokkit::Filter::DeplateHTML.new } )
|
|
104
|
+
factory.add('deplate-text' => lambda { Dokkit::Filter::DeplateText.new } )
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Construct a resource factory to get resource instances
|
|
109
|
+
# (i.e. document and data). The object is instantiated only
|
|
110
|
+
# once.
|
|
111
|
+
def resource_factory
|
|
112
|
+
@resource_factory ||= Factory.new do |factory|
|
|
113
|
+
factory.add(:document => document_factory_block)
|
|
114
|
+
factory.add(:data => data_factory_block)
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
# Return a block that is able to construct a Document instance.
|
|
118
|
+
def document_factory_block
|
|
119
|
+
lambda do |source_fn|
|
|
120
|
+
Resource::Document.new(source_fn,
|
|
121
|
+
configuration.marshal_dump,
|
|
122
|
+
logger,
|
|
123
|
+
cache,
|
|
124
|
+
resource_factory,
|
|
125
|
+
filter_factory,
|
|
126
|
+
&extmap[source_fn])
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
# Return a block that is able to construct a Data instance.
|
|
130
|
+
def data_factory_block
|
|
131
|
+
lambda do |source_fn|
|
|
132
|
+
Resource::Data.new(source_fn, configuration.marshal_dump)
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
# Define render tasklib.
|
|
136
|
+
def render
|
|
137
|
+
TaskLib::Render.new(logger, resource_factory, documents.files, data.files)
|
|
138
|
+
end
|
|
139
|
+
# Define clean tasklib.
|
|
140
|
+
def clean
|
|
141
|
+
TaskLib::Clean.new(logger, configuration.marshal_dump)
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
module Dokkit
|
|
148
|
+
module Environment
|
|
149
|
+
module Basic
|
|
150
|
+
# Define a setup container.
|
|
151
|
+
class Container
|
|
152
|
+
include Dokkit::Environment::Basic
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#
|
|
2
|
+
# File 'extmap.rb' created on 14 mag 2008 at 10:52:17.
|
|
3
|
+
#
|
|
4
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
|
5
|
+
#
|
|
6
|
+
# (C)2006-2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'dokkit/environment/helpers/fileselection'
|
|
10
|
+
|
|
11
|
+
module Dokkit
|
|
12
|
+
module Environment
|
|
13
|
+
module Helper
|
|
14
|
+
class ExtMap < FileSelection
|
|
15
|
+
def initialize(base_dir)
|
|
16
|
+
super(base_dir)
|
|
17
|
+
@ext = { }
|
|
18
|
+
end
|
|
19
|
+
def map(&blk)
|
|
20
|
+
files.each { |fn| @ext[fn] = blk }
|
|
21
|
+
self
|
|
22
|
+
end
|
|
23
|
+
def [](resource)
|
|
24
|
+
@ext[resource]
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#
|
|
2
|
+
# File 'fileselection.rb' created on 01 mag 2008 at 16:31:18.
|
|
3
|
+
#
|
|
4
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
|
5
|
+
#
|
|
6
|
+
# (C)2006-2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'rake'
|
|
10
|
+
|
|
11
|
+
module Dokkit
|
|
12
|
+
module Environment
|
|
13
|
+
module Helper
|
|
14
|
+
# FileSelection encapsulates the behaviour of Rake::FileList
|
|
15
|
+
# class. Objects of class FileSelection are capable to return
|
|
16
|
+
# the list of file in a directory. Objects are initialized with
|
|
17
|
+
# a base directory. File list can be refined with
|
|
18
|
+
# FileSelection#include and FileSelection#exclude instance
|
|
19
|
+
# methods.
|
|
20
|
+
class FileSelection
|
|
21
|
+
attr_reader :base_dir
|
|
22
|
+
alias :dir :base_dir
|
|
23
|
+
# Initialize a FileSelection object.
|
|
24
|
+
# base_dir :: the base dir for all inclusion/exclusion operations.
|
|
25
|
+
def initialize(base_dir = '.')
|
|
26
|
+
@base_dir = base_dir
|
|
27
|
+
@includes = []
|
|
28
|
+
@excludes = []
|
|
29
|
+
yield self if block_given?
|
|
30
|
+
end
|
|
31
|
+
# Include files to the list.
|
|
32
|
+
# patterns :: array of glob patterns
|
|
33
|
+
def include(*patterns)
|
|
34
|
+
patterns.each { |pattern| @includes << pattern }
|
|
35
|
+
self
|
|
36
|
+
end
|
|
37
|
+
# Exclude files from the list.
|
|
38
|
+
# patterns :: array of glob patterns
|
|
39
|
+
def exclude(*patterns)
|
|
40
|
+
patterns.each { |pattern| @excludes << pattern }
|
|
41
|
+
self
|
|
42
|
+
end
|
|
43
|
+
# Return an array containing the file list.
|
|
44
|
+
def files
|
|
45
|
+
FileList.new(@base_dir) do |fl|
|
|
46
|
+
fl.exclude *@excludes.collect { |exclude| File.join(@base_dir, exclude) } unless @excludes.empty?
|
|
47
|
+
fl.include *@includes.collect { |include| File.join(@base_dir, include) } unless @includes.empty?
|
|
48
|
+
end.uniq.select { |fn| not File.directory?(fn) }
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#
|
|
2
|
+
# File 'helpers.rb' created on 04 mag 2008 at 17:44:17.
|
|
3
|
+
#
|
|
4
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
|
5
|
+
#
|
|
6
|
+
# (C)2006-2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'dokkit/environment/helpers/fileselection'
|
|
10
|
+
require 'dokkit/environment/helpers/extmap'
|
|
11
|
+
|
|
12
|
+
module Dokkit
|
|
13
|
+
module Environment
|
|
14
|
+
# Collect helper class that simplify the setup of
|
|
15
|
+
# documentation environment.
|
|
16
|
+
module Helper
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
#
|
|
2
|
-
# File '
|
|
2
|
+
# File 'environment.rb' created on 04 mag 2008 at 17:34:56.
|
|
3
3
|
#
|
|
4
4
|
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
|
5
5
|
#
|
|
6
|
-
# (C)
|
|
6
|
+
# (C)2006-2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
|
7
7
|
#
|
|
8
|
-
# Rakefile for website project model
|
|
9
|
-
|
|
10
|
-
require 'tasks/all'
|
|
11
|
-
|
|
12
|
-
task :clobber => 'clean:all'
|
|
13
|
-
task :default => 'render:all'
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
8
|
|
|
9
|
+
require 'dokkit/environment/basic'
|
|
10
|
+
require 'dokkit/environment/helpers'
|
|
22
11
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
|
|
2
|
+
# File 'factory.rb' created on 25 apr 2008 at 19:43:56.
|
|
3
|
+
#
|
|
4
|
+
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
|
5
|
+
#
|
|
6
|
+
# (C)2006-2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
module Dokkit
|
|
10
|
+
class Factory
|
|
11
|
+
|
|
12
|
+
# Return stored instances.
|
|
13
|
+
attr_reader :instances
|
|
14
|
+
|
|
15
|
+
# Return stored factory method.
|
|
16
|
+
attr_reader :methods
|
|
17
|
+
|
|
18
|
+
# Initialize a Factory object. Configuration is made passing a
|
|
19
|
+
# code block.
|
|
20
|
+
def initialize
|
|
21
|
+
@instances, @methods = { }, { }
|
|
22
|
+
yield self if block_given?
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Add a factory method associated with the given class of objects.
|
|
26
|
+
# +factory_method+ is a class/method pair.
|
|
27
|
+
#
|
|
28
|
+
# Example:
|
|
29
|
+
#
|
|
30
|
+
# factory.add(:bar => bar_factory_method) # add a method that
|
|
31
|
+
# # instantiates Bar object
|
|
32
|
+
#
|
|
33
|
+
def add(factory_method)
|
|
34
|
+
@methods.merge! factory_method
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Construct an instance for the given class. Note that, if an
|
|
38
|
+
# instance of the same class has been already instantiated for a
|
|
39
|
+
# given parameters set, then *no* new instance will be created but
|
|
40
|
+
# the first one will be returned.
|
|
41
|
+
def get(key, *params)
|
|
42
|
+
get_instance(key, *params) || store_instance(key, *params)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
def store_instance(key, *params)
|
|
48
|
+
@instances[ [key].concat(params) ] = @methods[key].call(*params)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def get_instance(key, *params)
|
|
52
|
+
@instances[ [key].concat(params) ]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -1,39 +1,44 @@
|
|
|
1
1
|
#--
|
|
2
2
|
# Dokkit filter for Deplate
|
|
3
|
-
# (c)2006 Andrea Fazzi (and contributors)
|
|
3
|
+
# (c) 2006, 2007, 2008 Andrea Fazzi (and contributors)
|
|
4
4
|
#
|
|
5
5
|
# See 'dokkit.rb' or LICENSE for licence information.
|
|
6
6
|
|
|
7
|
-
require 'deplate/
|
|
8
|
-
require 'deplate/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
require 'deplate/deplate-string'
|
|
8
|
+
require 'deplate/fmt/latex'
|
|
9
|
+
|
|
10
|
+
class Deplate::Formatter::LaTeX
|
|
11
|
+
def initialize_deplate_sty; end
|
|
12
|
+
end
|
|
13
13
|
|
|
14
14
|
module Dokkit
|
|
15
|
-
module
|
|
16
|
-
|
|
15
|
+
module Filter
|
|
16
|
+
|
|
17
|
+
class DeplateHTML
|
|
18
|
+
|
|
17
19
|
def filter(text)
|
|
18
|
-
|
|
19
|
-
::Deplate::Converter.new('html-notemplate').convert_string(text)
|
|
20
|
+
DeplateString.new(text).to_html
|
|
20
21
|
end
|
|
22
|
+
|
|
21
23
|
end
|
|
22
|
-
|
|
24
|
+
|
|
25
|
+
class DeplateLatex
|
|
26
|
+
|
|
23
27
|
def filter(text)
|
|
24
|
-
|
|
25
|
-
::Deplate::Converter.new('latex-notemplate').convert_string(text)
|
|
28
|
+
DeplateString.new(text).to_latex
|
|
26
29
|
end
|
|
30
|
+
|
|
27
31
|
end
|
|
28
|
-
|
|
32
|
+
|
|
33
|
+
class DeplateText
|
|
34
|
+
|
|
29
35
|
def filter(text)
|
|
30
|
-
|
|
36
|
+
DeplateString.new(text).to_text
|
|
31
37
|
end
|
|
38
|
+
|
|
32
39
|
end
|
|
40
|
+
|
|
33
41
|
end
|
|
34
42
|
end
|
|
35
|
-
|
|
36
|
-
Dokkit::Filters.register('deplate-html') { Dokkit::Filters::DeplateHTML.new }
|
|
37
|
-
Dokkit::Filters.register('deplate-latex') { Dokkit::Filters::DeplateLatex.new }
|
|
38
|
-
Dokkit::Filters.register('deplate-text') { Dokkit::Filters::DeplateText.new }
|
|
43
|
+
|
|
39
44
|
|
|
@@ -6,18 +6,19 @@
|
|
|
6
6
|
# (C) 2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
|
7
7
|
#
|
|
8
8
|
|
|
9
|
-
require 'dokkit/filters/base'
|
|
10
|
-
require 'dokkit/filters'
|
|
11
9
|
require 'maruku'
|
|
12
10
|
|
|
13
11
|
module Dokkit
|
|
14
|
-
module
|
|
15
|
-
|
|
12
|
+
module Filter
|
|
13
|
+
|
|
14
|
+
class MarukuHTML
|
|
15
|
+
|
|
16
16
|
def filter(text)
|
|
17
17
|
Maruku.new(text).to_html
|
|
18
18
|
end
|
|
19
|
+
|
|
19
20
|
end
|
|
21
|
+
|
|
20
22
|
end
|
|
21
23
|
end
|
|
22
24
|
|
|
23
|
-
Dokkit::Filters.register('maruku-html') { Dokkit::Filters::MarukuHTML.new }
|
data/lib/dokkit/filters/nil.rb
CHANGED
|
@@ -6,18 +6,19 @@
|
|
|
6
6
|
# (C) 2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
|
7
7
|
#
|
|
8
8
|
|
|
9
|
-
require 'dokkit/filters/base'
|
|
10
|
-
require 'dokkit/filters'
|
|
11
|
-
|
|
12
9
|
module Dokkit
|
|
13
|
-
module
|
|
14
|
-
|
|
10
|
+
module Filter
|
|
11
|
+
|
|
12
|
+
class Nil
|
|
13
|
+
|
|
15
14
|
def filter(text)
|
|
16
15
|
text
|
|
17
16
|
end
|
|
17
|
+
|
|
18
18
|
end
|
|
19
|
+
|
|
19
20
|
end
|
|
20
21
|
end
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
|
|
23
24
|
|
data/lib/dokkit/filters.rb
CHANGED
|
@@ -1,34 +1,12 @@
|
|
|
1
1
|
#
|
|
2
|
-
# File 'filters.rb' created on
|
|
2
|
+
# File 'filters.rb' created on 04 mag 2008 at 17:39:39.
|
|
3
3
|
#
|
|
4
4
|
# See 'dokkit.rb' or +LICENSE+ for licence information.
|
|
5
5
|
#
|
|
6
|
-
# (C)
|
|
6
|
+
# (C)2006-2008 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
|
|
7
7
|
#
|
|
8
8
|
|
|
9
|
-
require 'dokkit'
|
|
10
|
-
require 'dokkit/
|
|
9
|
+
require 'dokkit/filters/nil'
|
|
10
|
+
require 'dokkit/filters/deplate'
|
|
11
|
+
require 'dokkit/filters/maruku'
|
|
11
12
|
|
|
12
|
-
module Dokkit
|
|
13
|
-
module Filters
|
|
14
|
-
@filters = { }
|
|
15
|
-
@logger = Log::ConsoleLog.consolelog
|
|
16
|
-
def Filters.register(name, &blk)
|
|
17
|
-
@filters[name] = blk
|
|
18
|
-
end
|
|
19
|
-
def Filters.[](name)
|
|
20
|
-
filter = @filters[name]
|
|
21
|
-
if filter
|
|
22
|
-
@filters[name].call
|
|
23
|
-
else
|
|
24
|
-
@logger.error("Filter '#{name}' is not defined!")
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
def Filters.filters
|
|
28
|
-
return @filters
|
|
29
|
-
end
|
|
30
|
-
def Filters.clean
|
|
31
|
-
@filters = { }
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
data/lib/dokkit/hash.rb
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#
|
|
2
|
+
# File 'hash.rb' created on 17 mar 2008 at 09:37:25.
|
|
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
|
+
class Symbol
|
|
10
|
+
def include_clear?
|
|
11
|
+
nil
|
|
12
|
+
end
|
|
13
|
+
def delete_clear
|
|
14
|
+
nil
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class String
|
|
19
|
+
def include_clear?
|
|
20
|
+
self == 'clear'
|
|
21
|
+
end
|
|
22
|
+
def delete_clear
|
|
23
|
+
nil
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class Array
|
|
28
|
+
def include_clear?
|
|
29
|
+
include?('clear')
|
|
30
|
+
end
|
|
31
|
+
def delete_clear
|
|
32
|
+
delete('clear')
|
|
33
|
+
self
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
class Hash
|
|
38
|
+
# Hash#recursive_merge merges two arbitrarily deep hashes into a single hash.
|
|
39
|
+
# The hash is followed recursively, so that deeply nested hashes that are at
|
|
40
|
+
# the same level will be merged when the parent hashes are merged.
|
|
41
|
+
def recursive_merge!(other_hash, &blk)
|
|
42
|
+
if block_given?
|
|
43
|
+
merge!(other_hash, &blk)
|
|
44
|
+
else
|
|
45
|
+
merge!(other_hash) do |key, value, other_value|
|
|
46
|
+
recursive_store(key, value, other_value)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
# Non-destructive version of Hash#recursive_merge method.
|
|
51
|
+
def recursive_merge(other_hash, &blk)
|
|
52
|
+
dup.recursive_merge!(other_hash, &blk)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
def merge_value(value, other_value, &blk)
|
|
58
|
+
unless other_value.include_clear?
|
|
59
|
+
yield value, other_value
|
|
60
|
+
else
|
|
61
|
+
value = other_value.delete_clear
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def recursive_store(key, value, other_value)
|
|
66
|
+
if(value.class == Hash && other_value.class == Hash)
|
|
67
|
+
value.recursive_merge other_value
|
|
68
|
+
elsif(value.class == String && other_value.class == String)
|
|
69
|
+
merge_value(value, other_value) { |v, ov| v = ov }
|
|
70
|
+
elsif(value.class == Symbol && other_value.class == String)
|
|
71
|
+
merge_value(value, other_value) { |v, ov| v = ov }
|
|
72
|
+
elsif(value.class == Array && other_value.class == Array)
|
|
73
|
+
merge_value(value, other_value) { |v, ov| v.concat ov }
|
|
74
|
+
elsif(value.class == String && other_value.class == Array)
|
|
75
|
+
merge_value(value, other_value) { |v, ov| v.to_a.concat ov }
|
|
76
|
+
elsif(value.class == Array && other_value.class == String)
|
|
77
|
+
merge_value(value, other_value) { value << other_value }
|
|
78
|
+
else
|
|
79
|
+
store(key, other_value)
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -9,65 +9,71 @@
|
|
|
9
9
|
#require 'dokkit'
|
|
10
10
|
|
|
11
11
|
module Dokkit
|
|
12
|
-
module
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
INFO =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
attr_reader :text
|
|
19
|
-
attr_reader :level
|
|
20
|
-
def initialize(text, level)
|
|
21
|
-
@text, @level = text, level
|
|
22
|
-
end
|
|
23
|
-
end
|
|
12
|
+
module Logging
|
|
13
|
+
|
|
14
|
+
# Define logger constants.
|
|
15
|
+
OFF, ERROR, WARNING, INFO, DEBUG = (-1..3).to_a
|
|
16
|
+
|
|
17
|
+
# Logger instance send log message to all its attached observers.
|
|
24
18
|
class Logger
|
|
25
|
-
|
|
26
|
-
def logger
|
|
27
|
-
@logger ||= Logger.new
|
|
28
|
-
end
|
|
29
|
-
def clear
|
|
30
|
-
@logger = nil
|
|
31
|
-
end
|
|
32
|
-
end
|
|
19
|
+
|
|
33
20
|
attr_reader :observers
|
|
34
21
|
attr_reader :last_message
|
|
35
22
|
attr_reader :level
|
|
23
|
+
|
|
36
24
|
def initialize
|
|
37
25
|
@observers = []
|
|
38
26
|
@level = INFO
|
|
39
27
|
end
|
|
28
|
+
|
|
29
|
+
# Set the logging level.
|
|
40
30
|
def level=(new_level)
|
|
41
|
-
new_level =
|
|
42
|
-
new_level =
|
|
31
|
+
new_level = DEBUG if new_level > DEBUG
|
|
32
|
+
new_level = OFF if new_level < ERROR
|
|
43
33
|
@level = new_level
|
|
44
34
|
end
|
|
35
|
+
|
|
36
|
+
# Attach an observer to the logger instance.
|
|
45
37
|
def attach(observer)
|
|
46
38
|
(@observers << observer).last
|
|
47
39
|
end
|
|
40
|
+
|
|
41
|
+
# Detach the observer from the logger instance.
|
|
48
42
|
def detach(observer)
|
|
49
43
|
@observers.delete(observer)
|
|
50
44
|
end
|
|
45
|
+
|
|
46
|
+
# Notify log messages to all attached observers.
|
|
51
47
|
def notify
|
|
52
48
|
@observers.each { |observer| observer.update }
|
|
53
49
|
end
|
|
50
|
+
|
|
54
51
|
def message(message)
|
|
55
52
|
@last_message = message
|
|
56
53
|
notify
|
|
57
54
|
@last_message
|
|
58
55
|
end
|
|
56
|
+
|
|
57
|
+
# Send an info message to observers.
|
|
59
58
|
def info(text)
|
|
60
|
-
message({ :text => text, :level =>
|
|
59
|
+
message({ :text => text, :level => INFO }) if level >= INFO
|
|
61
60
|
end
|
|
61
|
+
|
|
62
|
+
# Send an error message to the observers.
|
|
62
63
|
def error(text)
|
|
63
64
|
message({ :text => text, :level => ERROR }) if level >= ERROR
|
|
64
65
|
end
|
|
66
|
+
|
|
67
|
+
# Send a warning message to the observers.
|
|
65
68
|
def warn(text)
|
|
66
69
|
message({ :text => text, :level => WARNING }) if level >= WARNING
|
|
67
70
|
end
|
|
71
|
+
|
|
72
|
+
# Send a debug message to the observers.
|
|
68
73
|
def debug(text)
|
|
69
|
-
message({ :text => text, :level =>
|
|
74
|
+
message({ :text => text, :level => DEBUG }) if level >= DEBUG
|
|
70
75
|
end
|
|
76
|
+
|
|
71
77
|
end
|
|
72
78
|
end
|
|
73
79
|
end
|