dnote 0.8 → 0.9

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY ADDED
@@ -0,0 +1,23 @@
1
+ = RELEASE HISTORY
2
+
3
+ == 0.9 / 2009-10-10
4
+
5
+ This release adds a syckle plugin and improves output.
6
+
7
+ Changes:
8
+
9
+ * Add syckle plugin, based on old Notes plugin.
10
+ * Improved HTML output (</div> tag should have been </ol>).
11
+ * If output not specified, sends rdoc to stdout.
12
+ * If no paths specified, will scan '**/*.rb'
13
+
14
+ == 0.8 / 2009-10-09
15
+
16
+ This is the initial release of DNote. DNote is a spin-off
17
+ of a Syckle (formerlly Reap) plugin which scans source
18
+ code and compiles a list of developer notes.
19
+
20
+ Changes:
21
+
22
+ * Happy Birthday!
23
+
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2009 Thomas Sawyer
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+
data/MANIFEST CHANGED
@@ -1,17 +1,27 @@
1
+ HISTORY
2
+ LICENSE
3
+ MANIFEST
1
4
  README.rdoc
2
5
  bin/dnote
3
6
  lib/dnote
4
7
  lib/dnote.rb
8
+ lib/dnote/command.rb
5
9
  lib/dnote/notes.rb
10
+ lib/dnote/site.rb
6
11
  lib/dnote/template
12
+ lib/dnote/template/assets
13
+ lib/dnote/template/assets/css
14
+ lib/dnote/template/assets/img
7
15
  lib/dnote/template/index.html
8
- lib/dnote/template/notes.rdoc
9
- lib/dnote/template/notes.xml
16
+ meta/account
10
17
  meta/contact
11
- meta/package
18
+ meta/loadpath
12
19
  meta/project
13
20
  meta/released
14
21
  meta/repository
15
22
  meta/summary
16
23
  meta/title
17
- meta/version
24
+ meta/version
25
+ plug/syckle
26
+ plug/syckle/services
27
+ plug/syckle/services/dnote.rb
data/README.rdoc CHANGED
@@ -1,50 +1,65 @@
1
1
  = D'Note
2
2
 
3
- * http://proutils.github.com/dnote
4
- * http://github.com/proutils/dnote
3
+ * home: http://proutils.github.com/dnote
4
+ * source: http://github.com/proutils/dnote
5
+ * forum: http://googlegroups.com/group/proutils
5
6
 
6
7
 
7
8
  == DESCRIPTION
8
9
 
9
- Extract developement notes from source code and make some pretty RDoc and/or HTML
10
- formatted files out of them.
10
+ Extract developement notes from source code and generate some nice
11
+ output formats for them.
11
12
 
12
13
 
13
14
  == SYNOPSIS
14
15
 
15
- Developer notes it the source code must be formate as follows:
16
+ Developer notes it the source code must be formatted as follows:
16
17
 
17
- # TYPE: description ...
18
- # ... cont ...
18
+ # LABEL: description ...
19
19
 
20
- All notes must be separated by a blank line. Eg.
21
-
22
- # TYPE: description ...
23
- #
24
- # TYPE: description ...
25
-
26
- Without the blank line the second note will be taken to be part of the first.
27
20
  Any description that takes up more than one line must remain flush to the left
28
21
  margin (if the first line is flush to the left margin too) b/c RDoc will mistake
29
22
  of formatting the remaining lines as a +pre+ block it if is not. So...
30
23
 
31
- # TYPE: ... description ...
24
+ # LABEL: ... description ...
32
25
  # continue ...
33
26
 
34
- Alternately the whole note can be a +pre+ block by indenting them. Then the
35
- layout if freed-up.
27
+ All consecutive notes must be separated by a blank lines.
28
+
29
+ # LABEL: description ...
30
+ #
31
+ # LABEL: description ...
32
+
33
+ Without the blank line the second note will be taken to be part of the first.
34
+
35
+ Alternately the whole note can be made a +pre+ block by indention. Then the
36
+ layout if freed-form.
36
37
 
37
38
  # This is a description of something...
38
39
  #
39
- # TYPE: description ...
40
- # continued ...
40
+ # LABEL: description ...
41
+ # continued ...
42
+
43
+ With properly formatted notes, we then use the +dnote+ command line tool.
44
+
45
+ $ dnote
46
+
47
+ And lo! Pretty output. See <tt>dnote --help</tt> for more options.
48
+
49
+
50
+ == INSTALLATION
51
+
52
+ The usual RubyGem's command:
53
+
54
+ $ sudo gem install dnote
41
55
 
42
56
 
43
57
  == COPYRIGHTS
44
58
 
45
- (GPL Licensed)
59
+ (MIT License)
46
60
 
47
61
  Copyright (c) 2006, 2009 Thomas Sawyer
48
62
 
49
- [INSERT NOTICE HERE]
63
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
64
+
50
65
 
data/bin/dnote CHANGED
@@ -1,59 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
-
3
- require 'optparse'
4
- require 'dnote'
5
-
6
- options = {}
7
-
8
- opts = OptionParser.new do |opt|
9
-
10
- opt.banner = "Usage: dnote [OPTIONS] path1 [path2 ...]"
11
-
12
- opt.on("--label", "debug and verbose modes combined") do |lbl|
13
- options[:labels] ||= []
14
- options[:labels] << lbl
15
- end
16
-
17
- opt.on("--output", "-o [DIR]", "folder to store output") do |out|
18
- options[:output] = out
19
- end
20
-
21
- opt.on("--debug", "debug mode") do
22
- $DEBUG = true
23
- end
24
-
25
- opt.on("--verbose", "-v", "verbose mode") do
26
- options[:verbose] = true
27
- end
28
-
29
- opt.on("--quiet", "-q", "surpress output") do
30
- options[:quiet] = true
31
- end
32
-
33
- opt.on("--noop", "-n", "pretend mode") do
34
- options[:quiet] = true
35
- end
36
-
37
- opt.on("--dryrun", "noop and verbose modes combined") do
38
- options[:verbose] = true
39
- options[:noop] = true
40
- end
41
-
42
- opt.on("--trace", "debug and verbose modes combined") do
43
- $DEBUG = true
44
- options[:verbose] = true
45
- end
46
-
47
- opt.on_tail('--help', '-h', "show this help information") do
48
- puts self
49
- exit
50
- end
51
-
52
- end
53
-
54
- opts.parse!
55
-
56
- paths = ARGV.dup
57
- dnote = DNote.new(paths, options)
58
- dnote.document
2
+ load "dnote/command"
3
+ DNote.run
59
4
 
data/lib/dnote.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'dnote/notes'
2
2
 
3
3
  module DNote
4
- VERSION = "0.8" #:till: VERSION = "<%= version %>"
4
+ VERSION = "0.9" #:till: VERSION = "<%= version %>"
5
5
 
6
6
  def self.new(*args)
7
7
  Notes.new(*args)
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ module DNote
4
+ require 'optparse'
5
+ require 'dnote'
6
+
7
+ def self.run
8
+ options = {}
9
+ format = 'rdoc'
10
+
11
+ opts = OptionParser.new do |opt|
12
+
13
+ opt.banner = "Usage: dnote [OPTIONS] path1 [path2 ...]"
14
+
15
+ opt.separator(" ")
16
+ opt.separator("OUTPUT FORMAT: (choose one)")
17
+
18
+ opt.on("--rdoc", "RDoc comment format") do |format|
19
+ format = 'rdoc'
20
+ end
21
+
22
+ opt.on("--markdown", "Markdown wiki format") do |format|
23
+ format = 'markdown'
24
+ end
25
+
26
+ opt.on("--xml", "XML markup format") do |format|
27
+ format = 'xml'
28
+ end
29
+
30
+ opt.on("--html", "HTML markup format") do |format|
31
+ format = 'html'
32
+ end
33
+
34
+ opt.on("--yaml", "YAML serialization format") do |format|
35
+ format = 'yaml'
36
+ end
37
+
38
+ opt.on("--json", "JSON serialization format") do |format|
39
+ format = 'json'
40
+ end
41
+
42
+ opt.separator(" ")
43
+ opt.separator("OTHER OPTIONS:")
44
+
45
+ opt.on("--label", "labels to collect") do |lbl|
46
+ options[:labels] ||= []
47
+ options[:labels] << lbl
48
+ end
49
+
50
+ opt.on("--title", "-t [TITLE]", "title to use in headers") do |title|
51
+ options[:title] = title
52
+ end
53
+
54
+ #opt.on("--output", "-o [FILE]", "name of file to store output (w/o extension)") do |out|
55
+ # options[:output] = out
56
+ #end
57
+
58
+ opt.separator(" ")
59
+ opt.separator("STANDARD OPTIONS:")
60
+
61
+ #opt.on("--verbose", "-v", "extra verbose output") do
62
+ # options[:verbose] = true
63
+ #end
64
+
65
+ opt.on("--debug", "debug mode") do
66
+ $DEBUG = true
67
+ end
68
+
69
+ #opt.on("--quiet", "-q", "surpress non-essential output") do
70
+ # options[:quiet] = true
71
+ #end
72
+
73
+ #opt.on("--noharm", "-n", "only pretend to write to disk") do
74
+ # options[:noharm] = true
75
+ #end
76
+
77
+ #opt.on("--dryrun", "noharm and verbose modes combined") do
78
+ # options[:verbose] = true
79
+ # options[:noharm] = true
80
+ #end
81
+
82
+ #opt.on("--trace", "debug and verbose modes combined") do
83
+ # $DEBUG = true
84
+ # options[:verbose] = true
85
+ #end
86
+
87
+ opt.on_tail('--help', '-h', "show this help information") do
88
+ puts opt
89
+ exit
90
+ end
91
+
92
+ end
93
+
94
+ opts.parse!
95
+
96
+ paths = ARGV.dup
97
+ dnote = DNote.new(paths, options)
98
+ dnote.display(format)
99
+ end
100
+
101
+ end
102
+
data/lib/dnote/notes.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'rexml/text'
2
2
  require 'pathname'
3
3
  require 'erb'
4
- #require 'reap/project/scm'
5
4
 
6
5
  module DNote
7
6
 
@@ -28,70 +27,31 @@ module DNote
28
27
  # Default note labels to look for in source code.
29
28
  DEFAULT_LABELS = ['TODO', 'FIXME', 'OPTIMIZE', 'DEPRECATE']
30
29
 
31
- #
32
- DEFAULT_OUTPUT = Pathname.new('log/notes')
33
-
34
30
  #
35
31
  attr_accessor :title
36
32
 
37
- # Non-Operative
38
- attr_accessor :noop
39
-
40
- # Verbose
41
- attr_accessor :verbose
42
-
43
33
  # Paths to search.
44
34
  attr_accessor :paths
45
35
 
46
36
  # Labels to document. Defaults are: TODO, FIXME, OPTIMIZE and DEPRECATE.
47
37
  attr_accessor :labels
48
38
 
49
- # Directory to save output. Defaults to standard log directory.
50
- attr_accessor :output
51
-
52
- # Format (xml, html, text).
53
- # TODO: HTML format is not usable yet.
54
- #attr_accessor :format
55
-
56
39
  #
57
40
  def initialize(paths, options={})
58
41
  initialize_defaults
59
-
60
- if paths.empty?
61
- if file = File.exist?('meta/loadpath')
62
- paths = YAML.load(File.new(file)).to_list
63
- paths = Array === paths ? paths : paths.split(/\s+/)
64
- elsif file = File.exist?('lib')
65
- paths = ['lib']
66
- else
67
- paths = ['**/*.rb']
68
- end
69
- end
70
-
71
- @paths = paths
72
-
73
42
  options.each do |k, v|
74
43
  __send__("#{k}=", v)
75
44
  end
45
+ #@paths = ['**/*.rb'] if @paths.empty?
46
+ parse
76
47
  end
77
48
 
78
49
  #
79
50
  def initialize_defaults
80
- @paths = ['lib']
81
- @output = DEFAULT_OUTPUT
82
51
  @labels = DEFAULT_LABELS
52
+ @paths = ["**/*.rb"]
83
53
  @title = "Developer's Notes"
84
- #@format = 'xml'
85
- end
86
-
87
- #
88
- def noop?
89
- @noop
90
- end
91
-
92
- #
93
- def verbose?
94
- @verbose
54
+ @format = "rdoc"
95
55
  end
96
56
 
97
57
  #
@@ -104,19 +64,14 @@ module DNote
104
64
  @counts
105
65
  end
106
66
 
107
- #
108
- def templates
109
- Dir[File.join(File.dirname(__FILE__), 'template/*')]
110
- end
111
-
112
- # Scans source code for developer notes and writes them to
67
+ # Scans source code for developer notes and writes them to
113
68
  # well organized files.
114
69
  #
115
- def document
116
- paths = self.paths
117
- output = self.output
70
+ def display(format)
71
+ #paths = self.paths
72
+ #output = self.output
118
73
 
119
- parse
74
+ #parse
120
75
 
121
76
  #paths = paths.to_list
122
77
 
@@ -134,33 +89,25 @@ module DNote
134
89
  #end
135
90
 
136
91
  if notes.empty?
137
- puts "No #{labels.join(', ')} notes."
92
+ $stderr << "No #{labels.join(', ')} notes.\n"
138
93
  else
139
- templates.each do |template|
140
- erb = ERB.new(File.read(template))
141
- text = erb.result(binding)
142
- #text = format_notes(notes, format)
143
- file = write(File.basename(template), text)
144
- #file = file #Pathname.new(file).relative_path_from(Pathname.pwd) #project.root
145
- puts "Updated #{file}"
146
- end
147
- puts(counts.map{|l,n| "#{n} #{l}s"}.join(', '))
148
- end
149
- end
150
-
151
- # Reset output directory, marking it as out-of-date.
152
- def reset
153
- if File.directory?(output)
154
- File.utime(0,0,output)
155
- puts "marked #{output}"
156
- end
157
- end
158
-
159
- # Remove output directory.
160
- def clean
161
- if File.directory?(output)
162
- fu.rm_r(output)
163
- puts "removed #{output}"
94
+ #temp = templates.find{ |f| /#{format}$/ =~ f }
95
+ #erb = ERB.new(File.read(temp))
96
+ #text = erb.result(binding)
97
+
98
+ text = __send__("to_#{format}")
99
+
100
+ #if output
101
+ # #templates.each do |template|
102
+ # #text = format_notes(notes, format)
103
+ # file = write(txt, format)
104
+ # #file = file #Pathname.new(file).relative_path_from(Pathname.pwd) #project.root
105
+ # puts "Updated #{file}"
106
+ # #end
107
+ #else
108
+ puts text
109
+ #end
110
+ $stderr << "\n(" + counts.map{|l,n| "#{n} #{l}s"}.join(', ') + ")\n"
164
111
  end
165
112
  end
166
113
 
@@ -176,19 +123,9 @@ module DNote
176
123
  )
177
124
  end
178
125
 
179
- #
180
- def output=(output)
181
- raise "output cannot be root" if File.expand_path(output) == "/"
182
- @output = Pathname.new(output)
183
- end
184
-
185
- private
186
-
187
126
  # Gather and count notes. This returns two elements,
188
127
  # a hash in the form of label=>notes and a counts hash.
189
- #
190
128
  def parse
191
- #
192
129
  files = self.paths.map do |path|
193
130
  if File.directory?(path)
194
131
  Dir.glob(File.join(path, '**/*'))
@@ -252,41 +189,37 @@ module DNote
252
189
  end
253
190
 
254
191
  #
255
- #def format_notes(notes, type=:rdoc)
256
- # send("format_#{type}", notes)
257
- #end
192
+ def to(format)
193
+ __send__("to_#{format}")
194
+ end
258
195
 
259
- # Format notes in XML format.
196
+ # Format notes in RDoc format.
260
197
  #
261
- def notes_xml
262
- xml = []
263
- xml << "<notes>"
198
+ def to_rdoc
199
+ out = []
200
+ out << "= Development Notes"
264
201
  notes.each do |label, per_file|
265
- xml << %[<set label="#{label}">]
202
+ out << %[\n== #{label}]
266
203
  per_file.each do |file, line_notes|
267
- xml << %[<file src="#{file}">]
204
+ out << %[\n=== file://#{file}\n]
268
205
  line_notes.sort!{ |a,b| a[0] <=> b[0] }
269
206
  line_notes.each do |line, note|
270
- note = REXML::Text.normalize(note)
271
- xml << %[<note line="#{line}" type="#{label}">#{note}</note>]
207
+ out << %[* #{note} (#{line})]
272
208
  end
273
- xml << %[</file>]
274
209
  end
275
- xml << %[</set>]
276
210
  end
277
- xml << "</notes>"
278
- return xml.join("\n")
211
+ return out.join("\n")
279
212
  end
280
213
 
281
214
  # Format notes in RDoc format.
282
215
  #
283
- def notes_rdoc
216
+ def to_markdown
284
217
  out = []
285
- out << "= Development Notes"
218
+ out << "# Development Notes"
286
219
  notes.each do |label, per_file|
287
- out << %[\n== #{label}]
220
+ out << %[\n## #{label}]
288
221
  per_file.each do |file, line_notes|
289
- out << %[\n=== file://#{file}]
222
+ out << %[\n### file://#{file}\n]
290
223
  line_notes.sort!{ |a,b| a[0] <=> b[0] }
291
224
  line_notes.each do |line, note|
292
225
  out << %[* #{note} (#{line})]
@@ -296,52 +229,94 @@ module DNote
296
229
  return out.join("\n")
297
230
  end
298
231
 
299
- # HTML format.
232
+ # Format notes in XML format.
300
233
  #
301
- def notes_html
234
+ def to_xml
302
235
  xml = []
303
- xml << %[<div class="notes">]
236
+ xml << "<notes>"
304
237
  notes.each do |label, per_file|
305
- xml << %[<h2>#{label}</h2>\n<ol class="set #{label.downcase}">]
238
+ xml << %[<set label="#{label}">]
306
239
  per_file.each do |file, line_notes|
307
- xml << %[<li><h3><a href="#{file}">#{file}</a></h3><ol class="file" href="#{file}">]
240
+ xml << %[<file src="#{file}">]
308
241
  line_notes.sort!{ |a,b| a[0] <=> b[0] }
309
242
  line_notes.each do |line, note|
310
243
  note = REXML::Text.normalize(note)
311
- xml << %[<li class="note #{label.downcase}" ref="#{line}">#{note} <sup>#{line}</sup></li>]
244
+ xml << %[<note line="#{line}" type="#{label}">#{note}</note>]
312
245
  end
313
- xml << %[</ol></li>]
246
+ xml << %[</file>]
314
247
  end
315
- xml << %[</div>]
248
+ xml << %[</set>]
316
249
  end
317
- xml << "</div>"
250
+ xml << "</notes>"
318
251
  return xml.join("\n")
319
252
  end
320
253
 
321
- # Save notes.
254
+ # HTML format.
322
255
  #
323
- def write(file, text)
324
- file = output + file
325
- fu.mkdir_p(output)
326
- File.open(file, 'w') { |f| f << text } unless noop?
327
- file
256
+ def to_html
257
+ html = []
258
+ html << %[<html>]
259
+ html << %[<head>]
260
+ html << %[<title><%= title %></title>]
261
+ html << %[<style>]
262
+ html << HTML_CSS
263
+ html << %[</style>]
264
+ html << %[</head>]
265
+ html << %[<body>]
266
+ html << %[<div class="main">]
267
+ html << %[<h1><%= title %></h1>]
268
+ html << to_html_list
269
+ html << %[</div>]
270
+ html << %[</boby>]
271
+ html << %[</html>]
272
+ html.join("\n")
328
273
  end
329
274
 
330
275
  #
331
- def fu
332
- @fu ||= (
333
- if noop? and verbose?
334
- FileUtils::DryRun
335
- elsif noop
336
- FileUtils::Noop
337
- elsif verbose
338
- FileUtils::Verbose
339
- else
340
- FileUtils
276
+ def to_html_list
277
+ html = []
278
+ html << %[<div class="notes">]
279
+ notes.each do |label, per_file|
280
+ html << %[<h2>#{label}</h2>]
281
+ html << %[<ol class="set #{label.downcase}">]
282
+ per_file.each do |file, line_notes|
283
+ html << %[<li><h3><a href="#{file}">#{file}</a></h3><ol class="file" href="#{file}">]
284
+ line_notes.sort!{ |a,b| a[0] <=> b[0] }
285
+ line_notes.each do |line, note|
286
+ note = REXML::Text.normalize(note)
287
+ html << %[<li class="note #{label.downcase}" ref="#{line}">#{note} <sup>#{line}</sup></li>]
288
+ end
289
+ html << %[</ol></li>]
341
290
  end
342
- )
291
+ html << %[</ol>]
292
+ end
293
+ html << %[</div>]
294
+ html.join("\n")
295
+ end
296
+
297
+ #
298
+ def to_yaml
299
+ require 'yaml'
300
+ notes.to_yaml
343
301
  end
344
302
 
303
+ #
304
+ def to_json
305
+ require 'json'
306
+ notes.to_json
307
+ end
308
+
309
+ HTML_CSS = <<-HERE
310
+ body { margin: 0; padding: 0; }
311
+ .main { width: 800px; margin: 0 auto; border: 1px solid #ccc; padding: 0 20px 20px 20px; }
312
+ h1 { margin: 25px 0; }
313
+ h2,h3,h4 { margin: 5px 0; padding: 0; color: 880044; }
314
+ h3 { color: 004488; }
315
+ h4 { color: 888844; }
316
+ ul { margin: 0; padding: 0; text-align: left; }
317
+ li { margin: 0; padding: 0; text-align: left; }
318
+ HERE
319
+
345
320
  end
346
321
 
347
322
  end
data/lib/dnote/site.rb ADDED
@@ -0,0 +1,123 @@
1
+ module DNote
2
+
3
+ require 'dnote/notes'
4
+
5
+ # Site class is used to build a "pretty" output set.
6
+ # The template files are saved to the +output+ directory.
7
+ # Additional +formats+ can be saved the the directory
8
+ # as well.
9
+
10
+ class Site
11
+
12
+ # Default output directory is +dnote/+.
13
+ DEFAULT_OUTPUT = Pathname.new('dnote')
14
+
15
+ # Title to use in any headers.
16
+ attr_accessor :title
17
+
18
+ # Directory to save output.
19
+ attr_accessor :output
20
+
21
+ # Additional Formats to supply besided the html (xml, rdoc, markdown, etc.)
22
+ attr_accessor :formats
23
+
24
+ # Notes object.
25
+ attr_reader :notes
26
+
27
+ def initialize(paths, options)
28
+ self.title = options[:title]
29
+
30
+ self.output = options.delete(:output)
31
+ self.formats = options.delete(:formats)
32
+
33
+ @notes = Notes.new(paths, options)
34
+ end
35
+
36
+ #
37
+ def initialize_defaults
38
+ @output = DEFAULT_OUTPUT
39
+ @title = "Development Notes"
40
+ @formats = []
41
+ end
42
+
43
+ #
44
+ def output=(path)
45
+ raise "output cannot be root" if File.expand_path(path) == "/"
46
+ @output = Pathname.new(path)
47
+ end
48
+
49
+ #
50
+ def document
51
+ fu.mkdir_p(output)
52
+
53
+ # copy the whole template directory over
54
+ fu.cp_r("#{__DIR__}/template/", "#{output}/")
55
+
56
+ # (re)write the erb templates
57
+ templates.each do |temp|
58
+ erb = ERB.new(File.read(temp))
59
+ text = erb.result(binding)
60
+ file = File.basename(temp)
61
+ write(file, text)
62
+ end
63
+
64
+ # produce requested additional formats
65
+ formats.each do |format|
66
+ text = notes.to(format)
67
+ write("notes.#{format}", text)
68
+ end
69
+ end
70
+
71
+ # Reset output directory, marking it as out-of-date.
72
+ def reset
73
+ if File.directory?(output)
74
+ File.utime(0,0,output) unless $NOOP
75
+ puts "marked #{output}"
76
+ end
77
+ end
78
+
79
+ # Remove output directory.
80
+ def clean
81
+ if File.directory?(output)
82
+ fu.rm_r(output)
83
+ puts "removed #{output}"
84
+ end
85
+ end
86
+
87
+ #
88
+ def templates
89
+ @templates ||= (
90
+ Dir[File.join(File.dirname(__FILE__), 'template/*')].select{ |f| File.file?(f) }
91
+ )
92
+ end
93
+
94
+ # Save file to output.
95
+ #
96
+ def write(fname, text)
97
+ file = output + fname
98
+ fu.mkdir_p(file.parent)
99
+ File.open(file, 'w') { |f| f << text } unless $NOOP
100
+ end
101
+
102
+ def __DIR__
103
+ File.dirname(__FILE__)
104
+ end
105
+
106
+ #
107
+ def fu
108
+ @fu ||= (
109
+ if $NOOP and $DEBUG
110
+ FileUtils::DryRun
111
+ elsif $NOOP
112
+ FileUtils::Noop
113
+ elsif $DEBUG
114
+ FileUtils::Verbose
115
+ else
116
+ FileUtils
117
+ end
118
+ )
119
+ end
120
+
121
+ end
122
+
123
+ end
@@ -18,13 +18,15 @@
18
18
  </style>
19
19
  </head>
20
20
  <body>
21
+
21
22
  <div class="main">
22
23
 
23
24
  <h1><%= title %></h1>
24
25
 
25
- <%= notes_html %>
26
+ <%= notes.to_html_list %>
26
27
 
27
28
  </div>
29
+
28
30
  </boby>
29
31
  </html>
30
32
 
data/meta/account ADDED
@@ -0,0 +1 @@
1
+ proutils
data/meta/loadpath ADDED
@@ -0,0 +1,2 @@
1
+ lib
2
+ plug
data/meta/project CHANGED
@@ -1 +1 @@
1
- proutils
1
+ dnote
data/meta/version CHANGED
@@ -1 +1 @@
1
- 0.8
1
+ 0.9
@@ -0,0 +1,100 @@
1
+ module Syckle::Plugins
2
+
3
+ # = Developmer's Notes Plugin
4
+ #
5
+ # This plugin goes through you source files and compiles
6
+ # an lit of any labeled comments. Labels are single word
7
+ # prefixes to a comment ending in a colon. For example,
8
+ # you might note somewhere in your code:
9
+ #
10
+ # By default this label supports the TODO, FIXME, OPTIMIZE
11
+ # and DEPRECATE.
12
+ #
13
+ # Output is a set of files in HTML, XML and RDoc's simple
14
+ # markup format. This plugin can run automatically if there
15
+ # is a +notes/+ directory in the project's log directory.
16
+ #
17
+ #--
18
+ # TODO: Should this service be part of the +site+ cycle?
19
+ #++
20
+ class DNote < Service
21
+
22
+ cycle :main, :document
23
+ cycle :main, :reset
24
+ cycle :main, :clean
25
+
26
+ # not that this is necessary, but ...
27
+ available do |project|
28
+ begin
29
+ require 'dnote/site'
30
+ true
31
+ rescue LoadError
32
+ false
33
+ end
34
+ end
35
+
36
+ # autorun if log/notes exists
37
+ autorun do |project|
38
+ (project.log + 'notes').exist?
39
+ end
40
+
41
+ # Default note labels to looked for in source code.
42
+ DEFAULT_LABELS = ['TODO', 'FIXME', 'OPTIMIZE', 'DEPRECATE']
43
+
44
+ # Paths to search.
45
+ attr_accessor :files
46
+
47
+ # Labels to document. Defaults are: TODO, FIXME, OPTIMIZE and DEPRECATE.
48
+ attr_accessor :labels
49
+
50
+ # Directory to save output. Defaults to <tt>dnote/</tt> under project
51
+ # log directory.
52
+ attr_accessor :output
53
+
54
+ # Formats (xml, html, rdoc).
55
+ attr_accessor :formats
56
+
57
+ #
58
+ def output=(path)
59
+ @output = Pathname.new(path)
60
+ end
61
+
62
+ #
63
+ def dnote
64
+ @dnote ||= ::DNote::Site.new(files, :labels=>labels, :formats=>formats, :output=>output)
65
+ end
66
+
67
+ # Generate notes documents.
68
+ def document
69
+ $NOOP = noop? # TODO:
70
+ dnote.document
71
+ #mkdir_p(output)
72
+ #file = output + "index.html"
73
+ #File.open(file, 'w'){ |f| f << dnote.to_html }
74
+ report "Updated #{output.to_s.sub(Dir.pwd+'/','')}"
75
+ end
76
+
77
+ # Mark notes documents as out-of-date.
78
+ def reset
79
+ #dnote.reset
80
+ end
81
+
82
+ # Remove notes directory.
83
+ def clean
84
+ #dnote.clean
85
+ end
86
+
87
+ private
88
+
89
+ # TODO: maybe files default of **/*.rb is better?
90
+ def initialize_defaults
91
+ @files = metadata.loadpath || 'lib'
92
+ @output = project.log + 'dnote'
93
+ @formats = []
94
+ @labels = DEFAULT_LABELS
95
+ end
96
+
97
+ end
98
+
99
+ end
100
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dnote
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.8"
4
+ version: "0.9"
5
5
  platform: ruby
6
6
  authors: []
7
7
 
@@ -9,13 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-09 00:00:00 -04:00
12
+ date: 2009-10-24 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: |-
17
- Extract developement notes from source code and make some pretty RDoc and/or HTML
18
- formatted files out of them.
16
+ description: ""
19
17
  email: http://googlegroups.com/group/proutils
20
18
  executables:
21
19
  - dnote
@@ -23,35 +21,41 @@ extensions: []
23
21
 
24
22
  extra_rdoc_files:
25
23
  - MANIFEST
24
+ - LICENSE
26
25
  - README.rdoc
26
+ - HISTORY
27
27
  files:
28
+ - HISTORY
29
+ - LICENSE
30
+ - MANIFEST
28
31
  - README.rdoc
29
32
  - bin/dnote
30
33
  - lib/dnote.rb
34
+ - lib/dnote/command.rb
31
35
  - lib/dnote/notes.rb
36
+ - lib/dnote/site.rb
32
37
  - lib/dnote/template/index.html
33
- - lib/dnote/template/notes.rdoc
34
- - lib/dnote/template/notes.xml
38
+ - meta/account
35
39
  - meta/contact
36
- - meta/package
40
+ - meta/loadpath
37
41
  - meta/project
38
42
  - meta/released
39
43
  - meta/repository
40
44
  - meta/summary
41
45
  - meta/title
42
46
  - meta/version
43
- - MANIFEST
47
+ - plug/syckle/services/dnote.rb
44
48
  has_rdoc: true
45
49
  homepage:
46
50
  licenses: []
47
51
 
48
52
  post_install_message:
49
53
  rdoc_options:
50
- - --inline-source
51
54
  - --title
52
- - dnote api
55
+ - D'Note API
53
56
  require_paths:
54
57
  - lib
58
+ - plug
55
59
  required_ruby_version: !ruby/object:Gem::Requirement
56
60
  requirements:
57
61
  - - ">="
@@ -1 +0,0 @@
1
- <%= notes_rdoc %>
@@ -1 +0,0 @@
1
- <%= notes_xml %>
data/meta/package DELETED
@@ -1 +0,0 @@
1
- dnote