dnote 1.6.1 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/.ruby CHANGED
@@ -1,47 +1,55 @@
1
- ---
2
- spec_version: 1.0.0
3
- replaces: []
4
-
5
- loadpath:
6
- - lib
7
- name: dnote
8
- repositories:
9
- public: git://github.com/rubyworks/dnote.git
10
- conflicts: []
11
-
12
- engine_check: []
13
-
14
- title: DNote
15
- contact: trans <transfire@gmail.com>
16
- resources:
17
- code: http://github.com/rubyworks/dnote
18
- api: http://rubyworks.github.com/dnote/rdoc
19
- mail: http://groups.google.com/group/rubyworks-mailinglist
20
- wiki: http://wiki.github.com/rubyworks/dnote
21
- home: http://rubyworks.github.com/dnote
22
- maintainers: []
23
-
24
- requires:
25
- - group:
1
+ ---
2
+ source:
3
+ - meta
4
+ authors:
5
+ - name: Thomas Sawyer
6
+ email: transfire@gmail.com
7
+ copyrights:
8
+ - holder: Thomas Sawyer, Rubyworks
9
+ year: '2009'
10
+ replacements: []
11
+ alternatives: []
12
+ requirements:
13
+ - name: lemon
14
+ groups:
15
+ - test
16
+ development: true
17
+ - name: ae
18
+ groups:
26
19
  - test
27
- name: lemon
28
- version: 0+
29
- - group:
20
+ development: true
21
+ - name: detroit
22
+ groups:
30
23
  - build
31
- name: redline
32
- version: 0+
33
- - group:
24
+ development: true
25
+ - name: reap
26
+ groups:
34
27
  - build
35
- name: reap
36
- version: 0+
37
- manifest: MANIFEST
38
- version: 1.6.1
39
- licenses: []
28
+ development: true
29
+ dependencies: []
30
+ conflicts: []
31
+ repositories:
32
+ - uri: git://github.com/rubyworks/dnote.git
33
+ scm: git
34
+ name: upstream
35
+ resources:
36
+ home: http://rubyworks.github.com/dnote
37
+ code: http://github.com/rubyworks/dnote
38
+ wiki: http://wiki.github.com/rubyworks/dnote
39
+ api: http://rubydoc.info/gems/dnote
40
+ bugs: http://github.com/rubyworks/dnote/issues
41
+ mail: http://groups.google.com/groups/rubyworks-mailinglist
42
+ extra: {}
43
+ load_path:
44
+ - lib
45
+ revision: 0
46
+ created: '2009-10-09'
47
+ summary: Extract developer's notes from source code.
48
+ title: DNote
49
+ version: 1.7.0
50
+ name: dnote
51
+ description: ! 'DNote makes it easy to extract developer''s notes from source code,
40
52
 
41
- copyright: Copyright (c) 2009 Thomas Sawyer
42
- authors:
43
- - Thomas Sawyer
53
+ and supports almost any language.'
44
54
  organization: RubyWorks
45
- description: DNote makes it easy to extract developer's notes from source code, and supports almost any language.
46
- summary: Extract developer's notes from source code
47
- created: 2009-10-09
55
+ date: '2011-10-25'
@@ -0,0 +1,5 @@
1
+ --protected
2
+ --private
3
+ lib/**/*.rb
4
+ -
5
+ [A-Z]*.*
@@ -0,0 +1,31 @@
1
+ = COPYRIGHT NOTICES
2
+
3
+ == DNote
4
+
5
+ Copyright:: (c) 2006 Thomas Sawyer, Rubyworks
6
+ License:: BSD-2-Clause
7
+ Website:: http://rubyworks.github.com/tapout
8
+
9
+ Copyright 2006 Thomas Sawyer, Rubyworks. All rights reserved.
10
+
11
+ Redistribution and use in source and binary forms, with or without
12
+ modification, are permitted provided that the following conditions are met:
13
+
14
+ 1. Redistributions of source code must retain the above copyright notice,
15
+ this list of conditions and the following disclaimer.
16
+
17
+ 2. Redistributions in binary form must reproduce the above copyright
18
+ notice, this list of conditions and the following disclaimer in the
19
+ documentation and/or other materials provided with the distribution.
20
+
21
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
+ COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
28
+ OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
+
@@ -1,11 +1,23 @@
1
1
  = RELEASE HISTORY
2
2
 
3
3
 
4
+ == 1.7.0 / 2011-10-25
5
+
6
+ This release finishes adding code context support to all formats. Use the `-c`
7
+ option to set the number of lines to include. Note also that the rake task has
8
+ been moved to `dnote/rake/dnotetask`.
9
+
10
+ Changes:
11
+
12
+ * Support code contexts in all formats.
13
+ * Rake task moved to `dnote/rake/dnotetask`.
14
+
15
+
4
16
  == 1.6.1 / 2011-05-18
5
17
 
6
18
  Last release reused the `-c` option for context lines. This clobbered
7
- the shortcut option for `--custom`. To fix this release capitalizes
8
- the shortcut to `-C`.
19
+ the shortcut option for `--custom`. To fix, this release capitalizes
20
+ the custom shortcut to `-C`.
9
21
 
10
22
  Changes:
11
23
 
@@ -1,4 +1,4 @@
1
- = D'Note
1
+ = DNote
2
2
 
3
3
  * {Homepage}[http://rubyworks.github.com/dnote]
4
4
  * {Mailing List}[http://googlegroups.com/group/rubyworks-mailinglist]
@@ -16,7 +16,7 @@ output formats for them.
16
16
  === Note Structure
17
17
 
18
18
  DNote scans for the common note patterns used by developers of many languages in the form of an
19
- all-caps labels followed by a colon. To be more specific, for D'Note to recognize a note,
19
+ all-caps labels followed by a colon. To be more specific, for DNote to recognize a note,
20
20
  it needs to follow this simple set of rules:
21
21
 
22
22
  1) Notes start with an all-caps label punctuated with a colon, followed by the note's text.
@@ -106,17 +106,8 @@ The usual RubyGem's command will do the trick.
106
106
 
107
107
  == COPYRIGHT
108
108
 
109
- Copyright (c) 2006 Thomas Sawyer
109
+ Copyright (c) 2006 Thomas Sawyer, Rubyworks
110
110
 
111
- Licensed under the Apache License, Version 2.0 (the "License");
112
- you may not use this file except in compliance with the License.
113
- You may obtain a copy of the License at
114
-
115
- http://www.apache.org/licenses/LICENSE-2.0
116
-
117
- Unless required by applicable law or agreed to in writing, software
118
- distributed under the License is distributed on an "AS IS" BASIS,
119
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
120
- See the License for the specific language governing permissions and
121
- limitations under the License.
111
+ DNote is distributable in accordance with the terms of the *FreeBSD* license.
122
112
 
113
+ See COPYING.rdoc for details.
@@ -1,4 +1,4 @@
1
1
  require 'dnote/version'
2
2
  require 'dnote/session'
3
3
 
4
- # TEST: This is a test of arbitraty labels.
4
+ # TEST: This is a test of an arbitrary label.
@@ -10,3 +10,83 @@ module Enumerable
10
10
 
11
11
  end
12
12
 
13
+ module DNote
14
+
15
+ # Extensions for String class.
16
+ # These methods are taken directly from Ruby Facets.
17
+ #
18
+ module String
19
+
20
+ # Provides a margin controlled string.
21
+ #
22
+ # x = %Q{
23
+ # | This
24
+ # | is
25
+ # | margin controlled!
26
+ # }.margin
27
+ #
28
+ #
29
+ # NOTE: This may still need a bit of tweaking.
30
+ #
31
+ # CREDIT: Trans
32
+
33
+ def margin(n=0)
34
+ #d = /\A.*\n\s*(.)/.match( self )[1]
35
+ #d = /\A\s*(.)/.match( self)[1] unless d
36
+ d = ((/\A.*\n\s*(.)/.match(self)) ||
37
+ (/\A\s*(.)/.match(self)))[1]
38
+ return '' unless d
39
+ if n == 0
40
+ gsub(/\n\s*\Z/,'').gsub(/^\s*[#{d}]/, '')
41
+ else
42
+ gsub(/\n\s*\Z/,'').gsub(/^\s*[#{d}]/, ' ' * n)
43
+ end
44
+ end
45
+
46
+ # Preserves relative tabbing.
47
+ # The first non-empty line ends up with n spaces before nonspace.
48
+ #
49
+ # CREDIT: Gavin Sinclair
50
+
51
+ def tabto(n)
52
+ if self =~ /^( *)\S/
53
+ indent(n - $1.length)
54
+ else
55
+ self
56
+ end
57
+ end
58
+
59
+ # Indent left or right by n spaces.
60
+ # (This used to be called #tab and aliased as #indent.)
61
+ #
62
+ # CREDIT: Gavin Sinclair
63
+ # CREDIT: Trans
64
+
65
+ def indent(n)
66
+ if n >= 0
67
+ gsub(/^/, ' ' * n)
68
+ else
69
+ gsub(/^ {0,#{-n}}/, "")
70
+ end
71
+ end
72
+
73
+ #
74
+ #
75
+ def tabset(n)
76
+ i = lines.map do |line|
77
+ line.strip.empty? ? nil : line.index(/\S/)
78
+ end
79
+ x = i.compact.min
80
+ t = n - x.to_i
81
+ t = 0 if t < 0
82
+ indent(t)
83
+ end
84
+
85
+ end
86
+
87
+ class ::String #:nodoc:
88
+ include DNote::String
89
+ end
90
+
91
+ end
92
+
@@ -12,7 +12,7 @@ module DNote
12
12
  require 'fileutils'
13
13
  require 'erb'
14
14
  require 'rexml/text'
15
- require 'dnote/string'
15
+ require 'dnote/core_ext'
16
16
 
17
17
  #DEFAULT_OUTPUT_DIR = "log/dnote"
18
18
 
@@ -45,6 +45,7 @@ module DNote
45
45
  @format = 'text'
46
46
  @subtype = 'label'
47
47
  @title = "Developer's Notes"
48
+ @dryrun = false
48
49
  options.each{ |k,v| __send__("#{k}=", v) if v }
49
50
  yield(self) if block_given?
50
51
  end
@@ -0,0 +1,116 @@
1
+ module DNote
2
+
3
+ # = Developmer's Notes Rake Task
4
+ #
5
+ class RakeTask < Rake::TaskLib
6
+
7
+ require 'rake/clean'
8
+
9
+ # Default note labels to looked for in source code.
10
+ DEFAULT_LABELS = ['TODO', 'FIXME', 'OPTIMIZE', 'DEPRECATE']
11
+
12
+ # File paths to search.
13
+ attr_accessor :files
14
+
15
+ # Labels to document. Defaults are: TODO, FIXME, OPTIMIZE and DEPRECATE.
16
+ attr_accessor :labels
17
+
18
+ # Formats (xml, html, rdoc, rdoc/list and so on).
19
+ attr_accessor :formats
20
+
21
+ # Exclude paths.
22
+ attr_accessor :exclude
23
+
24
+ # Ignore paths based on any part of pathname.
25
+ attr_accessor :ignore
26
+
27
+ # Output directory to save notes file. Defaults to <tt>dnote/</tt> under
28
+ # the project log directory (eg. <tt>log/dnote/</tt>).
29
+ attr_accessor :output
30
+
31
+ # Title to use if temaplte can use it.
32
+ attr_accessor :title
33
+
34
+ #
35
+ def output=(path)
36
+ @output = Pathname.new(path)
37
+ end
38
+
39
+ #
40
+ def init
41
+ require 'dnote'
42
+ require 'dnote/format'
43
+ @files = "**/*.rb"
44
+ @output = 'log/dnote'
45
+ @formats = ['index']
46
+ @labels = nil #DEFAULT_LABELS
47
+ end
48
+
49
+ #
50
+ def define
51
+ desc "Collect Developer's Notes"
52
+ task 'dnote' do
53
+ document
54
+ end
55
+ task 'dnote:clobber' do
56
+ clean
57
+ end
58
+ task :clobber => ['dnote:clobber']
59
+ end
60
+
61
+ # Generate notes document(s).
62
+ def document
63
+ abort "dnote: #{output} is not a directory" unless output.directory?
64
+
65
+ session = ::DNote::Session.new do |s|
66
+ s.paths = files
67
+ s.exclude = exclude
68
+ s.ignore = ignore
69
+ s.labels = labels #|| DEFAULT_LABELS
70
+ s.title = title
71
+ s.output = output
72
+ s.dryrun = application.options.dryrun #trial?
73
+ end
74
+
75
+ formats.each do |format|
76
+ if format == 'index'
77
+ session.format = 'html'
78
+ session.output = File.join(self.output, 'index.html')
79
+ else
80
+ session.format = format
81
+ end
82
+ session.run
83
+ report "Updated #{output.to_s.sub(Dir.pwd+'/','')}" unless trial?
84
+ end
85
+ end
86
+
87
+ # Reset output directory, marking it as out-of-date.
88
+ def reset
89
+ #if File.directory?(output)
90
+ File.utime(0,0,output) unless $NOOP
91
+ puts "Marked #{output} as out-of-date"
92
+ #end
93
+ end
94
+
95
+ # Remove output files.
96
+ def clean
97
+ #if File.directory?(output)
98
+ formats.each do |format|
99
+ if format == 'index'
100
+ file = (output + "index.html").to_s
101
+ else
102
+ ext = ::DNote::Format::EXTENSIONS[format] || format
103
+ file = (output + "notes.#{ext}").to_s
104
+ end
105
+ rm(file)
106
+ report "Removed #{output}"
107
+ end
108
+ #else
109
+ # rm(output)
110
+ # report "Removed #{output}"
111
+ #end
112
+ end
113
+
114
+ end
115
+
116
+ end
@@ -95,12 +95,12 @@ module DNote
95
95
 
96
96
  # Set exclude list ensuring that the value is an array.
97
97
  def exclude=(list)
98
- @exclude = [list].flatten.compact
98
+ @exclude = [list].compact.flatten.compact
99
99
  end
100
100
 
101
101
  # Set ignore list ensuring that the value is an array.
102
102
  def ignore=(list)
103
- @ignore = [list].flatten.compact
103
+ @ignore = [list].compact.flatten.compact
104
104
  end
105
105
 
106
106
  # Run session.
@@ -1,6 +1,6 @@
1
1
  <%= title %>
2
2
 
3
- <%= '=' * title.size %>
3
+ <%= '=' * title.to_s.size %>
4
4
 
5
5
  <% notes.by_label_file.each do |label, per_file| %>
6
6
 
@@ -14,5 +14,6 @@
14
14
 
15
15
  <% line_notes.each do |note| %>
16
16
  * <%= note %> (<%= note.line %>)
17
+ <% if note.code? %><%= "\n" + note.code.tabset(4).rstrip + "\n\n" %><% end %>
17
18
  <% end; end; end %>
18
19