dnote 1.4.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/.ruby ADDED
@@ -0,0 +1,47 @@
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:
26
+ - test
27
+ name: lemon
28
+ version: 0+
29
+ - group:
30
+ - build
31
+ name: redline
32
+ version: 0+
33
+ - group:
34
+ - build
35
+ name: reap
36
+ version: 0+
37
+ manifest: MANIFEST
38
+ version: 1.6.0
39
+ licenses: []
40
+
41
+ copyright: Copyright (c) 2009 Thomas Sawyer
42
+ authors:
43
+ - Thomas Sawyer
44
+ 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
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
@@ -1,16 +1,46 @@
1
1
  = RELEASE HISTORY
2
2
 
3
+ == 1.6.0 / 2011-05-17
4
+
5
+ This release adds code conext output. Select the number of
6
+ context lines to display with the `-c` option. Currently
7
+ only the HTML, YAML and JSON formats support context.
8
+
9
+ This release also fixes the false note match that can arise when
10
+ a class or module name with double-colons starts a comment line.
11
+ We have changed the regex to ALWAYS REQUIRE a space after the
12
+ label colon. Please make a note of it!
13
+
14
+ Changes:
15
+
16
+ * Add code context count option and output.
17
+ * Regex changed to REQUIRE space after label colon.
18
+
19
+
20
+ == 1.5.0 / 2010-11-27
21
+
22
+ This release adds a `--url` option for defining a URL template
23
+ string used in certain HTML/XML formats. In addition a parsing
24
+ bug was corrected that limited some notes to one line.
25
+
26
+ Changes:
27
+
28
+ * Add support for configurable URLs.
29
+ * Fix multi-line note parsing bug.
30
+
31
+
3
32
  == 1.4.0 / 2010-06-26
4
33
 
5
34
  This release adds auto-determination of marker based on file
6
- extension. This mean DNote can now scan multiple file types
7
- in a single pass. The supported type are fairly small at this
8
- point, but will expand in the future. The fallback marker is '#'.
9
- You can still force a particular marker using the --marker option.
35
+ extension. This means DNote can now scan multiple file types
36
+ in a single pass. The supported types are fairly small at this
37
+ point, but cover the command cases and will expand in the future.
38
+ The fallback marker is '#'. You can still force a particular
39
+ marker using the --marker option.
10
40
 
11
41
  Changes:
12
42
 
13
- * Support for automatic markers.
43
+ * Add support for automatic markers.
14
44
 
15
45
 
16
46
  == 1.3.1 / 2010-06-11
@@ -1,8 +1,8 @@
1
1
  = D'Note
2
2
 
3
- * home: http://proutils.github.com/dnote
4
- * forum: http://googlegroups.com/group/proutils
5
- * source: http://github.com/proutils/dnote
3
+ * {Homepage}[http://rubyworks.github.com/dnote]
4
+ * {Mailing List}[http://googlegroups.com/group/rubyworks-mailinglist]
5
+ * {Source Code}[http://github.com/rubyworks/dnote]
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -15,7 +15,7 @@ output formats for them.
15
15
 
16
16
  === Note Structure
17
17
 
18
- D'Note scans for the common note patterns used by developers of many languages in the form of an
18
+ DNote scans for the common note patterns used by developers of many languages in the form of an
19
19
  all-caps labels followed by a colon. To be more specific, for D'Note to recognize a note,
20
20
  it needs to follow this simple set of rules:
21
21
 
@@ -25,7 +25,7 @@ it needs to follow this simple set of rules:
25
25
 
26
26
  2) Any note that requires more than one line must remain flush to the left
27
27
  margin (the margin is set by the first line). This is done because RDoc will mistake
28
- the note for a <tt>&lt;pre&gt;</tt> block if it is indented.
28
+ the note for a <code>pre</code> block if it is indented.
29
29
 
30
30
  # LABEL: description ...
31
31
  # continue ...
@@ -63,6 +63,8 @@ As you can see the commandline interface is pretty straight-forward.
63
63
  OTHER OPTIONS:
64
64
  -l, --label LABEL labels to collect
65
65
  --[no-]colon match labels with/without colon suffix
66
+ -m, --marker MARK alternative remark marker
67
+ -u --url TEMPLATE url template for line entries (for HTML)
66
68
  -x, --exclude PATH exclude file or directory
67
69
  -i, --ignore NAME ignore based on any part of the pathname
68
70
  -t, --title TITLE title to use in header
@@ -102,11 +104,19 @@ The usual RubyGem's command will do the trick.
102
104
  $ sudo gem install dnote
103
105
 
104
106
 
105
- == COPYRIGHTS
107
+ == COPYRIGHT
106
108
 
107
- (MIT License)
109
+ Copyright (c) 2006 Thomas Sawyer
108
110
 
109
- Copyright (c) 2006, 2009 Thomas Sawyer
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
110
114
 
111
- 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.
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.
112
122
 
@@ -1,27 +1,4 @@
1
- require 'yaml'
2
-
3
- module DNote
4
- DIRECTORY = File.dirname(__FILE__) + '/dnote'
5
-
6
- profile = YAML.load(File.new(DIRECTORY + '/profile.yml'))
7
- verfile = YAML.load(File.new(DIRECTORY + '/version.yml'))
8
-
9
- VERSION = verfile.values_at('major','minor','patch','state','build').compact.join('.')
10
-
11
- #
12
- def self.const_missing(name)
13
- key = name.to_s.downcase
14
- if verfile.key?(key)
15
- verfile[key]
16
- elsif profile.key?(key)
17
- profile[key]
18
- else
19
- super(name)
20
- end
21
- end
22
- end
23
-
1
+ require 'dnote/version'
24
2
  require 'dnote/session'
25
3
 
26
4
  # TEST: This is a test of arbitraty labels.
27
-
@@ -102,7 +102,7 @@ module DNote
102
102
 
103
103
  #
104
104
  def write(result, fname=nil)
105
- if output.end_with?('/') || File.directory?(output)
105
+ if output.to_s[-1,1] == '/' || File.directory?(output)
106
106
  fmt = format.split('/').first
107
107
  ext = EXTENSIONS[fmt] || fmt
108
108
  file = File.join(output, fname || "notes.#{ext}")
@@ -1,30 +1,59 @@
1
1
  module DNote
2
2
 
3
+ # The Note class encapsulates a single note made in a source file.
3
4
  #
5
+ # Each note instance holds a reference, +notes+, to the set of notes
6
+ # being generated for a given session. This allows the note to access
7
+ # general options applicable to all notes.
4
8
  class Note
9
+
10
+ # Number of lines to provide in source context.
11
+ #CONTEXT_DEPTH = 5
12
+
13
+ # Set of notes to which this note belongs.
14
+ attr :notes
15
+
16
+ # The file in which the note is made.
5
17
  attr :file
18
+
19
+ # The type of note.
6
20
  attr :label
21
+
22
+ # The line number of the note.
7
23
  attr :line
24
+
25
+ # The verbatim text of the note.
8
26
  attr :text
9
27
 
10
- def initialize(file, label, line, text)
11
- @file = file
12
- @label = label
13
- @line = line
14
- @text = text.rstrip
28
+ # Remark marker used in parsing the note.
29
+ attr :mark
30
+
31
+ # Contextual lines of code.
32
+ attr :capture
33
+
34
+ # Initialize new Note instance.
35
+ def initialize(notes, file, label, line, text, mark)
36
+ @notes = notes
37
+
38
+ @file = file
39
+ @label = label
40
+ @line = line
41
+ @text = text.rstrip
42
+ @mark = mark
43
+ @capture = []
15
44
  end
16
45
 
17
- #
46
+ # Convert to string representation.
18
47
  def to_s
19
48
  "#{label}: #{text}"
20
49
  end
21
50
 
22
- #
51
+ # Convert to string representation.
23
52
  def to_str
24
53
  "#{label}: #{text}"
25
54
  end
26
55
 
27
- #
56
+ # Remove newlines from note text.
28
57
  def textline
29
58
  text.gsub("\n", " ")
30
59
  end
@@ -36,22 +65,86 @@ module DNote
36
65
  line <=> other.line
37
66
  end
38
67
 
68
+ # Convert to Hash.
69
+ #--
70
+ # TODO: Add +url+?
71
+ # TODO: Add +code+? Problem is that xml needs code in CDATA.
72
+ #++
39
73
  def to_h
40
74
  { 'label'=>label, 'text'=>textline, 'file'=>file, 'line'=>line }
41
75
  end
42
76
 
77
+ # Convert to Hash, leaving the note text verbatim.
43
78
  def to_h_raw
44
- { 'label'=>label, 'text'=>text, 'file'=>file, 'line'=>line }
79
+ { 'label'=>label, 'text'=>text, 'file'=>file, 'line'=>line, 'code'=>code }
45
80
  end
46
81
 
82
+ # Convert to JSON.
47
83
  def to_json(*args)
48
84
  to_h_raw.to_json(*args)
49
85
  end
50
86
 
87
+ # Convert to YAML.
51
88
  def to_yaml(*args)
52
89
  to_h_raw.to_yaml(*args)
53
90
  end
91
+
92
+ # Return line URL based on URL template. If no template was set, then
93
+ # returns the file.
94
+ def url
95
+ if notes.url
96
+ notes.url % [file, line]
97
+ else
98
+ file
99
+ end
100
+ end
101
+
102
+ #
103
+ def code
104
+ unindent(capture).join
105
+ end
106
+
107
+ # Is there code to show?
108
+ def code?
109
+ !capture.empty?
110
+ end
111
+
112
+ =begin
113
+ # This isn't being used currently b/c the URL solution as deeemd better,
114
+ # but the code is here for custom templates.
115
+ def capture
116
+ @context ||= (
117
+ lines = file_cache(file) #.lines.to_a
118
+ count = line()
119
+ count +=1 while /^\s*#{mark}/ =~ lines[count]
120
+ lines[count, context_depth]
121
+ )
122
+ end
123
+
124
+ # Read in +file+, parse into lines and cache.
125
+ def file_cache(file)
126
+ @@file_cache ||= {}
127
+ @@file_cache[file] ||= File.read(file).lines.to_a
128
+ end
129
+ =end
130
+
131
+ private
132
+
133
+ # Remove blank space from lines.
134
+ def unindent(lines)
135
+ dents = []
136
+ lines.each do |line|
137
+ if md = /^([\ ]*)/.match(line)
138
+ size = md[1].size
139
+ dents << md[1]
140
+ end
141
+ end
142
+ dent = dents.min{ |a,b| a.size <=> b.size }
143
+ lines.map do |line|
144
+ line.sub(dent, '')
145
+ end
146
+ end
147
+
54
148
  end
55
149
 
56
150
  end
57
-