dokkit 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
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/README CHANGED
@@ -0,0 +1,32 @@
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
+
data/Rakefile CHANGED
@@ -1,18 +1,12 @@
1
- # Standard Rakefile for custom Dokkit build
1
+ # Rakefile for dokkit
2
+ #
3
+ # (C) 2006, 2007 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
2
4
  #
3
- #
4
-
5
- begin
6
- require 'rubygems'
7
- rescue LoadError
8
- nil # optional
9
- end
10
5
 
11
6
  $:.unshift('lib')
12
- require 'meta_project'
7
+
13
8
  require 'rake/gempackagetask'
14
9
  require 'rake/contrib/rubyforgepublisher'
15
- require 'rake/contrib/xforge'
16
10
  require 'rake/clean'
17
11
  require 'rake/testtask'
18
12
  require 'rake/rdoctask'
@@ -25,23 +19,37 @@ require 'rake/rdoctask'
25
19
  # Later DamageControl can bump PATCH automatically.
26
20
  #
27
21
  # REMEMBER TO KEEP PKG_VERSION IN SYNC WITH THE CHANGES FILE!
22
+ #
23
+ # Determine the current version of the software
24
+
25
+ if `ruby -Ilib ./bin/dokkit --version` =~ /\S+$/
26
+ CURRENT_VERSION = $&
27
+ else
28
+ CURRENT_VERSION = "0.0.0"
29
+ end
30
+
28
31
  PKG_NAME = "dokkit"
29
- PKG_VERSION = "0.1.1"
32
+ PKG_VERSION = CURRENT_VERSION
30
33
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
31
- PKG_FILES = FileList['lib/**/*', 'bin/*', '[A-Z]*', 'tests/*', 'tests/**/**'].exclude(/alca/).to_a
32
-
34
+ PKG_FILES = FileList.new( ['lib/**/*', 'bin/*', '[A-Z]*', 'tests/**/*'] ) do |fl|
35
+ fl.exclude(/TEMPLATE\./).to_a
36
+ end
33
37
 
34
38
  task :default => [:gem]
35
39
 
36
40
  rd = Rake::RDocTask.new do |rd|
41
+ rd.title = "dokkit"
37
42
  rd.main = "README"
38
- rd.rdoc_files.include("README", "lib/**/*.rb", "tests/*.rb")
39
- rd.rdoc_dir = "apidoc"
40
- rd.options.push('-d').push('-F')
43
+ rd.rdoc_files.include("[A-Z]*", "lib/**/*.rb", "tests/*.rb")
44
+ rd.rdoc_dir = "doc/rdoc"
41
45
  end
42
46
 
47
+ task :man do
48
+ sh "rd2 -r rd/rd2man-lib.rb bin/dokkit | gzip > doc/man/dokkit.1.gz"
49
+ end
50
+
43
51
  # ====================================================================
44
- # Create a task that will package the Rake software into distributable
52
+ # Create a task that will package the software into distributable
45
53
  # tar, zip and gem files.
46
54
 
47
55
  spec = Gem::Specification.new do |s|
@@ -50,21 +58,29 @@ spec = Gem::Specification.new do |s|
50
58
 
51
59
  s.name = PKG_NAME
52
60
  s.version = PKG_VERSION
53
- s.summary = "Ruby Documentation ToolKit"
61
+ s.summary = "Ruby Documentation toolKit"
54
62
  s.description = <<-EOF
55
- dokkit is an open source documentation environment based on ruby.
63
+ dokkit is an open source document generator based on rote.
56
64
  EOF
57
65
 
58
66
  s.files = PKG_FILES.to_a
59
67
  s.require_path = 'lib'
60
68
  s.autorequire = 'dokkit'
69
+ s.bindir = "bin" # Use these for applications.
70
+ s.executables = ["dokkit"]
71
+ s.default_executable = "dokkit"
72
+
73
+ s.add_dependency('deplate', '>= 0.8')
74
+ s.add_dependency('rote', '>= 0.3.4')
75
+ s.add_dependency('rake')
76
+ s.add_dependency('syntax')
61
77
 
62
78
  #### Documentation and testing.
63
79
 
64
80
  s.has_rdoc = true
65
81
  s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
66
82
  s.rdoc_options <<
67
- '--title' << 'Dokkit' <<
83
+ '--title' << 'dokkit' <<
68
84
  '--main' << 'README' <<
69
85
  '--line-numbers'
70
86
 
@@ -72,7 +88,7 @@ spec = Gem::Specification.new do |s|
72
88
 
73
89
  s.author = "Andrea Fazzi"
74
90
  s.email = "andrea.fazzi@alca.le.it"
75
- s.homepage = "http://dokkit.rubyforge.org"
91
+ s.homepage = "http://dokkit.rubyforge.org/"
76
92
  s.rubyforge_project = "dokkit"
77
93
  end
78
94
 
@@ -98,13 +114,22 @@ task :verify_env_vars do
98
114
  raise "RUBYFORGE_PASSWORD environment variable not set!" unless ENV['RUBYFORGE_PASSWORD']
99
115
  end
100
116
 
101
- task :publish_doc do
102
- publisher = Rake::RubyForgePublisher.new('dokkit', ENV['RUBYFORGE_USER'])
103
- publisher.upload
117
+ task :publish_doc => [:rdoc] do
118
+ if user = ENV['RUBYFORGE_USER']
119
+ Rake::SshDirPublisher.new(
120
+ "#{user}@rubyforge.org",
121
+ "/var/www/gforge-projects/dokkit/rdoc/",
122
+ "doc/rdoc/"
123
+ ).upload
124
+ else
125
+ $stderr << "Skipping documentation upload - Need to set RUBYFORGE_USER to your rubyforge.org user name\n"
126
+ end
104
127
  end
105
128
 
106
129
  desc "Release files on RubyForge"
107
130
  task :release_files => [:gem] do
131
+ require 'meta_project'
132
+ require 'rake/contrib/xforge'
108
133
  release_files = FileList[
109
134
  "pkg/#{PKG_FILE_NAME}.gem"
110
135
  ]
@@ -124,10 +149,19 @@ task :publish_news => [:gem] do
124
149
  release_files = FileList[
125
150
  "pkg/#{PKG_FILE_NAME}.gem"
126
151
  ]
127
-
128
152
  Rake::XForge::NewsPublisher.new(MetaProject::Project::XForge::RubyForge.new('dokkit')) do |news|
129
153
  # Never hardcode user name and password in the Rakefile!
130
154
  news.user_name = ENV['RUBYFORGE_USER']
131
155
  news.password = ENV['RUBYFORGE_PASSWORD']
132
156
  end
133
157
  end
158
+
159
+ desc "Tag the working tree and copy it to dokkit-core/tags/REL_X_Y_Z on RubyForge"
160
+ task :tag do
161
+ reltag = "REL_#{PKG_VERSION.gsub(/\./, '_')}"
162
+ puts "Tagging current head with [#{reltag}]"
163
+ sh "svn copy ./ svn+ssh://#{ENV['RUBYFORGE_USER']}@rubyforge.org/var/svn/dokkit/dokkit-core/tags/#{reltag}/ -m \"tag #{reltag}\"" if ENV['RUBYFORGE_USER']
164
+ end
165
+
166
+
167
+
data/bin/dokkit CHANGED
@@ -1,53 +1,63 @@
1
+ #
2
+ # File 'dokkit' created on 09 ott 2007 at 15:57:46.
1
3
  #
2
- # Commandline launcher for Dokkit, (c)2006 Andrea Fazzi (and contributors)
4
+ # See 'dokkit.rb' or LICENSE for licence information.
5
+ #
6
+ # (c)2006, 2007 Andrea Fazzi <andrea.fazzi@alca.le.it> (and contributors).
3
7
  #
8
+ # Commandline launcher for Dokkit.
4
9
  # Get set up with library paths, however we're installed.
10
+ #
5
11
 
6
- def croak
7
- puts "Cannot locate Dokkit libraries - Do you need to set $DOKKIT_LIB ?"
8
- exit(1)
9
- end
12
+ =begin
10
13
 
11
- begin
12
- require 'rubygems'
13
- rescue LoadError
14
- # just ignore, don't use gems
15
- end
14
+ = NAME
15
+ dokkit - Ruby Documentation toolKit
16
+
17
+ = SYNOPSIS
18
+
19
+ dokkit [options] [task1] .. [taskN]
20
+
21
+ = DESCRIPTION
22
+
23
+ dokkit is a documentation environment. It is based on rote and it uses deplate to generate output in a large variety of formats (tex, html, docbook, plain text, ...).
24
+
25
+ For more information please execute:
26
+
27
+ $ dokkit --help
16
28
 
17
- fail = false
29
+ = OPTIONS
18
30
 
19
- dokkit_lib = nil
31
+ For a complete list of the options please execute:
32
+
33
+ $ dokkit --help
34
+
35
+ = AUTHOR
36
+
37
+ Andrea Fazzi <andrea.fazzi@alca.le.it>
38
+
39
+ = SEE ALSO
40
+
41
+ ruby(1)
42
+
43
+ =end
44
+
45
+ def croak
46
+ puts "Cannot locate Dokkit libraries - Do you need to set $DOKKIT_LIB?"
47
+ exit(1)
48
+ end
20
49
 
21
50
  begin
22
- require 'dokkit'
23
- require 'dokkit/app'
24
-
25
- # find this later
26
- dokkit_lib = nil
51
+ require 'rubygems'
27
52
  rescue LoadError
28
- unless fail || !(dokkit_lib = ENV['DOKKIT_LIB'])
29
- $: << dokkit_lib
30
- # at least we can know this now...
31
- builtin = File.join(dokkit_lib,'dokkit/builtin.rake')
32
- fail = true # next time.
33
- retry
34
- else
35
- croak
36
- end
53
+ nil # just ignore, don't use gems
37
54
  end
38
55
 
39
- # If we're loaded via RubyGems or some such we need to locate
40
- # the builtin rakefile.
41
- unless dokkit_lib
42
- $:.each { |it|
43
- if File.exists?(File.join(it,'dokkit/builtin.rake'))
44
- dokkit_lib = it
45
- break
46
- end
47
- }
48
- end
56
+ require 'dokkit'
57
+ require 'dokkit/app'
58
+
59
+ croak unless Dokkit.dokkit_lib
49
60
 
50
- croak unless dokkit_lib
61
+ Dokkit.application.run
51
62
 
52
- Dokkit::Application.new(dokkit_lib).run
53
63
 
@@ -0,0 +1,94 @@
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
+