dokkit 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. data/CHANGES +15 -1
  2. data/LICENSE +673 -19
  3. data/README +32 -0
  4. data/Rakefile +59 -25
  5. data/bin/dokkit +48 -38
  6. data/lib/dokkit/#render_task_factory.rb# +94 -0
  7. data/lib/dokkit/app.rb +212 -257
  8. data/lib/dokkit/deplate/fmt/latex-notemplate.rb +3 -1
  9. data/lib/dokkit/dokkittasks.rb +45 -15
  10. data/lib/dokkit/filters/deplate.rb +11 -5
  11. data/lib/dokkit/hash.rb +41 -0
  12. data/lib/dokkit/models/Rakefile.tpl +9 -0
  13. data/lib/dokkit/models/share/builtin.rf +28 -0
  14. data/lib/dokkit/page.rb +161 -20
  15. data/lib/dokkit/render_task_factory.rb +91 -0
  16. data/lib/dokkit.rb +35 -42
  17. data/tests/data/output/simple_document/README +57 -0
  18. data/tests/data/output/simple_document/Rakefile +7 -0
  19. data/tests/data/output/simple_document/doc/config/simple_document.yaml +5 -0
  20. data/tests/data/output/simple_document/doc/pages/simple_document.dpl +12 -0
  21. data/{lib/dokkit/projects/website → tests/data/output/website_project}/Rakefile +2 -1
  22. data/tests/data/projects/simple-document/README +57 -0
  23. data/tests/data/projects/simple-document/Rakefile +22 -0
  24. data/tests/data/projects/simple-document/doc/config/author.yaml +4 -0
  25. data/tests/data/projects/simple-document/doc/config/model.yaml +18 -0
  26. data/tests/data/projects/simple-document/doc/config/simple_document.yaml +6 -0
  27. data/tests/data/projects/simple-document/doc/layouts/another_simple_document.html +8 -0
  28. data/tests/data/projects/simple-document/doc/layouts/another_simple_document.tex +10 -0
  29. data/tests/data/projects/simple-document/doc/layouts/layout_with_custom_name.html +8 -0
  30. data/tests/data/projects/simple-document/doc/layouts/semantic.cache +23 -0
  31. data/tests/data/projects/simple-document/doc/pages/COMMON.yaml +23 -0
  32. data/tests/data/projects/simple-document/doc/pages/another_simple_document.dpl +12 -0
  33. data/tests/data/projects/simple-document/doc/pages/simple_document.dpl +12 -0
  34. data/tests/data/projects/simple-document/doc/pages/simple_document_without_layout.dpl +12 -0
  35. data/tests/data/projects/simple-document/doc/pages/subdir/COMMON.yaml +4 -0
  36. data/tests/data/projects/simple-document/doc/pages/subdir/simple_document_in_subdir.dpl +12 -0
  37. data/tests/data/projects/simple-document/doc/pages/subdir/simple_document_in_subdir.yaml +3 -0
  38. data/tests/data/projects/simple-document/doc/pages/subdir/subdir/COMMON.yaml +2 -0
  39. data/tests/data/projects/simple-document/doc/pages/subdir/subdir/another_simple_document_in_subdir.dpl +12 -0
  40. data/tests/data/projects/simple-document/doc/pages/yet_another_simple_document.dpl +12 -0
  41. data/tests/data/projects/simple-document/doc/pages/yet_another_simple_document.yaml +8 -0
  42. data/tests/spec_page.rb +25 -0
  43. data/tests/test.rb +2 -0
  44. data/tests/test_application.rb +40 -0
  45. data/tests/test_builtin_tasks.rb +37 -0
  46. data/tests/test_config.rb +108 -0
  47. data/tests/test_core.rb +12 -0
  48. data/tests/test_dokkit_commandline.rb +18 -0
  49. data/tests/test_exception.rb +7 -0
  50. data/tests/test_filters.rb +1 -1
  51. data/tests/test_layout.rb +64 -0
  52. data/tests/test_options.rb +33 -0
  53. data/tests/test_project_tasks.rb +48 -0
  54. data/tests/test_recursive_merge.rb +42 -0
  55. data/tests/test_task_factory.rb +38 -0
  56. metadata +138 -94
  57. data/Rakefile.old +0 -62
  58. data/lib/dokkit/builtin.rake +0 -55
  59. data/lib/dokkit/projects/invoice/Rakefile +0 -100
  60. data/lib/dokkit/projects/invoice/doc/config/company.yaml +0 -12
  61. data/lib/dokkit/projects/invoice/doc/config/customer.yaml +0 -4
  62. data/lib/dokkit/projects/invoice/doc/layouts/invoice.dpltex +0 -90
  63. data/lib/dokkit/projects/invoice/doc/pages/COMMON.rb +0 -12
  64. data/lib/dokkit/projects/invoice/doc/pages/invoice.rb +0 -5
  65. data/lib/dokkit/projects/invoice/doc/pages/invoice.yamltex +0 -16
  66. data/lib/dokkit/projects/invoice/doc/res/tex/deplate.sty +0 -46
  67. data/lib/dokkit/projects/invoice/doc/res/tex/images/logo.eps +0 -209
  68. data/lib/dokkit/projects/invoice/doc/res/tex/include/deplate.sty +0 -46
  69. data/lib/dokkit/projects/invoice/doc/res/tex/include/layout.inc +0 -24
  70. data/lib/dokkit/projects/invoice/doc/res/tex/include/macro.inc +0 -67
  71. data/lib/dokkit/projects/invoice/doc/res/tex/include/packages.inc +0 -51
  72. data/lib/dokkit/projects/invoice/lib/invoice.rb +0 -104
  73. data/lib/dokkit/projects/tech_report/README +0 -49
  74. data/lib/dokkit/projects/tech_report/Rakefile +0 -102
  75. data/lib/dokkit/projects/tech_report/doc/config/company.yaml +0 -13
  76. data/lib/dokkit/projects/tech_report/doc/config/tech_report.yaml +0 -3
  77. data/lib/dokkit/projects/tech_report/doc/layouts/report.dpltex +0 -40
  78. data/lib/dokkit/projects/tech_report/doc/pages/COMMON.rb +0 -12
  79. data/lib/dokkit/projects/tech_report/doc/pages/report.dpltex +0 -37
  80. data/lib/dokkit/projects/tech_report/doc/pages/report.inc +0 -2
  81. data/lib/dokkit/projects/tech_report/doc/pages/report.rb +0 -3
  82. data/lib/dokkit/projects/tech_report/doc/res/attachments/attachment_2 +0 -0
  83. data/lib/dokkit/projects/tech_report/doc/res/tex/images/logo.eps +0 -311
  84. data/lib/dokkit/projects/tech_report/doc/res/tex/include/deplate.sty +0 -46
  85. data/lib/dokkit/projects/tech_report/doc/res/tex/include/layout.inc +0 -24
  86. data/lib/dokkit/projects/tech_report/doc/res/tex/include/macro.inc +0 -67
  87. data/lib/dokkit/projects/tech_report/doc/res/tex/include/packages.inc +0 -48
  88. data/lib/dokkit/projects/tech_report/doc/res/tex/report.bib +0 -4
  89. data/lib/dokkit/projects/tech_report/lib/tech_report.rb +0 -17
  90. data/lib/dokkit/projects/website/README +0 -49
  91. /data/{lib/dokkit/projects/invoice → tests/data/output/website_project}/README +0 -0
  92. /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/layouts/normal.thtml +0 -0
  93. /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/pages/COMMON.rb +0 -0
  94. /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/pages/deplate.dplhtml +0 -0
  95. /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/pages/index.rb +0 -0
  96. /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/pages/index.thtml +0 -0
  97. /data/{lib/dokkit/projects/website → tests/data/output/website_project}/doc/res/images/rote-tiny.png +0 -0
  98. /data/{lib/dokkit/projects/tech_report/doc/res/attachments/attachment_1 → tests/pages/test.dpltex} +0 -0
data/lib/dokkit/app.rb CHANGED
@@ -1,305 +1,260 @@
1
- # Dokkit application class
2
- # (c)2006 Andrea Fazzi (and contributors)
1
+ #
2
+ # File 'app.rb' created on 09 ott 2007 at 16:00:28.
3
3
  #
4
- # See 'dokkit.rb' or LICENSE for licence information.
4
+ # See 'dokkit.rb' or +LICENSE+ for licence information.
5
+ #
6
+ # (C) 2006, 2007 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
7
+ #
5
8
 
6
9
  require 'optparse'
7
10
  require 'rake'
8
11
 
9
- DEFAULT_PROJECT_MODEL = "tech_report"
10
-
11
- module Rake
12
-
13
- class Application
14
-
15
- def do_option(opt, value)
16
- case opt
17
- when '--directory'
18
- Dir.chdir( File.expand_path(value) )
19
- options.directory = true
20
- when '--dry-run'
21
- verbose(true)
22
- nowrite(true)
23
- options.dryrun = true
24
- options.trace = true
25
- when '--help'
26
- help
27
- exit
28
- when '--libdir'
29
- $:.push(value)
30
- when '--nosearch'
31
- options.nosearch = true
32
- when '--prereqs'
33
- options.show_prereqs = true
34
- when '--quiet'
35
- verbose(false)
36
- when '--rakefile'
37
- RAKEFILES.clear
38
- RAKEFILES << value
39
- when '--rakelibdir'
40
- options.rakelib = value.split(':')
41
- when '--require'
42
- begin
43
- require value
44
- rescue LoadError => ex
45
- begin
46
- rake_require value
47
- rescue LoadError => ex2
48
- raise ex
12
+ module Dokkit
13
+ # The path from where to copy the model structure.
14
+ MODEL_PATH = 'lib/model'
15
+ # The path from which to load the built-in layout of the model.
16
+ MODEL_LAYOUT_PATH = 'lib/doc/layouts'
17
+ # The path from which to load the built-in config of the model.
18
+ MODEL_CONFIG_PATH = 'lib/doc/config'
19
+ # Dokkit module singleton methods.
20
+ class << self
21
+ # Current Dokkit Application
22
+ def application
23
+ @application ||= Dokkit::Application.new(dokkit_lib)
24
+ end
25
+ # Set the current Rake application object.
26
+ def application=(app)
27
+ @application = app
28
+ end
29
+ # Return the original directory where the Dokkit application was started.
30
+ def original_dir
31
+ application.original_dir
32
+ end
33
+ def dokkit_lib
34
+ lib = nil
35
+ unless lib = ENV['DOKKIT_LIB']
36
+ $:.each do |it|
37
+ if File.exists?(File.join(it,'dokkit/dokkittasks.rb'))
38
+ lib = it
39
+ break
49
40
  end
50
41
  end
51
- when '--silent'
52
- verbose(false)
53
- options.silent = true
54
- when '--tasks'
55
- options.show_tasks = true
56
- options.show_task_pattern = Regexp.new(value || '.')
57
- when '--trace'
58
- options.trace = true
59
- verbose(true)
60
- when '--usage'
61
- usage
62
- exit
63
- when '--verbose'
64
- verbose(true)
65
- when '--version'
66
- puts "rake, version #{RAKEVERSION}"
67
- exit
68
- when '--classic-namespace'
69
- require 'rake/classic_namespace'
70
- options.classic_namespace = true
71
- else
72
- fail "Unknown option: #{opt}"
73
42
  end
43
+ lib
74
44
  end
75
-
76
- def handle_options
77
- options.rakelib ||= 'rakelib'
78
- options.each { |opt, value| do_option(opt, value) }
45
+ # Return the directory containing models related files.
46
+ def projects_dir
47
+ File.join(dokkit_lib, 'dokkit', 'models')
79
48
  end
80
-
81
- def display_tasks_and_comments
82
- displayable_tasks = Rake::Task.tasks.select { |t|
83
- t.comment && t.name =~ options.show_task_pattern
84
- }
85
- width = displayable_tasks.collect { |t|
86
- t.name.length
87
- }.max
88
- displayable_tasks.each do |t|
89
- printf "dokkit %-#{width}s # %s\n", t.name, t.comment
49
+
50
+ def fetch_models
51
+ models = { }
52
+ Dir["#{Gem.dir}/gems/dokkit-model-*"].each do |path|
53
+ path.scan(/dokkit-model-(.+)-(\d\.\d\.\d)/) { models[$1] = path }
54
+ end
55
+ Dir["#{File.expand_path("~/.dokkit/models/*")}"].each do |path|
56
+ path.scan(/.dokkit\/models\/(.+)/) { models[$1] = path }
90
57
  end
58
+ models
91
59
  end
92
-
93
- # Search for a Rakefile
94
- def search_for_rakefile
95
- initial_dir = here = Dir.pwd
96
- while ! have_rakefile
97
- Dir.chdir("..")
98
- if Dir.pwd == here
99
- Dir.chdir(initial_dir)
100
- return false
101
- end
102
- here = Dir.pwd
103
- end
104
- return true
60
+ # Return the full path from where to copy the model.
61
+ def model_dir(model)
62
+ File.join(fetch_models[model], MODEL_PATH)
63
+ end
64
+ # Return the full path from where to copy the model.
65
+ def model_layout_dir(model)
66
+ File.join(fetch_models[model], MODEL_LAYOUT_PATH)
67
+ end
68
+ # Return the full path from where to copy the model.
69
+ def model_config_dir(model)
70
+ File.join(fetch_models[model], MODEL_CONFIG_PATH)
71
+ end
72
+ # Return the directory containing the tests
73
+ def tests_dir
74
+ File.expand_path(File.join(dokkit_lib, '..', 'tests'))
105
75
  end
106
-
107
76
  end
108
77
 
109
- end
110
-
111
- module Dokkit
112
-
113
78
  # Command-line launcher for Dokkit.
114
79
  class Application
115
80
 
116
81
  attr_accessor :dokkit_lib
117
- attr_accessor :debug
118
- attr_accessor :tasks
119
- attr_accessor :trace
120
- attr_accessor :usage
121
- attr_accessor :version
122
- attr_accessor :rake
123
- attr_accessor :rakefile
124
- attr_accessor :rakeopts
125
- attr_accessor :rake_env
126
- attr_accessor :list_projects
82
+
83
+ DEFAULT_PROJECT_MODEL = "simpledocument"
84
+ USAGE_PREAMBLE = <<-EOU
85
+ Usage: dokkit [options] [task1] .. [taskN]
86
+
87
+ Where [taskN] is a valid task or target name for the current project.
88
+ Dokkit generates targets for each page source, and also defines a number
89
+ of top-level tasks for various things. Use the '--tasks' option to get
90
+ a list of valid tasks.
91
+
92
+ In addition to the standard render_XXX tasks and those provided by any
93
+ local configuration, the following 'special' tasks are recognised:
94
+
95
+ create <project> Create a blank project from the built-in template using the #{DEFAULT_PROJECT_MODEL} project model.
96
+
97
+ In non-standard environments, it may be necessary to set the DOKKIT_LIB
98
+ variable to point to the location of Dokkit libraries.
99
+
100
+ EOU
101
+ OPTIONS = [
102
+ [ "--usage", "-u", GetoptLong::NO_ARGUMENT,
103
+ "Display usage information." ],
104
+ [ "--help", "-h", GetoptLong::NO_ARGUMENT,
105
+ "Synonim for usage."],
106
+ [ "--project", "-P", GetoptLong::REQUIRED_ARGUMENT,
107
+ "Set the PROJECT model to create. Use --list for the full list of project models available."],
108
+ [ "--directory","-D", GetoptLong::REQUIRED_ARGUMENT,
109
+ "Change to directory DIR before reading the rakefiles or doing anything else."],
110
+ [ "--list", "-l", GetoptLong::NO_ARGUMENT,
111
+ "Display the list of the project models available." ],
112
+ [ "--version", "-V", GetoptLong::NO_ARGUMENT,
113
+ "Display the version number and quit." ],
114
+ [ "--trace", "-t", GetoptLong::NO_ARGUMENT,
115
+ "Enable trace-level output (debugging)"],
116
+ [ "--tasks", "-T", GetoptLong::NO_ARGUMENT,
117
+ "Display the list of the tasks available."],
118
+ [ "--nosearch", "-N", GetoptLong::NO_ARGUMENT,
119
+ "Do not search parent directories for the Rakefiles. Only builtin tasks can be invoked."]
120
+ ]
127
121
 
128
122
  @@project_dirs = nil
129
123
 
130
124
  # Create a new Application instance, processing command-line arguments,
131
- # optionally passing +self+ to the supplied block for further
125
+ # optionally passing +self+ to the supplied block for further
132
126
  # configuration.
133
-
134
127
  def initialize(dokkit_lib) # :yield: self if block_given?
135
128
  # init vars
136
- @@project_dirs = ($:.collect { |dir| File.join(dir,"dokkit/projects")}).concat(Array["~/.dokkit/projects"])
137
-
138
129
  @dokkit_lib = dokkit_lib
139
- @debug = false
140
- @tasks = false
141
- @trace = false
142
- @usage = false
143
- @version = false
144
- @list_projects = false
145
- @directory = false
146
- @rf = false
147
- @rakefile = "#{dokkit_lib}/dokkit/builtin.rake"
148
- raise "Missing builtin.rake (expected at '#{@rakefile}')!" unless File.exists?(@rakefile)
149
-
150
- @rakeopts = ENV['RAKE_OPTS'] || ''
151
- @rake_env = "PROJECT=#{@project}"
152
-
153
130
  ENV['PROJECT'] = @project = DEFAULT_PROJECT_MODEL
154
-
155
- @rake = Rake::Application.new
156
-
157
- process_args
158
-
159
131
  yield self if block_given?
160
132
  end
161
-
162
- # Gets the list of the directory to search into for project models
163
- def Application.get_project_dirs
164
- @@project_dirs
165
- end
133
+ # Application options from the command line
134
+ def options
135
+ @options ||= OpenStruct.new
136
+ end
137
+ # set an option
138
+ def do_option(opt,value)
139
+ case opt
140
+ when '--version'
141
+ options.version = true
142
+ print "dokkit, version #{DOKKITVERSION}\n"
143
+ exit
144
+ when '--directory'
145
+ options.directory = value
146
+ Dir.chdir(options.directory)
147
+ when '--tasks'
148
+ options.tasks = true
149
+ Rake.application.do_option('--tasks', nil)
150
+ when '--project'
151
+ ENV['PROJECT'] = @project = options.project = value
152
+ when '--list'
153
+ options.list_projects = true
154
+ Dokkit.fetch_models.each_key { |key| puts key }
155
+ exit
156
+ when '--usage'
157
+ options.usage = options.help = true
158
+ help
159
+ exit
160
+ when '--help'
161
+ options.usage = options.help = true
162
+ help
163
+ exit
164
+ when '--nosearch'
165
+ options.nosearch = true
166
+ Rake.application.do_option('--nosearch', nil)
167
+ when '--trace'
168
+ options.trace = true
169
+ Rake.application.do_option('--trace', nil)
170
+ end
171
+ end
166
172
 
167
- # Run the application with the current options.
168
- def run
173
+ def init
174
+ Rake.application.init('dokkit')
175
+ end
169
176
 
170
- @rake.do_option("--libdir",dokkit_lib)
177
+ def clear
178
+ Rake.application.clear
179
+ end
171
180
 
172
- if @version
173
- print "dokkit, version #{DOKKITVERSION}\n"
181
+ def load_rakefile
182
+ Rake.application.init('dokkit')
183
+ Rake.application.load_rakefile
184
+ end
185
+ def load_builtin
186
+ raise "#{@project} model not found!" unless model_dir = Dokkit.fetch_models[@project]
187
+ Dir["#{File.join(model_dir, 'lib/tasks/builtin')}/*.{rake,rf}"].each { |name| Rake.application.add_import name }
188
+ Rake.application.load_imports
189
+ end
190
+ def [](task_name)
191
+ Rake.application[task_name]
192
+ end
174
193
 
175
- elsif @tasks
176
- if @rake.search_for_rakefile
177
- @rake.do_option("--rakelibdir","#{dokkit_lib}/dokkit/")
178
- @rake.do_option("--tasks",nil)
179
- @rake.run
180
- else
181
- @rake.do_option("--tasks",nil)
182
- @rake.do_option("--rakefile","#{rakefile}")
183
- @rake.run
184
- end
185
- elsif @list_projects
186
- show_all_projects
187
- elsif @usage
188
- show_usage()
189
- else
190
- if @trace
191
- @rake.do_option("--trace",nil)
192
- elsif @debug
193
- @rake.do_option("--verbose",nil)
194
- elsif @rf
195
- @rake.do_option("--rakefile",@rf)
196
- elsif @directory
197
- @rake.do_option("--directory",@directory)
198
- elsif @project
199
- ENV['PROJECT'] = @project
194
+ def task_defined?(task)
195
+ Rake.application.task_defined?(task)
196
+ end
197
+ # check if a Rakefile exists in the current directory or in any parent directory.
198
+ def have_rakefile
199
+ Rake.application.have_rakefile
200
+ end
201
+ # search for a Rakefile in the current directory and in all parent directory.
202
+ def search_for_rakefile
203
+ initial_dir = here = Dir.pwd
204
+ while ! have_rakefile
205
+ Dir.chdir("..")
206
+ if Dir.pwd == here || options.nosearch
207
+ Dir.chdir(initial_dir)
208
+ return false
200
209
  end
201
-
202
- if @rake.search_for_rakefile
203
- @rake.do_option("--rakelibdir","#{dokkit_lib}/dokkit/")
204
- else
205
- @rake.do_option("--rakefile","#{rakefile}")
210
+ here = Dir.pwd
211
+ end
212
+ Dir.chdir(initial_dir)
213
+ true
214
+ end
215
+ # Run the application with the current options.
216
+ def run(args = nil)
217
+ begin
218
+ warn "Warning: No models found on this system! The task 'create' will not work!" if Dokkit.fetch_models.empty?
219
+ if args
220
+ ARGV.clear
221
+ ARGV.concat(args)
206
222
  end
207
-
208
- @rake.run
209
-
223
+ process_args
224
+ init
225
+ load_builtin
226
+ Rake.application.load_rakefile if search_for_rakefile
227
+ Rake.application.top_level
228
+ Rake.application = nil
210
229
  end
211
230
  end
212
-
231
+
213
232
  private
214
233
 
234
+ def command_line_options
235
+ OPTIONS.collect { |lst| lst[0..-2] }
236
+ end
237
+
215
238
  # Process commandline
216
239
  def process_args
217
- GetoptLong.new(
218
- [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
219
- [ "--tasks", "-T", GetoptLong::NO_ARGUMENT ],
220
- [ "--trace", "-t", GetoptLong::NO_ARGUMENT ],
221
- [ "--usage", "-u", GetoptLong::NO_ARGUMENT ],
222
- [ "--project", "-P", GetoptLong::REQUIRED_ARGUMENT],
223
- [ "--rakefile","-f", GetoptLong::REQUIRED_ARGUMENT],
224
- [ "--directory","-D", GetoptLong::REQUIRED_ARGUMENT],
225
- [ "--list", "-l", GetoptLong::NO_ARGUMENT ],
226
- [ "--help", "-h", GetoptLong::NO_ARGUMENT ],
227
- [ "--version", "-V", GetoptLong::NO_ARGUMENT ]
228
- ).each { |opt,arg|
229
- @debug = true if opt == '--verbose'
230
- @trace = true if opt == '--trace'
231
- @tasks = true if opt == '--tasks'
232
- @project = arg if opt == '--project'
233
- @rf = arg if opt == '--rakefile'
234
- @directory = arg if opt == '--directory'
235
- @list_projects = true if opt == '--list'
236
- @usage = true if opt == '--usage' || opt == '--help'
237
- @version = true if opt == '--version'
238
- }
240
+ opts = GetoptLong.new(*command_line_options)
241
+ opts.each { |opt, value| do_option(opt, value) }
239
242
  end
240
-
241
- # Show all the projects present in the distro default dir $DOKKIT_LIB/dokkit/projects/
242
- # and into the user dir $HOME/.dokkit/projects
243
- def show_all_projects
244
- puts "Searching in #{dokkit_lib}.."
245
- puts "Available project models are:"
246
- Dir["#{dokkit_lib}/dokkit/projects/**/Rakefile"].concat(Dir["#{File.expand_path("~/.dokkit/projects/**/Rakefile")}"]).each do |project|
247
- puts File.dirname(project).scan(/projects\/\w+\/*\w+/).to_s.gsub!(/projects\//,"")
243
+
244
+ def help
245
+ puts USAGE_PREAMBLE
246
+ puts "Recognized options are:"
247
+ puts
248
+ OPTIONS.sort.each do |long, short, mode, desc|
249
+ if mode == GetoptLong::REQUIRED_ARGUMENT
250
+ if desc =~ /\b([A-Z]{2,})\b/
251
+ long = long + "=#{$1}"
252
+ end
253
+ end
254
+ printf " %-20s (%s)\n", long, short
255
+ printf " %s\n", desc
248
256
  end
249
257
  end
250
258
 
251
- # Display help text
252
- def show_usage
253
- print <<-EOM
254
- Usage: dokkit [options] [task1] .. [taskN]
255
-
256
- Where [taskN] is a valid task or target name for the current project.
257
- Dokkit generates targets for each page source, and also defines a number
258
- of top-level tasks for various things. Use the '--tasks' option to get
259
- a list of valid tasks.
260
-
261
- Recognised options are:
262
-
263
- --directory=DIR -D
264
- Change to directory DIR before reading the rakefiles or doing anything else.
265
-
266
- --rakefile=FILE -f
267
- Use FILE as a Rakefile.
268
-
269
- --list -l
270
- Display the list of model projects available.
271
-
272
- --help -h
273
- Synonym for --usage
274
-
275
- --project=PROJECT -P
276
- Sets the model project to create. Use --list for the full list of available projects.
277
-
278
- --tasks -T
279
- Display a list of tasks in this project.
280
-
281
- --trace -t
282
- Enables trace-level output (debugging).
283
-
284
- --usage -u
285
- Display this help message and quit.
286
-
287
- --verbose -v
288
- Enable verbose output.
289
-
290
- --version -V
291
- Display Dokkit's version and quit
292
-
293
- In addition to the standard doc_XXX tasks and those provided by any
294
- local configuration, the following 'special' tasks are recognised:
295
-
296
- create <project> Create a blank project from the built-in template using the #{DEFAULT_PROJECT_MODEL} project model.
297
-
298
- In non-standard environments, it may be necessary to set the DOKKIT_LIB
299
- variable to point to the location of Dokkit's libraries.
300
-
301
- EOM
302
- end
303
-
304
259
  end # Application
305
260
  end # Dokkit
@@ -12,10 +12,12 @@ class Deplate::Formatter::LatexNoTemplate < Deplate::Formatter::LaTeX
12
12
  self.myname = "latex-notemplate"
13
13
  self.rx = /(la)?tex(-notemplate)?/i
14
14
 
15
-
16
15
  def prepare
17
16
  end
18
17
 
18
+ def initialize_deplate_sty
19
+ end
20
+
19
21
  def add_package(pkg, *options)
20
22
  end
21
23
  end
@@ -1,11 +1,15 @@
1
- #--
2
- # Rake tasklib for Dokkit
3
- # (c)2006 Andrea Fazzi (and contributors)
4
1
  #
5
- # See 'dokkit.rb' or LICENSE for licence information.
6
- #++
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.
7
9
 
8
10
  require 'rote/rotetasks.rb'
11
+ require 'dokkit/page'
12
+ require 'dokkit/hash'
9
13
 
10
14
  module Rote
11
15
 
@@ -13,14 +17,40 @@ module Rote
13
17
 
14
18
  # Base directories used by the task.
15
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
16
46
 
17
47
  # define a task for each page, and 'all pages' task
18
48
  def define_page_tasks
19
- pages_fl = pages.to_filelist
49
+ pages_fl = pages.to_filelist
20
50
 
21
51
  gen_files = pages_fl.select { |fn| not File.directory?(fn) }.map do |fn|
22
- tfn, blk = target_fn(/^#{pages.dir}/, fn)
23
-
52
+ tfn, blk = target_fn(/^#{pages.dir}/, fn)
53
+
24
54
  desc "#{fn} => #{tfn}" #if show_file_tasks?
25
55
  file tfn => [fn] do
26
56
  dn = File.dirname(tfn)
@@ -29,7 +59,7 @@ module Rote
29
59
  begin
30
60
  File.open(tfn, 'w+') do |f|
31
61
  # new page, run extension block, render out, throw away
32
- f << Page.new(fn,pages.dir,layout_dir,config_dir || pages.dir,&blk).render
62
+ f << Page.new( {:fn => fn}.merge(config_page), &blk).render
33
63
  end
34
64
  rescue => e
35
65
  # Oops... Unlink file and dump backtrace
@@ -42,28 +72,28 @@ module Rote
42
72
  raise
43
73
  end
44
74
  end
45
-
75
+
46
76
  # Each page depends properly on source and common - thx again
47
77
  # Jonathan :)
48
78
  src_rb = Page::page_ruby_filename(fn)
49
79
  if File.exists?(src_rb)
50
80
  file tfn => [src_rb]
51
81
  end
52
-
82
+
53
83
  common_rbs = Page::resolve_common_rubys(File.dirname(fn))
54
84
  file tfn => common_rbs unless common_rbs.empty?
55
-
85
+
56
86
  tfn
57
87
  end
58
-
88
+
59
89
  desc "Render new/changed documentation pages"
60
90
  task "#{name}_pages" => gen_files
61
91
  task "clobber_#{name}_pages" do
62
92
  gen_files.each do |f|
63
93
  rm_f f
64
94
  end
65
- end
95
+ end
66
96
  end
67
97
 
68
98
  end
69
- end
99
+ end
@@ -12,19 +12,25 @@ require 'dokkit/deplate/fmt/html-notemplate'
12
12
 
13
13
  module Dokkit
14
14
  module Filters
15
+
16
+ def Filters.declare_formatters
17
+ ::Deplate::Core.declare_formatter(::Deplate::Formatter::LatexNoTemplate,'latex-notemplate')
18
+ ::Deplate::Core.declare_formatter(::Deplate::Formatter::HTMLNoTemplate,'html-notemplate')
19
+ end
20
+
15
21
  #####
16
- ## Page filter that converts emacs-wiki formatting to tex using
17
- ## deplate.
22
+ ## Page filter that converts emacs-wiki formatting in various formats (tex, html,
23
+ ## docbook, plain text, etc.) using deplate.
18
24
  ##
19
25
  class Deplate < Rote::Filters::TextFilter
20
-
26
+
27
+ Filters.declare_formatters
28
+
21
29
  # Create a new filter instance. If a block is defined returns a Deplate::Converter instance.
22
30
  # You can supply options directly to the instance. See deplate docs for a full list
23
31
  # of options.
24
32
  def initialize(formatter)
25
33
  super()
26
- ::Deplate::Core.declare_formatter(::Deplate::Formatter::LatexNoTemplate,'latex-notemplate')
27
- ::Deplate::Core.declare_formatter(::Deplate::Formatter::HTMLNoTemplate,'html-notemplate')
28
34
  @deplate = ::Deplate::Converter.new(formatter) { |instance| yield(instance) if block_given? }
29
35
  end
30
36