dokkit 0.2.0 → 0.3.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.
Files changed (178) hide show
  1. data/History.txt +4 -0
  2. data/Manifest.txt +125 -0
  3. data/README.txt +53 -0
  4. data/Rakefile +25 -167
  5. data/bin/dokkit +4 -60
  6. data/lib/dokkit/app.rb +63 -192
  7. data/lib/dokkit/builtintask.rb +85 -0
  8. data/lib/dokkit/cachemanager.rb +61 -0
  9. data/lib/dokkit/cleantask.rb +51 -0
  10. data/lib/dokkit/consolelog.rb +42 -0
  11. data/lib/dokkit/defaults.rb +19 -0
  12. data/lib/dokkit/document.rb +221 -0
  13. data/lib/dokkit/dokkitlib.rb +68 -0
  14. data/lib/dokkit/extension/extension.rb +15 -0
  15. data/lib/dokkit/extension/filehelper.rb +25 -0
  16. data/lib/dokkit/fileselection.rb +44 -0
  17. data/lib/dokkit/filters/all.rb +18 -0
  18. data/lib/dokkit/filters/base.rb +18 -0
  19. data/lib/dokkit/filters/deplate.rb +21 -25
  20. data/lib/dokkit/filters/maruku.rb +23 -0
  21. data/lib/dokkit/filters/nil.rb +23 -0
  22. data/lib/dokkit/filters.rb +29 -21
  23. data/lib/dokkit/logger.rb +73 -0
  24. data/lib/dokkit/model.rb +34 -0
  25. data/lib/dokkit/models/{Rakefile.tpl → simpledocument/model/Rakefile} +15 -2
  26. data/lib/dokkit/models/simpledocument/model/doc/configs/simpledocument.yaml +3 -0
  27. data/lib/dokkit/models/simpledocument/model/doc/layouts/simpledocument.html +9 -0
  28. data/lib/dokkit/models/simpledocument/model/doc/layouts/simpledocument.latex +8 -0
  29. data/lib/dokkit/models/simpledocument/model/doc/layouts/simpledocument.text +1 -0
  30. data/lib/dokkit/models/simpledocument/model/doc/pages/simpledocument.deplate +102 -0
  31. data/lib/dokkit/models/simpledocument/model/tasks/all.rb +3 -0
  32. data/lib/dokkit/models/simpledocument/model/tasks/clean.rake +3 -0
  33. data/lib/dokkit/models/simpledocument/model/tasks/render.rake +8 -0
  34. data/lib/dokkit/models/simpledocument/model/tasks/setup.rb +9 -0
  35. data/lib/dokkit/modeltask.rb +83 -0
  36. data/lib/dokkit/pathhelper.rb +46 -0
  37. data/lib/dokkit/recursivemerge.rb +59 -0
  38. data/lib/dokkit/rendertask.rb +101 -0
  39. data/lib/dokkit/resourcemanager.rb +177 -0
  40. data/lib/dokkit/taskconfig.rb +39 -0
  41. data/lib/dokkit/templatetask.rb +37 -0
  42. data/lib/dokkit.rb +2 -8
  43. data/spec/app_spec.rb +55 -0
  44. data/spec/builtintask_spec.rb +114 -0
  45. data/spec/cachemanager_spec.rb +107 -0
  46. data/spec/cleantask_spec.rb +72 -0
  47. data/spec/consolelog_spec.rb +69 -0
  48. data/{tests/data/projects/simple-document → spec/data/test_build}/Rakefile +8 -8
  49. data/spec/data/test_build/doc/configs/document_1.yaml +3 -0
  50. data/spec/data/test_build/doc/configs/required.yaml +3 -0
  51. data/spec/data/test_build/doc/configs/subdir/document_4.yaml +3 -0
  52. data/spec/data/test_build/doc/layouts/document_1.html +9 -0
  53. data/spec/data/test_build/doc/layouts/document_1.latex +8 -0
  54. data/spec/data/test_build/doc/layouts/document_with_partials.html +9 -0
  55. data/spec/data/test_build/doc/layouts/layout +0 -0
  56. data/spec/data/test_build/doc/layouts/layout.html +8 -0
  57. data/spec/data/test_build/doc/layouts/layout.html.backup +8 -0
  58. data/spec/data/test_build/doc/layouts/nested.html +3 -0
  59. data/spec/data/test_build/doc/layouts/partials/partial.html +4 -0
  60. data/spec/data/test_build/doc/pages/COMMON.yaml +6 -0
  61. data/spec/data/test_build/doc/pages/document_1 +20 -0
  62. data/spec/data/test_build/doc/pages/document_1.dep +4 -0
  63. data/spec/data/test_build/doc/pages/document_1.yaml +11 -0
  64. data/spec/data/test_build/doc/pages/document_2 +9 -0
  65. data/spec/data/test_build/doc/pages/document_2.dep +0 -0
  66. data/spec/data/test_build/doc/pages/document_2.yaml +6 -0
  67. data/spec/data/test_build/doc/pages/document_3 +13 -0
  68. data/spec/data/test_build/doc/pages/document_5.exclude +0 -0
  69. data/spec/data/test_build/doc/pages/document_7 +4 -0
  70. data/spec/data/test_build/doc/pages/document_7.yaml +5 -0
  71. data/spec/data/test_build/doc/pages/document_extended +1 -0
  72. data/spec/data/test_build/doc/pages/document_nested +6 -0
  73. data/spec/data/test_build/doc/pages/document_nested.yaml +5 -0
  74. data/spec/data/test_build/doc/pages/document_nolayout.ext +3 -0
  75. data/spec/data/test_build/doc/pages/document_nolayout.yaml +2 -0
  76. data/spec/data/test_build/doc/pages/document_with_partials +3 -0
  77. data/spec/data/test_build/doc/pages/document_with_partials.yaml +2 -0
  78. data/spec/data/test_build/doc/pages/partials/COMMON.yaml +5 -0
  79. data/spec/data/test_build/doc/pages/partials/circular_partial +2 -0
  80. data/spec/data/test_build/doc/pages/partials/circular_partial.yaml +3 -0
  81. data/spec/data/test_build/doc/pages/partials/partial +2 -0
  82. data/spec/data/test_build/doc/pages/subdir/COMMON.yaml +2 -0
  83. data/spec/data/test_build/doc/pages/subdir/document_4 +11 -0
  84. data/spec/data/test_build/doc/pages/subdir/subdir/COMMON.yaml +2 -0
  85. data/spec/data/test_build/doc/pages/subdir/subdir/document_6 +3 -0
  86. data/spec/data/test_build/tasks/all.rb +3 -0
  87. data/spec/data/test_build/tasks/clean.rake +3 -0
  88. data/spec/data/test_build/tasks/render.rake +8 -0
  89. data/spec/data/test_build/tasks/setup.rb +9 -0
  90. data/spec/data/test_build/tasks/template.rake +3 -0
  91. data/spec/data/test_build/templates/layouts/layout +0 -0
  92. data/spec/data/test_build/templates/pages/template +0 -0
  93. data/spec/document_spec.rb +321 -0
  94. data/spec/dokkitlib_spec.rb +63 -0
  95. data/spec/filehelper_spec.rb +34 -0
  96. data/spec/fileselection_spec.rb +101 -0
  97. data/spec/filter_base_spec.rb +29 -0
  98. data/spec/filter_deplate_spec.rb +48 -0
  99. data/spec/filter_maruku_spec.rb +29 -0
  100. data/spec/filter_nil_spec.rb +30 -0
  101. data/spec/filters_spec.rb +37 -0
  102. data/spec/logger_spec.rb +150 -0
  103. data/spec/model_spec.rb +45 -0
  104. data/spec/pathhelper_spec.rb +62 -0
  105. data/spec/recursivemerge_spec.rb +91 -0
  106. data/spec/rendertask_spec.rb +374 -0
  107. data/spec/spec_helper.rb +61 -0
  108. data/spec/taskconfig_spec.rb +45 -0
  109. data/spec/templatetask_spec.rb +72 -0
  110. data/tasks/annotations.rake +30 -0
  111. data/tasks/doc.rake +49 -0
  112. data/tasks/gem.rake +89 -0
  113. data/tasks/manifest.rake +41 -0
  114. data/tasks/rubyforge.rake +57 -0
  115. data/tasks/setup.rb +151 -0
  116. data/tasks/spec.rake +40 -0
  117. data/tasks/svn.rake +44 -0
  118. data/tasks/test.rake +40 -0
  119. metadata +188 -161
  120. data/CHANGES +0 -26
  121. data/LICENSE +0 -674
  122. data/README +0 -32
  123. data/lib/dokkit/#render_task_factory.rb# +0 -94
  124. data/lib/dokkit/dokkittasks.rb +0 -99
  125. data/lib/dokkit/hash.rb +0 -41
  126. data/lib/dokkit/models/share/builtin.rf +0 -28
  127. data/lib/dokkit/page.rb +0 -195
  128. data/lib/dokkit/render_task_factory.rb +0 -91
  129. data/tests/data/output/simple_document/README +0 -57
  130. data/tests/data/output/simple_document/Rakefile +0 -7
  131. data/tests/data/output/simple_document/doc/config/simple_document.yaml +0 -5
  132. data/tests/data/output/simple_document/doc/pages/simple_document.dpl +0 -12
  133. data/tests/data/output/website_project/README +0 -49
  134. data/tests/data/output/website_project/Rakefile +0 -82
  135. data/tests/data/output/website_project/doc/layouts/normal.thtml +0 -38
  136. data/tests/data/output/website_project/doc/pages/COMMON.rb +0 -9
  137. data/tests/data/output/website_project/doc/pages/deplate.dplhtml +0 -9
  138. data/tests/data/output/website_project/doc/pages/index.rb +0 -10
  139. data/tests/data/output/website_project/doc/pages/index.thtml +0 -12
  140. data/tests/data/output/website_project/doc/res/images/rote-tiny.png +0 -0
  141. data/tests/data/projects/simple-document/README +0 -57
  142. data/tests/data/projects/simple-document/doc/config/author.yaml +0 -4
  143. data/tests/data/projects/simple-document/doc/config/model.yaml +0 -18
  144. data/tests/data/projects/simple-document/doc/config/simple_document.yaml +0 -6
  145. data/tests/data/projects/simple-document/doc/layouts/another_simple_document.html +0 -8
  146. data/tests/data/projects/simple-document/doc/layouts/another_simple_document.tex +0 -10
  147. data/tests/data/projects/simple-document/doc/layouts/layout_with_custom_name.html +0 -8
  148. data/tests/data/projects/simple-document/doc/layouts/semantic.cache +0 -23
  149. data/tests/data/projects/simple-document/doc/pages/COMMON.yaml +0 -23
  150. data/tests/data/projects/simple-document/doc/pages/another_simple_document.dpl +0 -12
  151. data/tests/data/projects/simple-document/doc/pages/simple_document.dpl +0 -12
  152. data/tests/data/projects/simple-document/doc/pages/simple_document_without_layout.dpl +0 -12
  153. data/tests/data/projects/simple-document/doc/pages/subdir/COMMON.yaml +0 -4
  154. data/tests/data/projects/simple-document/doc/pages/subdir/simple_document_in_subdir.dpl +0 -12
  155. data/tests/data/projects/simple-document/doc/pages/subdir/simple_document_in_subdir.yaml +0 -3
  156. data/tests/data/projects/simple-document/doc/pages/subdir/subdir/COMMON.yaml +0 -2
  157. data/tests/data/projects/simple-document/doc/pages/subdir/subdir/another_simple_document_in_subdir.dpl +0 -12
  158. data/tests/data/projects/simple-document/doc/pages/yet_another_simple_document.dpl +0 -12
  159. data/tests/data/projects/simple-document/doc/pages/yet_another_simple_document.yaml +0 -8
  160. data/tests/gem_tests.rb +0 -4
  161. data/tests/spec_page.rb +0 -25
  162. data/tests/test.rb +0 -2
  163. data/tests/test_application.rb +0 -40
  164. data/tests/test_builtin_tasks.rb +0 -37
  165. data/tests/test_config.rb +0 -108
  166. data/tests/test_core.rb +0 -12
  167. data/tests/test_dokkit_commandline.rb +0 -18
  168. data/tests/test_exception.rb +0 -7
  169. data/tests/test_filters.rb +0 -46
  170. data/tests/test_layout.rb +0 -64
  171. data/tests/test_options.rb +0 -33
  172. data/tests/test_project_tasks.rb +0 -48
  173. data/tests/test_recursive_merge.rb +0 -42
  174. data/tests/test_task_factory.rb +0 -38
  175. /data/{CONTRIBUTORS → lib/dokkit/models/simpledocument/model/doc/data/css/style.css} +0 -0
  176. /data/{DONE → spec/data/test_build/doc/data/resource} +0 -0
  177. /data/{TODO → spec/data/test_build/doc/data/resource.exclude} +0 -0
  178. /data/{tests/pages/test.dpltex → spec/data/test_build/doc/data/subdir/resource.insubdir} +0 -0
data/README DELETED
@@ -1,32 +0,0 @@
1
- = WHAT'S dokkit?
2
-
3
- +dokkit+ is an open source documentation environment based on
4
- ruby.
5
-
6
- +dokkit+ puts together the flexibility of +rote+ and the great
7
- variety of +deplate+'s output formats.
8
-
9
- With +dokkit+ you can:
10
-
11
- * generate many types of documentation in many formats (html, tex,
12
- docbook, plain text, etc.)
13
- * write your documents using a simple wiki syntax (emacs-wiki like)
14
- * generate different output formats from the same source document
15
- * use a big set of models to quickly generate the documents you want (technical report, invoice, howto,
16
- guides, presentation, website, etc.)
17
- * simply derive new document models from the existing ones
18
- * simply modify existing models to fit your needs
19
-
20
- +dokkit+'s success keys are:
21
-
22
- * a smart task system based on +rake+ a consistent documentation
23
- per-model framework organized in templates, layouts, ruby classes,
24
- configuration files, resources based on +rote+
25
- * a powerful templating system based on +erb+
26
- * a simple and flexible configuration system based on +yaml+
27
-
28
- +dokkit+ aims to be modular and extensible: you can easily add
29
- new filters, formatters and document models.
30
-
31
- See http://dokkit.rubyforge.org for further information.
32
-
@@ -1,94 +0,0 @@
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
- def create_render_pdf
90
- Rake::Task.new
91
- end
92
- end
93
- end
94
-
@@ -1,99 +0,0 @@
1
- #
2
- # File 'dokkittasks.rb' created on 09 ott 2007 at 17:08:49.
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
- # Rake tasklib for Dokkit.
9
-
10
- require 'rote/rotetasks.rb'
11
- require 'dokkit/page'
12
- require 'dokkit/hash'
13
-
14
- module Rote
15
-
16
- class DocTask
17
-
18
- # Base directories used by the task.
19
- attr_accessor :config_dir
20
- attr_accessor :config_page
21
- attr_accessor :layout_defext
22
-
23
- def initialize(name = :doc) # :yield: self if block_given?
24
- @name = name
25
- @config_page = { }
26
- @output_dir = '.'
27
- @pages = FilePatterns.new('.')
28
- @res = FilePatterns.new('.')
29
- @monitor_interval = 1
30
- @ext_mappings = ExtHash.new
31
- @show_page_tasks = false
32
-
33
- DEFAULT_SRC_EXCLUDES.each { |excl| @pages.exclude(excl) }
34
-
35
- yield self if block_given?
36
-
37
- @config_page = {
38
- :layout_dir => layout_dir,
39
- :config_dir => config_dir,
40
- :pages_dir => pages.dir,
41
- :layout_defext => layout_defext
42
- }
43
-
44
- define
45
- end
46
-
47
- # define a task for each page, and 'all pages' task
48
- def define_page_tasks
49
- pages_fl = pages.to_filelist
50
-
51
- gen_files = pages_fl.select { |fn| not File.directory?(fn) }.map do |fn|
52
- tfn, blk = target_fn(/^#{pages.dir}/, fn)
53
-
54
- desc "#{fn} => #{tfn}" #if show_file_tasks?
55
- file tfn => [fn] do
56
- dn = File.dirname(tfn)
57
- mkdir_p dn unless File.exists?(dn)
58
- puts "tr #{fn} => #{tfn}"
59
- begin
60
- File.open(tfn, 'w+') do |f|
61
- # new page, run extension block, render out, throw away
62
- f << Page.new( {:fn => fn}.merge(config_page), &blk).render
63
- end
64
- rescue => e
65
- # Oops... Unlink file and dump backtrace
66
- File.unlink(tfn)
67
- bt = e.backtrace
68
- end_idx = bt.each_with_index do |entry, idx|
69
- break idx if entry =~ /^#{File.dirname(__FILE__)}/
70
- end
71
- puts bt[0...end_idx]
72
- raise
73
- end
74
- end
75
-
76
- # Each page depends properly on source and common - thx again
77
- # Jonathan :)
78
- src_rb = Page::page_ruby_filename(fn)
79
- if File.exists?(src_rb)
80
- file tfn => [src_rb]
81
- end
82
-
83
- common_rbs = Page::resolve_common_rubys(File.dirname(fn))
84
- file tfn => common_rbs unless common_rbs.empty?
85
-
86
- tfn
87
- end
88
-
89
- desc "Render new/changed documentation pages"
90
- task "#{name}_pages" => gen_files
91
- task "clobber_#{name}_pages" do
92
- gen_files.each do |f|
93
- rm_f f
94
- end
95
- end
96
- end
97
-
98
- end
99
- end
data/lib/dokkit/hash.rb DELETED
@@ -1,41 +0,0 @@
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
-
@@ -1,28 +0,0 @@
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 DELETED
@@ -1,195 +0,0 @@
1
- #
2
- # File 'page.rb' created on 09 ott 2007 at 15:56:08.
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 '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
23
-
24
- module DokkitPage
25
-
26
- # The base path for config resolution
27
- attr_reader :config_path
28
-
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')
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
42
-
43
- def load_configs
44
- @config_files.each { |fn| load_config(fn) }
45
- @config
46
- end
47
-
48
- def load_config(fn)
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
64
- end
65
- end
66
-
67
- def config_fn(fn)
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
97
- end
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
-
105
- end
106
-
107
- module Rote
108
-
109
- class Page
110
-
111
- include DokkitPage
112
-
113
- track_methods
114
- alias page_initialize initialize
115
-
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
178
- end
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
195
- end
@@ -1,91 +0,0 @@
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
-
@@ -1,57 +0,0 @@
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
-
@@ -1,7 +0,0 @@
1
- # Rakefile for simple_document project model
2
-
3
- require 'dokkit'
4
- require 'dokkit/app'
5
- import File.join(Dokkit.projects_dir,"simple_document","lib/rakefile.rf")
6
-
7
-
@@ -1,5 +0,0 @@
1
- title: A Simple Document
2
- author: John Doe
3
-
4
-
5
-
@@ -1,12 +0,0 @@
1
- * Abstract
2
- From a document of Jim{cite: author:jim}
3
-
4
- * Introduction
5
-
6
- * Main section
7
-
8
- ** Subsection One
9
- ** Subsection Two
10
-
11
- * Conclusions
12
-