dnote 1.7.1 → 1.8.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.
@@ -1,21 +1,37 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+ require 'rake/clean'
4
+
1
5
  module DNote
2
6
 
3
- # = Developmer's Notes Rake Task
7
+ # = Developer's Notes Rake Task
8
+ #
9
+ # require 'dnote/rake/dnotetask'
10
+ #
11
+ # DNote::RakeTask.new do |t|
12
+ # t.files = 'lib/**/*.rb'
13
+ # t.formats = ['html', 'md']
14
+ # t.output = 'doc/notes'
15
+ # end
4
16
  #
17
+ # This defines a +dnote+ task that writes the notes, and a
18
+ # +dnote:clobber+ task that removes them, which +clobber+ also runs.
5
19
  class RakeTask < Rake::TaskLib
6
20
 
7
- require 'rake/clean'
8
-
9
21
  # Default note labels to looked for in source code.
10
22
  DEFAULT_LABELS = ['TODO', 'FIXME', 'OPTIMIZE', 'DEPRECATE']
11
23
 
24
+ # Name of the task. Defaults to +dnote+.
25
+ attr_accessor :name
26
+
12
27
  # File paths to search.
13
28
  attr_accessor :files
14
29
 
15
- # Labels to document. Defaults are: TODO, FIXME, OPTIMIZE and DEPRECATE.
30
+ # Labels to document. By default all labels are collected.
16
31
  attr_accessor :labels
17
32
 
18
- # Formats (xml, html, rdoc, rdoc/list and so on).
33
+ # Formats (xml, html, rdoc, rdoc/list and so on). The default is
34
+ # +index+, which is the +html+ format saved as <tt>index.html</tt>.
19
35
  attr_accessor :formats
20
36
 
21
37
  # Exclude paths.
@@ -24,11 +40,11 @@ module DNote
24
40
  # Ignore paths based on any part of pathname.
25
41
  attr_accessor :ignore
26
42
 
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
43
+ # Output directory to save notes file. Defaults to <tt>log/dnote/</tt>.
44
+ # It is made if it does not exist.
45
+ attr_reader :output
30
46
 
31
- # Title to use if temaplte can use it.
47
+ # Title to use if template can use it.
32
48
  attr_accessor :title
33
49
 
34
50
  #
@@ -36,79 +52,82 @@ module DNote
36
52
  @output = Pathname.new(path)
37
53
  end
38
54
 
55
+ # Define the tasks. The task object is yielded for settings.
56
+ def initialize(name='dnote')
57
+ @name = name.to_s
58
+ init
59
+ yield(self) if block_given?
60
+ define
61
+ end
62
+
39
63
  #
40
64
  def init
65
+ require 'pathname'
41
66
  require 'dnote'
42
67
  require 'dnote/format'
43
68
  @files = "**/*.rb"
44
- @output = 'log/dnote'
69
+ @output = Pathname.new('log/dnote')
45
70
  @formats = ['index']
46
- @labels = nil #DEFAULT_LABELS
71
+ @labels = nil
47
72
  end
48
73
 
49
74
  #
50
75
  def define
51
76
  desc "Collect Developer's Notes"
52
- task 'dnote' do
77
+ task name do
53
78
  document
54
79
  end
55
- task 'dnote:clobber' do
80
+ task "#{name}:clobber" do
56
81
  clean
57
82
  end
58
- task :clobber => ['dnote:clobber']
83
+ task :clobber => ["#{name}:clobber"]
59
84
  end
60
85
 
61
86
  # Generate notes document(s).
62
87
  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
88
+ abort "dnote: #{output} is not a directory" if output.exist? && !output.directory?
89
+
90
+ dryrun = Rake.application.options.dryrun
74
91
 
75
92
  formats.each do |format|
93
+ session = ::DNote::Session.new do |s|
94
+ s.paths = [files].flatten.compact
95
+ s.exclude = exclude
96
+ s.ignore = ignore
97
+ s.labels = [labels].flatten.compact
98
+ s.title = title if title
99
+ s.dryrun = dryrun
100
+ end
101
+
76
102
  if format == 'index'
77
103
  session.format = 'html'
78
- session.output = File.join(self.output, 'index.html')
104
+ session.output = (output + 'index.html').to_s
79
105
  else
80
106
  session.format = format
107
+ session.output = output.to_s + '/'
81
108
  end
109
+
110
+ output.mkpath unless dryrun
82
111
  session.run
83
- report "Updated #{output.to_s.sub(Dir.pwd+'/','')}" unless trial?
84
112
  end
85
113
  end
86
114
 
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
115
  # Remove output files.
96
116
  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
117
+ formats.each do |format|
118
+ rm_f output_file(format).to_s
119
+ end
120
+ end
121
+
122
+ # The file a format is written to.
123
+ def output_file(format)
124
+ if format == 'index'
125
+ output + "index.html"
126
+ else
127
+ type = format.split('/').first
128
+ ext = ::DNote::Format::EXTENSIONS[type] || type
129
+ output + "notes.#{ext}"
130
+ end
112
131
  end
113
132
 
114
133
  end
data/lib/dnote/session.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  module DNote
2
2
 
3
- require 'dnote/core_ext'
4
3
  require 'dnote/notes'
5
4
  require 'dnote/format'
6
5
 
@@ -41,6 +40,10 @@ module DNote
41
40
  # Alternate remark marker. Useful to other languages besides Ruby.
42
41
  attr_accessor :marker
43
42
 
43
+ # Collect notes written as tags, such as <tt>@TODO</tt>. The default
44
+ # is true.
45
+ attr_accessor :tags
46
+
44
47
  # Output format.
45
48
  attr_accessor :format
46
49
 
@@ -87,6 +90,7 @@ module DNote
87
90
  @title = DEFAULT_TITLE
88
91
  @dryrun = false
89
92
  @marker = nil
93
+ @tags = true
90
94
  @url = nil
91
95
  @context = 0
92
96
  end
@@ -105,12 +109,13 @@ module DNote
105
109
 
106
110
  # Run session.
107
111
  def run
108
- notes = Notes.new(files, :labels=>labels, :colon=>colon, :marker=>marker, :url=>url, :context=>context)
112
+ notes = Notes.new(files, :labels=>labels, :colon=>colon, :marker=>marker, :tags=>tags, :url=>url, :context=>context)
109
113
  formatter = Format.new(notes) do |f|
110
114
  f.format = format
111
115
  f.template = template
112
116
  f.title = title
113
117
  f.output = output
118
+ f.dryrun = dryrun
114
119
  end
115
120
  formatter.render
116
121
  end
@@ -195,6 +200,10 @@ module DNote
195
200
  session.colon = val
196
201
  end
197
202
 
203
+ opt.on("--[no-]tags", "match labels written as tags, e.g. @TODO [yes]") do |val|
204
+ session.tags = val
205
+ end
206
+
198
207
  opt.on("--marker", "-m MARK", "alternative remark marker") do |mark|
199
208
  session.marker = mark
200
209
  end
@@ -33,7 +33,7 @@
33
33
  <%= h note.textline %> <sup><a href="<%= note.url %>"><%= note.line %></a></sup>
34
34
  <% if note.code? %>
35
35
  <pre>
36
- <%= note.code %>
36
+ <%= h note.code %>
37
37
  </pre>
38
38
  <% end %>
39
39
  </li>
@@ -34,7 +34,7 @@
34
34
  <%= h note.text %> <sup><a href="<%= note.url %>"><%= note.line %></a></sup>
35
35
  <% if note.code? %>
36
36
  <pre>
37
- <%= note.code %>
37
+ <%= h note.code %>
38
38
  </pre>
39
39
  <% end %>
40
40
  </li>
@@ -30,9 +30,9 @@
30
30
  <sup><a href="<%= note.url %>"><%= note.file %>: <%= note.line %></a></sup>
31
31
  <% if note.code? %>
32
32
  <pre>
33
- <%= note.code %>
33
+ <%= h note.code %>
34
34
  </pre>
35
- <$ end %>
35
+ <% end %>
36
36
  </li>
37
37
  <% end %>
38
38
  </ol>
@@ -34,7 +34,7 @@
34
34
  <%= h note.text %> <sup><a href="<%= note.url %>"><%= note.line %></a></sup>
35
35
  <% if note.code? %>
36
36
  <pre>
37
- <%= note.code %>
37
+ <%= h note.code %>
38
38
  </pre>
39
39
  <% end %>
40
40
  </li>
@@ -2,7 +2,7 @@
2
2
  <notes>
3
3
  <% notes.by_file_label.each do |file, per_label| %>
4
4
  <file src="<%= file %>">
5
- <% per_label.each do |label, lnotes| %>
5
+ <% per_label.each do |label, line_notes| %>
6
6
  <label name="<%= label %>">
7
7
  <% line_notes.sort!{ |a,b| a.line <=> b.line } %>
8
8
  <% line_notes.each do |note| %>
@@ -1,4 +1,6 @@
1
1
  <%=
2
2
  require 'xoxo'
3
- notes.by_file.to_xoxo
3
+ list = {}
4
+ notes.by_file.each{ |file, set| list[file] = set.map{ |n| n.to_h } }
5
+ list.to_xoxo
4
6
  %>
@@ -1,4 +1,6 @@
1
1
  <%=
2
2
  require 'xoxo'
3
- notes.by_label.to_xoxo
3
+ list = {}
4
+ notes.by_label.each{ |label, set| list[label] = set.map{ |n| n.to_h } }
5
+ list.to_xoxo
4
6
  %>
@@ -1,4 +1,6 @@
1
1
  <%=
2
2
  require 'xoxo'
3
- notes.by_label.to_xoxo
3
+ list = {}
4
+ notes.by_label.each{ |label, set| list[label] = set.map{ |n| n.to_h } }
5
+ list.to_xoxo
4
6
  %>
data/lib/dnote/version.rb CHANGED
@@ -1,16 +1,4 @@
1
1
  module DNote
2
-
3
- #
4
- def self.metadata
5
- @metadata ||= (
6
- require 'yaml'
7
- YAML.load_file(File.dirname(__FILE__) + '/../dnote.yml')
8
- )
9
- end
10
-
11
- #
12
- def self.const_missing(name)
13
- metadata[name.to_s.downcase] || super(name)
14
- end
15
-
2
+ # The version of DNote.
3
+ VERSION = '1.8.0'
16
4
  end
metadata CHANGED
@@ -1,150 +1,150 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dnote
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
5
- prerelease:
4
+ version: 1.8.0
6
5
  platform: ruby
7
6
  authors:
8
- - Thomas Sawyer
9
- autorequire:
7
+ - Trans
10
8
  bindir: bin
11
9
  cert_chain: []
12
- date: 2012-01-10 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
13
11
  dependencies:
14
12
  - !ruby/object:Gem::Dependency
15
- name: lemon
16
- requirement: &21487200 !ruby/object:Gem::Requirement
17
- none: false
13
+ name: rake
14
+ requirement: !ruby/object:Gem::Requirement
18
15
  requirements:
19
- - - ! '>='
16
+ - - ">="
20
17
  - !ruby/object:Gem::Version
21
- version: '0'
18
+ version: '13'
22
19
  type: :development
23
20
  prerelease: false
24
- version_requirements: *21487200
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '13'
25
26
  - !ruby/object:Gem::Dependency
26
- name: ae
27
- requirement: &21486520 !ruby/object:Gem::Requirement
28
- none: false
27
+ name: rubytest
28
+ requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
- - - ! '>='
30
+ - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: '0'
32
+ version: 0.11.1
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *21486520
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 0.11.1
36
40
  - !ruby/object:Gem::Dependency
37
- name: detroit
38
- requirement: &21502280 !ruby/object:Gem::Requirement
39
- none: false
41
+ name: lemon
42
+ requirement: !ruby/object:Gem::Requirement
40
43
  requirements:
41
- - - ! '>='
44
+ - - ">="
42
45
  - !ruby/object:Gem::Version
43
- version: '0'
46
+ version: 0.9.4
44
47
  type: :development
45
48
  prerelease: false
46
- version_requirements: *21502280
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 0.9.4
47
54
  - !ruby/object:Gem::Dependency
48
- name: reap
49
- requirement: &21501780 !ruby/object:Gem::Requirement
50
- none: false
55
+ name: ae
56
+ requirement: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - ! '>='
58
+ - - ">="
53
59
  - !ruby/object:Gem::Version
54
- version: '0'
60
+ version: '1.9'
55
61
  type: :development
56
62
  prerelease: false
57
- version_requirements: *21501780
58
- description: ! 'DNote makes it easy to extract developer''s notes from source code,
59
-
60
- and supports almost any language.'
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '1.9'
68
+ description: DNote makes it easy to extract developer's notes from source code, and
69
+ supports almost any language.
61
70
  email:
62
71
  - transfire@gmail.com
63
72
  executables:
64
73
  - dnote
65
74
  extensions: []
66
- extra_rdoc_files:
75
+ extra_rdoc_files: []
76
+ files:
77
+ - COPYING.rdoc
67
78
  - HISTORY.rdoc
68
79
  - README.rdoc
69
- - COPYING.rdoc
70
- files:
71
- - .ruby
72
- - .yardopts
73
80
  - bin/dnote
81
+ - lib/dnote.rb
74
82
  - lib/dnote/core_ext.rb
75
83
  - lib/dnote/format.rb
76
84
  - lib/dnote/note.rb
77
85
  - lib/dnote/notes.rb
78
86
  - lib/dnote/rake/dnotetask.rb
79
87
  - lib/dnote/session.rb
88
+ - lib/dnote/templates/html.erb
80
89
  - lib/dnote/templates/html/file.erb
81
90
  - lib/dnote/templates/html/label.erb
82
91
  - lib/dnote/templates/html/list.erb
83
- - lib/dnote/templates/html.erb
92
+ - lib/dnote/templates/json.erb
84
93
  - lib/dnote/templates/json/file.erb
85
94
  - lib/dnote/templates/json/label.erb
86
95
  - lib/dnote/templates/json/list.erb
87
- - lib/dnote/templates/json.erb
96
+ - lib/dnote/templates/md.erb
88
97
  - lib/dnote/templates/md/file.erb
89
98
  - lib/dnote/templates/md/label.erb
90
99
  - lib/dnote/templates/md/list.erb
91
- - lib/dnote/templates/md.erb
100
+ - lib/dnote/templates/rdoc.erb
92
101
  - lib/dnote/templates/rdoc/file.erb
93
102
  - lib/dnote/templates/rdoc/label.erb
94
103
  - lib/dnote/templates/rdoc/list.erb
95
- - lib/dnote/templates/rdoc.erb
104
+ - lib/dnote/templates/soap.erb
96
105
  - lib/dnote/templates/soap/file.erb
97
106
  - lib/dnote/templates/soap/label.erb
98
107
  - lib/dnote/templates/soap/list.erb
99
- - lib/dnote/templates/soap.erb
108
+ - lib/dnote/templates/text.erb
100
109
  - lib/dnote/templates/text/file.erb
101
110
  - lib/dnote/templates/text/label.erb
102
111
  - lib/dnote/templates/text/list.erb
103
- - lib/dnote/templates/text.erb
112
+ - lib/dnote/templates/xml.erb
104
113
  - lib/dnote/templates/xml/file.erb
105
114
  - lib/dnote/templates/xml/label.erb
106
115
  - lib/dnote/templates/xml/list.erb
107
- - lib/dnote/templates/xml.erb
116
+ - lib/dnote/templates/xoxo.erb
108
117
  - lib/dnote/templates/xoxo/file.erb
109
118
  - lib/dnote/templates/xoxo/label.erb
110
119
  - lib/dnote/templates/xoxo/list.erb
111
- - lib/dnote/templates/xoxo.erb
120
+ - lib/dnote/templates/yaml.erb
112
121
  - lib/dnote/templates/yaml/file.erb
113
122
  - lib/dnote/templates/yaml/label.erb
114
123
  - lib/dnote/templates/yaml/list.erb
115
- - lib/dnote/templates/yaml.erb
116
124
  - lib/dnote/version.rb
117
- - lib/dnote.rb
118
- - lib/dnote.yml
119
- - test/notes_case.rb
120
- - try/sample.bas
121
- - try/sample.js
122
- - try/sample.rb
123
- - HISTORY.rdoc
124
- - README.rdoc
125
- - COPYING.rdoc
126
- homepage: http://rubyworks.github.com/dnote
127
- licenses: []
128
- post_install_message:
125
+ homepage: https://github.com/rubyworks/dnote
126
+ licenses:
127
+ - BSD-2-Clause
128
+ metadata:
129
+ source_code_uri: https://github.com/rubyworks/dnote
130
+ bug_tracker_uri: https://github.com/rubyworks/dnote/issues
131
+ changelog_uri: https://github.com/rubyworks/dnote/blob/master/HISTORY.rdoc
132
+ documentation_uri: https://rubydoc.info/gems/dnote
129
133
  rdoc_options: []
130
134
  require_paths:
131
135
  - lib
132
136
  required_ruby_version: !ruby/object:Gem::Requirement
133
- none: false
134
137
  requirements:
135
- - - ! '>='
138
+ - - ">="
136
139
  - !ruby/object:Gem::Version
137
- version: '0'
140
+ version: '3.1'
138
141
  required_rubygems_version: !ruby/object:Gem::Requirement
139
- none: false
140
142
  requirements:
141
- - - ! '>='
143
+ - - ">="
142
144
  - !ruby/object:Gem::Version
143
145
  version: '0'
144
146
  requirements: []
145
- rubyforge_project:
146
- rubygems_version: 1.8.10
147
- signing_key:
148
- specification_version: 3
149
- summary: Extract developer's notes from source code.
147
+ rubygems_version: 3.6.9
148
+ specification_version: 4
149
+ summary: Extract developer's notes from source code
150
150
  test_files: []
data/.ruby DELETED
@@ -1,55 +0,0 @@
1
- ---
2
- source:
3
- - var
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:
19
- - test
20
- development: true
21
- - name: detroit
22
- groups:
23
- - build
24
- development: true
25
- - name: reap
26
- groups:
27
- - build
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.1
50
- name: dnote
51
- description: ! 'DNote makes it easy to extract developer''s notes from source code,
52
-
53
- and supports almost any language.'
54
- organization: RubyWorks
55
- date: '2012-01-10'
data/.yardopts DELETED
@@ -1,5 +0,0 @@
1
- --protected
2
- --private
3
- lib/**/*.rb
4
- -
5
- [A-Z]*.*
data/lib/dnote.yml DELETED
@@ -1,55 +0,0 @@
1
- ---
2
- source:
3
- - var
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:
19
- - test
20
- development: true
21
- - name: detroit
22
- groups:
23
- - build
24
- development: true
25
- - name: reap
26
- groups:
27
- - build
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.1
50
- name: dnote
51
- description: ! 'DNote makes it easy to extract developer''s notes from source code,
52
-
53
- and supports almost any language.'
54
- organization: RubyWorks
55
- date: '2012-01-10'