mvz-dnote 1.7.2 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/HISTORY.rdoc +5 -0
- data/README.md +119 -0
- data/bin/dnote +11 -2
- data/lib/dnote.rb +2 -0
- data/lib/dnote/core_ext.rb +11 -67
- data/lib/dnote/format.rb +35 -51
- data/lib/dnote/note.rb +17 -42
- data/lib/dnote/notes.rb +60 -101
- data/lib/dnote/rake/dnotetask.rb +22 -38
- data/lib/dnote/session.rb +49 -70
- data/lib/dnote/version.rb +3 -15
- metadata +22 -13
- data/README.rdoc +0 -113
- data/lib/dnote.yml +0 -1
- data/try/sample.bas +0 -7
- data/try/sample.js +0 -11
- data/try/sample.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5b9675201f53edcd5b27e0121bd08844769047c613d3d92b44b7ec9326e2f49d
|
4
|
+
data.tar.gz: 0b386e81dea084ee1618d6fd13fe48b5a8c15ec6be9a420442880f715956c05a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfe4a7bb7d9fb549025519ee59030c863e3a4c9242a55f96bdbb5dc17d93d9eae569f09f16ed39a3fb107382b753fc307cf2c8fad543bc7c819cba85f7a1010b
|
7
|
+
data.tar.gz: 190179a14bcddc1ae626107c05237afc6adce940e2c72047b3a7e4f3348c0646bb82c59ed4984357feb716113c068d749819005d7247f48536e15549efff6fae
|
data/HISTORY.rdoc
CHANGED
data/README.md
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
# DNote
|
2
|
+
|
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
|
+
|
7
|
+
[![Gem Version](https://badge.fury.io/rb/mvz-dnote.svg)](https://badge.fury.io/rb/mvz-dnote)
|
8
|
+
[![Build Status](https://travis-ci.org/mvz/mvz-dnote.svg?branch=master)](https://travis-ci.org/mvz/mvz-dnote)
|
9
|
+
[![Coverage Status](https://coveralls.io/repos/github/mvz/mvz-dnote/badge.svg?branch=master)](https://coveralls.io/github/mvz/mvz-dnote?branch=master)
|
10
|
+
[![Dependency Status](https://gemnasium.com/badges/github.com/mvz/mvz-dnote.svg)](https://gemnasium.com/github.com/mvz/mvz-dnote)
|
11
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/608621bbad5de3a98e3b/maintainability)](https://codeclimate.com/github/mvz/dnote/maintainability)
|
12
|
+
|
13
|
+
## DESCRIPTION
|
14
|
+
|
15
|
+
Extract development notes from source code and generate some nice
|
16
|
+
output formats for them.
|
17
|
+
|
18
|
+
|
19
|
+
## SYNOPSIS
|
20
|
+
|
21
|
+
### Note Structure
|
22
|
+
|
23
|
+
DNote scans for the common note patterns used by developers of many languages in the form of an
|
24
|
+
all-caps labels followed by a colon. To be more specific, for DNote to recognize a note,
|
25
|
+
it needs to follow this simple set of rules:
|
26
|
+
|
27
|
+
1. Notes start with an all-caps label punctuated with a colon, followed by the note's text.
|
28
|
+
|
29
|
+
# LABEL: description ...
|
30
|
+
|
31
|
+
2. Any note that requires more than one line must remain flush to the left
|
32
|
+
margin (the margin is set by the first line). This is done because RDoc will mistake
|
33
|
+
the note for a `pre` block if it is indented.
|
34
|
+
|
35
|
+
# LABEL: description ...
|
36
|
+
# continue ...
|
37
|
+
|
38
|
+
3. An alternative to the previous limitation is to indent the whole note, making it
|
39
|
+
a `<pre>` block when rendered by RDoc. Then the text layout is free-form.
|
40
|
+
|
41
|
+
# This is a description of something...
|
42
|
+
#
|
43
|
+
# LABEL: description ...
|
44
|
+
# continue ...
|
45
|
+
|
46
|
+
That's all there is to it, if I can convince the developers of RDoc to recognize labels,
|
47
|
+
we may eventually be able to relax the flush rule too, which would be very nice.
|
48
|
+
|
49
|
+
There is also a command-line option, `--no-colon`, which deactives the need for
|
50
|
+
a colon after the note label. However this often produces false positives, so its use is
|
51
|
+
discouraged.
|
52
|
+
|
53
|
+
### Generating Notes
|
54
|
+
|
55
|
+
As you can see the commandline interface is pretty straight-forward.
|
56
|
+
|
57
|
+
USAGE:
|
58
|
+
|
59
|
+
dnote [OPTIONS] path1 [path2 ...]
|
60
|
+
|
61
|
+
OUTPUT FORMAT: (choose one)
|
62
|
+
-f, --format NAME select a format [text]
|
63
|
+
-c, --custom FILE use a custom ERB template
|
64
|
+
--file shortcut for text/file format
|
65
|
+
--list shortcut for text/list format
|
66
|
+
|
67
|
+
OTHER OPTIONS:
|
68
|
+
-l, --label LABEL labels to collect
|
69
|
+
--[no-]colon match labels with/without colon suffix
|
70
|
+
-m, --marker MARK alternative remark marker
|
71
|
+
-u --url TEMPLATE url template for line entries (for HTML)
|
72
|
+
-x, --exclude PATH exclude file or directory
|
73
|
+
-i, --ignore NAME ignore based on any part of the pathname
|
74
|
+
-t, --title TITLE title to use in header
|
75
|
+
-o, --output PATH name of file or directory
|
76
|
+
-n, --dryrun do not actually write to disk
|
77
|
+
--debug debug mode
|
78
|
+
|
79
|
+
COMMAND OPTIONS:
|
80
|
+
-T, --templates list available format templates
|
81
|
+
-h, --help show this help information
|
82
|
+
|
83
|
+
The default path is `**/*.rb` and the default format is `-f text`.
|
84
|
+
Here is an example of DNote's current notes in RDoc format:
|
85
|
+
|
86
|
+
= Development Notes
|
87
|
+
|
88
|
+
== TODO
|
89
|
+
|
90
|
+
=== file://lib/dnote/notes.rb
|
91
|
+
|
92
|
+
* TODO: Add ability to read header notes. They often
|
93
|
+
have a outline format, rather then the single line. (19)
|
94
|
+
* TODO: Need good CSS file. (22)
|
95
|
+
* TODO: Need XSL? (24)
|
96
|
+
|
97
|
+
=== file://plug/syckle/services/dnote.rb
|
98
|
+
|
99
|
+
* TODO: Should this service be part of the +site+ cycle? (18)
|
100
|
+
|
101
|
+
(4 TODOs)
|
102
|
+
|
103
|
+
|
104
|
+
## INSTALLATION
|
105
|
+
|
106
|
+
The usual rubygems command will do the trick.
|
107
|
+
|
108
|
+
$ gem install mvz-dnote
|
109
|
+
|
110
|
+
|
111
|
+
## COPYRIGHT
|
112
|
+
|
113
|
+
Copyright (c) 2006 Thomas Sawyer, Rubyworks
|
114
|
+
|
115
|
+
Copyright (c) 2017-2018 Matijs van Zuijlen
|
116
|
+
|
117
|
+
DNote is distributable in accordance with the terms of the *FreeBSD* license.
|
118
|
+
|
119
|
+
See COPYING.rdoc for details.
|
data/bin/dnote
CHANGED
data/lib/dnote.rb
CHANGED
data/lib/dnote/core_ext.rb
CHANGED
@@ -1,92 +1,36 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# Taken from Ruby Facets.
|
4
|
-
def group_by #:yield:
|
5
|
-
#h = k = e = nil
|
6
|
-
r = Hash.new
|
7
|
-
each{ |e| (r[yield(e)] ||= []) << e }
|
8
|
-
r
|
9
|
-
end unless method_defined?(:group_by)
|
10
|
-
|
11
|
-
end
|
1
|
+
# frozen_string_literal: true
|
12
2
|
|
13
3
|
module DNote
|
14
|
-
|
15
4
|
# Extensions for String class.
|
16
5
|
# These methods are taken directly from Ruby Facets.
|
17
6
|
#
|
18
7
|
module StringExt
|
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.
|
8
|
+
# Indent left or right by num spaces.
|
60
9
|
# (This used to be called #tab and aliased as #indent.)
|
61
10
|
#
|
62
11
|
# CREDIT: Gavin Sinclair
|
63
12
|
# CREDIT: Trans
|
64
13
|
|
65
|
-
def indent(
|
66
|
-
if
|
67
|
-
gsub(/^/, ' ' *
|
14
|
+
def indent(num)
|
15
|
+
if num >= 0
|
16
|
+
gsub(/^/, ' ' * num)
|
68
17
|
else
|
69
|
-
gsub(/^ {0,#{-
|
18
|
+
gsub(/^ {0,#{-num}}/, '')
|
70
19
|
end
|
71
20
|
end
|
72
21
|
|
73
|
-
|
74
|
-
#
|
75
|
-
def tabset(n)
|
22
|
+
def tabset(num)
|
76
23
|
i = lines.map do |line|
|
77
24
|
line.strip.empty? ? nil : line.index(/\S/)
|
78
25
|
end
|
79
26
|
x = i.compact.min
|
80
|
-
t =
|
27
|
+
t = num - x.to_i
|
81
28
|
t = 0 if t < 0
|
82
29
|
indent(t)
|
83
30
|
end
|
84
|
-
|
85
31
|
end
|
86
|
-
|
87
|
-
class ::String #:nodoc:
|
88
|
-
include DNote::StringExt
|
89
|
-
end
|
90
|
-
|
91
32
|
end
|
92
33
|
|
34
|
+
String.class_eval do
|
35
|
+
include DNote::StringExt
|
36
|
+
end
|
data/lib/dnote/format.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
module DNote
|
3
4
|
# = Notes Formatter
|
4
5
|
#
|
5
6
|
#--
|
@@ -8,49 +9,37 @@ module DNote
|
|
8
9
|
# TODO: Need XSL?
|
9
10
|
#++
|
10
11
|
class Format
|
11
|
-
|
12
12
|
require 'fileutils'
|
13
13
|
require 'erb'
|
14
14
|
require 'rexml/text'
|
15
15
|
require 'dnote/core_ext'
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
EXTENSIONS = { 'text'=>'txt', 'soap'=>'xml', 'xoxo'=>'xml' }
|
17
|
+
EXTENSIONS = { 'text' => 'txt', 'soap' => 'xml', 'xoxo' => 'xml' }.freeze
|
20
18
|
|
21
|
-
|
22
|
-
attr :notes
|
19
|
+
attr_reader :notes
|
23
20
|
|
24
|
-
#
|
25
21
|
attr_accessor :format
|
26
22
|
|
27
|
-
#
|
28
23
|
attr_accessor :subtype
|
29
24
|
|
30
|
-
#
|
31
25
|
attr_accessor :output
|
32
26
|
|
33
|
-
#
|
34
27
|
attr_accessor :template
|
35
28
|
|
36
|
-
#
|
37
29
|
attr_accessor :title
|
38
30
|
|
39
|
-
#
|
40
31
|
attr_accessor :dryrun
|
41
32
|
|
42
|
-
|
43
|
-
def initialize(notes, options={})
|
33
|
+
def initialize(notes, options = {})
|
44
34
|
@notes = notes
|
45
35
|
@format = 'text'
|
46
36
|
@subtype = 'label'
|
47
37
|
@title = "Developer's Notes"
|
48
38
|
@dryrun = false
|
49
|
-
options.each{ |k,v| __send__("#{k}=", v) if v }
|
39
|
+
options.each { |k, v| __send__("#{k}=", v) if v }
|
50
40
|
yield(self) if block_given?
|
51
41
|
end
|
52
42
|
|
53
|
-
#
|
54
43
|
def render
|
55
44
|
if notes.empty?
|
56
45
|
$stderr << "No #{notes.labels.join(', ')} notes.\n"
|
@@ -66,44 +55,39 @@ module DNote
|
|
66
55
|
|
67
56
|
# C U S T O M
|
68
57
|
|
69
|
-
#
|
70
58
|
def render_custom
|
71
|
-
#raise ArgumentError unless File.exist?(template)
|
72
59
|
result = erb(template)
|
73
|
-
publish(result)
|
60
|
+
publish(result)
|
74
61
|
end
|
75
62
|
|
76
63
|
# T E M P L A T E
|
77
64
|
|
78
|
-
#
|
79
65
|
def render_template
|
80
66
|
template = File.join(File.dirname(__FILE__), 'templates', "#{format}.erb")
|
81
67
|
raise "No such format - #{format}" unless File.exist?(template)
|
68
|
+
|
82
69
|
result = erb(template)
|
83
|
-
publish(result)
|
70
|
+
publish(result)
|
84
71
|
end
|
85
72
|
|
86
|
-
|
73
|
+
private
|
87
74
|
|
88
|
-
#
|
89
75
|
def erb(file)
|
90
|
-
scope = ErbScope.new(:notes
|
76
|
+
scope = ErbScope.new(notes: notes, title: title)
|
91
77
|
scope.render(file)
|
92
78
|
end
|
93
79
|
|
94
|
-
|
95
|
-
def publish(result, fname=nil)
|
80
|
+
def publish(result, fname = nil)
|
96
81
|
if output
|
97
82
|
write(result, fname)
|
98
83
|
else
|
99
84
|
puts(result)
|
100
85
|
end
|
101
|
-
$stderr <<
|
86
|
+
$stderr << '(' + notes.counts.map { |l, n| "#{n} #{l}s" }.join(', ') + ")\n"
|
102
87
|
end
|
103
88
|
|
104
|
-
|
105
|
-
|
106
|
-
if output.to_s[-1,1] == '/' || File.directory?(output)
|
89
|
+
def write(result, fname = nil)
|
90
|
+
if output.to_s[-1, 1] == '/' || File.directory?(output)
|
107
91
|
fmt = format.split('/').first
|
108
92
|
ext = EXTENSIONS[fmt] || fmt
|
109
93
|
file = File.join(output, fname || "notes.#{ext}")
|
@@ -116,25 +100,22 @@ module DNote
|
|
116
100
|
else
|
117
101
|
dir = File.dirname(file)
|
118
102
|
fu.mkdir(dir) unless File.exist?(dir)
|
119
|
-
File.open(file, 'w'){ |f| f << result }
|
103
|
+
File.open(file, 'w') { |f| f << result }
|
120
104
|
end
|
121
|
-
|
105
|
+
file
|
122
106
|
end
|
123
107
|
|
124
|
-
#
|
125
108
|
def dryrun?
|
126
109
|
@dryrun
|
127
110
|
end
|
128
111
|
|
129
|
-
#
|
130
112
|
def debug?
|
131
113
|
$DEBUG
|
132
114
|
end
|
133
115
|
|
134
|
-
#
|
135
116
|
def fu
|
136
|
-
@fu ||=
|
137
|
-
if dryrun?
|
117
|
+
@fu ||= begin
|
118
|
+
if dryrun? && debug?
|
138
119
|
FileUtils::DryRun
|
139
120
|
elsif dryrun?
|
140
121
|
FileUtils::Noop
|
@@ -143,31 +124,34 @@ module DNote
|
|
143
124
|
else
|
144
125
|
FileUtils
|
145
126
|
end
|
146
|
-
|
127
|
+
end
|
147
128
|
end
|
148
129
|
|
149
|
-
#
|
150
|
-
class ErbScope
|
151
|
-
|
152
|
-
def initialize(data={})
|
130
|
+
# Evaluation scope for ERB templates
|
131
|
+
class ErbScope
|
132
|
+
def initialize(data = {})
|
153
133
|
@data = data
|
154
134
|
end
|
155
|
-
|
135
|
+
|
156
136
|
def render(file)
|
157
137
|
erb = ERB.new(File.read(file), nil, '<>')
|
158
138
|
erb.result(binding)
|
159
139
|
end
|
160
|
-
|
140
|
+
|
161
141
|
def h(string)
|
162
142
|
REXML::Text.normalize(string)
|
163
143
|
end
|
164
|
-
|
165
|
-
def method_missing(
|
166
|
-
|
144
|
+
|
145
|
+
def method_missing(method, *_args)
|
146
|
+
sym = method.to_sym
|
147
|
+
return @data.fetch(sym) if @data.key? sym
|
148
|
+
|
149
|
+
super
|
167
150
|
end
|
168
|
-
end
|
169
151
|
|
152
|
+
def respond_to_missing?(method)
|
153
|
+
@data.key? method.to_sym
|
154
|
+
end
|
155
|
+
end
|
170
156
|
end
|
171
|
-
|
172
157
|
end
|
173
|
-
|