diff --git a/.gemspec b/.gemspec deleted file mode 100644 index 72f376e..0000000 --- a/.gemspec +++ /dev/null @@ -1,136 +0,0 @@ -# encoding: utf-8 - -require 'yaml' - -metadata = YAML.load_file('.ruby') - -manifest = Dir.glob('manifest{,.txt}', File::FNM_CASEFOLD).first - - -Gem::Specification.new do |gemspec| - - scm = case - when File.directory?('.git') - :git - end - - files = case - when manifest - File.readlines(manifest). - map{ |line| line.strip }. - reject{ |line| line.empty? || line[0,1] == '#' } - when scm == :git - `git ls-files -z`.split("\0") - else - Dir.glob('{**/}{.*,*}') # TODO: be more specific using standard locations ? - end.select{ |path| File.file?(path) } - - patterns = { - :bin_files => 'bin/*', - :lib_files => 'lib/{**/}*.rb', - :ext_files => 'ext/{**/}extconf.rb', - :doc_files => '*.{txt,rdoc,md,markdown,tt,textile}', - :test_files => '{test/{**/}*_test.rb,spec/{**/}*_spec.rb}' - } - - glob_files = lambda { |pattern| - Dir.glob(pattern).select { |path| - File.file?(path) && files.include?(path) - } - } - - #files = glob_files[patterns[:files]] - - executables = glob_files[patterns[:bin_files]].map do |path| - File.basename(path) - end - - extensions = glob_files[patterns[:ext_files]].map do |path| - File.basename(path) - end - - # build-out the gemspec - - case metadata['revision'] - when 0 - gemspec.name = metadata['name'] - gemspec.version = metadata['version'] - gemspec.summary = metadata['summary'] - gemspec.description = metadata['description'] - - metadata['authors'].each do |author| - gemspec.authors << author['name'] - - if author.has_key?('email') - if gemspec.email - gemspec.email << author['email'] - else - gemspec.email = [author['email']] - end - end - end - - gemspec.licenses = metadata['copyrights'].map{ |c| c['license'] }.compact - - metadata['requirements'].each do |req| - name = req['name'] - version = req['version'] - groups = req['groups'] || [] - - case version - when /^(.*?)\+$/ - version = ">= #{$1}" - when /^(.*?)\-$/ - version = "< #{$1}" - when /^(.*?)\~$/ - version = "~> #{$1}" - end - - if groups.empty? or groups.include?('runtime') - # populate runtime dependencies - if gemspec.respond_to?(:add_runtime_dependency) - gemspec.add_runtime_dependency(name,*version) - else - gemspec.add_dependency(name,*version) - end - else - # populate development dependencies - if gemspec.respond_to?(:add_development_dependency) - gemspec.add_development_dependency(name,*version) - else - gemspec.add_dependency(name,*version) - end - end - end - - # convert external dependencies into a requirements - if metadata['external_dependencies'] - ##gemspec.requirements = [] unless metadata['external_dependencies'].empty? - metadata['external_dependencies'].each do |req| - gemspec.requirements << req.to_s - end - end - - # determine homepage from resources - homepage = metadata['resources'].find{ |key, url| key =~ /^home/ } - gemspec.homepage = homepage.last if homepage - - gemspec.require_paths = metadata['load_path'] || ['lib'] - gemspec.post_install_message = metadata['install_message'] - - # RubyGems specific metadata - gemspec.files = files - gemspec.extensions = extensions - gemspec.executables = executables - - if Gem::VERSION < '1.7.' - gemspec.default_executable = gemspec.executables.first - end - - gemspec.test_files = glob_files[patterns[:test_files]] - - unless gemspec.files.include?('.document') - gemspec.extra_rdoc_files = glob_files[patterns[:doc_files]] - end - end -end diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 5fe6d03..0000000 --- a/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -.reap/digest -.yardoc -doc -log -pkg -ri -tmp -site/doc -web \ No newline at end of file diff --git a/.reap/ignore b/.reap/ignore deleted file mode 100644 index 0b0eadf..0000000 --- a/.reap/ignore +++ /dev/null @@ -1,2 +0,0 @@ -ri -work diff --git a/.reap/pack.reap b/.reap/pack.reap deleted file mode 100644 index c1a379d..0000000 --- a/.reap/pack.reap +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env ruby - -trip :pack do - system "gem build .gemspec" - system "mv *.gem pkg/" -end - diff --git a/.reap/spec.reap b/.reap/spec.reap deleted file mode 100644 index 251daac..0000000 --- a/.reap/spec.reap +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby - -file "Profile", "Version" do - system "pom spec -u" - system "pom gemspec -u" -end - -#file "Version" do -# system "pom spec -u" -# system "pom gemspec -u" -#end - -file "Manifest", "MANIFEST" do - system "pom gemspec -u" -end - diff --git a/.reap/test.reap b/.reap/test.reap deleted file mode 100644 index 2792a37..0000000 --- a/.reap/test.reap +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env ruby - -file "lib/**/*.rb" do - system "lemon -Ilib test/*_case.rb" -end - -trip :test do - system "lemon -Ilib test/*_case.rb" -end - diff --git a/.rsync-filter b/.rsync-filter new file mode 100644 index 0000000..62c9380 --- /dev/null +++ b/.rsync-filter @@ -0,0 +1,8 @@ +- .svn +- scrap +P wiki +P robot.txt +P robots.txt +P statcvs +P statsvn +P usage diff --git a/.ruby b/.ruby deleted file mode 100644 index 1407272..0000000 --- a/.ruby +++ /dev/null @@ -1,55 +0,0 @@ ---- -source: -- var -authors: -- name: Thomas Sawyer - email: transfire@gmail.com -copyrights: -- holder: Thomas Sawyer, Rubyworks - year: '2009' -replacements: [] -alternatives: [] -requirements: -- name: lemon - groups: - - test - development: true -- name: ae - groups: - - test - development: true -- name: detroit - groups: - - build - development: true -- name: reap - groups: - - build - development: true -dependencies: [] -conflicts: [] -repositories: -- uri: git://github.com/rubyworks/dnote.git - scm: git - name: upstream -resources: - home: http://rubyworks.github.com/dnote - code: http://github.com/rubyworks/dnote - wiki: http://wiki.github.com/rubyworks/dnote - api: http://rubydoc.info/gems/dnote - bugs: http://github.com/rubyworks/dnote/issues - mail: http://groups.google.com/groups/rubyworks-mailinglist -extra: {} -load_path: -- lib -revision: 0 -created: '2009-10-09' -summary: Extract developer's notes from source code. -title: DNote -version: 1.7.0 -name: dnote -description: ! 'DNote makes it easy to extract developer''s notes from source code, - - and supports almost any language.' -organization: RubyWorks -date: '2011-11-11' diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 012d328..0000000 --- a/.travis.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -rvm: - - 1.8.7 - - 1.9.2 - - 1.9.3 - - rbx-2.0 - - jruby - - ree -script: "bundle exec ruby-test test/*.rb" - diff --git a/.yardopts b/.yardopts deleted file mode 100644 index 9a47033..0000000 --- a/.yardopts +++ /dev/null @@ -1,5 +0,0 @@ ---protected ---private -lib/**/*.rb -- -[A-Z]*.* diff --git a/Assembly b/Assembly deleted file mode 100644 index 2be838d..0000000 --- a/Assembly +++ /dev/null @@ -1,35 +0,0 @@ ---- -email: - service : Email - mailto : - - ruby-talk@ruby-lang.org - - rubyworks-mailinglist@googlegroups.com - -gem: - active: true - -github: - gh_pages: web - -yard: - priority: 2 - -dnote: - labels : ~ - lines : 5 - output : - - log/NOTES.rdoc - -vclog: - output: - - log/Changes.rdoc - - log/History.rdoc - -#lemon: -# tests : ~ -# exclude : ~ -# loadpath : ~ -# requires : ~ -# live : false -# active : false - diff --git a/COPYING.rdoc b/COPYING.rdoc deleted file mode 100644 index 9930cb5..0000000 --- a/COPYING.rdoc +++ /dev/null @@ -1,31 +0,0 @@ -= COPYRIGHT NOTICES - -== DNote - -Copyright:: (c) 2006 Thomas Sawyer, Rubyworks -License:: BSD-2-Clause -Website:: http://rubyworks.github.com/tapout - - Copyright 2006 Thomas Sawyer, Rubyworks. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/Gemfile b/Gemfile deleted file mode 100644 index e45e65f..0000000 --- a/Gemfile +++ /dev/null @@ -1,2 +0,0 @@ -source :rubygems -gemspec diff --git a/HISTORY.rdoc b/HISTORY.rdoc deleted file mode 100644 index 203ce65..0000000 --- a/HISTORY.rdoc +++ /dev/null @@ -1,171 +0,0 @@ -= RELEASE HISTORY - - -== 1.7.0 / 2011-10-25 - -This release finishes adding code context support to all formats. Use the `-c` -option to set the number of lines to include. Note also that the rake task has -been moved to `dnote/rake/dnotetask`. - -Changes: - -* Support code contexts in all formats. -* Rake task moved to `dnote/rake/dnotetask`. - - -== 1.6.1 / 2011-05-18 - -Last release reused the `-c` option for context lines. This clobbered -the shortcut option for `--custom`. To fix, this release capitalizes -the custom shortcut to `-C`. - -Changes: - -* Capitalize custom shortcut option (-c becomes -C). - - -== 1.6.0 / 2011-05-17 - -This release adds code conext output. Select the number of -context lines to display with the `-c` option. Currently -only the HTML, YAML and JSON formats support context. - -This release also fixes the false note match that can arise when -a class or module name with double-colons starts a comment line. -We have changed the regex to ALWAYS REQUIRE a space after the -label colon. Please make a note of it! - -Changes: - -* Add code context count option and output. -* Regex changed to REQUIRE space after label colon. - - -== 1.5.0 / 2010-11-27 - -This release adds a `--url` option for defining a URL template -string used in certain HTML/XML formats. In addition a parsing -bug was corrected that limited some notes to one line. - -Changes: - -* Add support for configurable URLs. -* Fix multi-line note parsing bug. - - -== 1.4.0 / 2010-06-26 - -This release adds auto-determination of marker based on file -extension. This means DNote can now scan multiple file types -in a single pass. The supported types are fairly small at this -point, but cover the command cases and will expand in the future. -The fallback marker is '#'. You can still force a particular -marker using the --marker option. - -Changes: - -* Add support for automatic markers. - - -== 1.3.1 / 2010-06-11 - -This release fixes a simple bug. Some version of Ruby do not have -the Enumerable#group_by method. This release provides it if it is -missing. - -Changes: - -* Bug fix, provide #group_by when it is not present. - - -== 1.3.0 / 2010-06-04 - -This release adds support for alternate comment markers. Simply -supply the marker with the -m option. - -Changes: - -* Add support for languages other than Ruby. - - -== 1.2.0 / 2010-02-18 - -By request this release adds additional formats, allowing notes to be -sorted by filename as well a label. In addition, paths can now be -excluded from the search. To implement these changes it was necessary -to makes some significant under-the-hood adjustments, and this required -making some adjustments to the design of the templates and the -command-line interface. - -If are using any of your own custom templates you will have to make -adjustments accordingly --which basically entails exchanging +notes.each+ -for +notes.by_label_file.each+. Also, notice that the serialization formats -have changed accordingly to match the improved underlying model. - -On the command-line, the format type itself is no longer used as the -option name, e.g. "--yaml", but instead use "-f", e.g. "-f yaml". This -opens DNote up to many more templates. Use "-T" to get a list of all -template format available. - -Changes: - -* Improve underlying model by adding a Note class. -* Add --exclude and --ignore options. -* Add new formats and rename "gnu" formats to "text". -* Use --format/-f to designate formats. -* Renamed --template/-t option to --custom/-c. -* Add --templates/-T to list all format templates. - - -== 1.1.0 / 2010-02-06 - -This relase primarily adjusts the way output it rendered -underthehood. Serialization formats are rendered as -before but markup formats now use Erb. In the process -two new serialization formats have been added: soap and xoxo. - -Also, this release renames the lib/plugin directory to -lib/plugins (plural) per the new convention of the latest -Plugin gem. This only matters to Syckle users. - -Changes: - -* Add Soap and XOXO formats. -* Add actual --output option. -* Move lib/plugin to lib/plugins. - - -== 1.0.0 / 2009-10-25 - -This relase adds support for arbitrary note labels. -Any all-caps word followed by a colon will be -picked-up. Common labels like TODO and FIXME are -recognized without the trailing ':'. - -Changes: - -* Added support for arbitrary labels. - - -== 0.9.0 / 2009-10-10 - -This release adds a syckle plugin and improves output. - -Changes: - -* Add syckle plugin, based on old Notes plugin. -* Improved HTML output ( tag should have been ). -* If output not specified, sends rdoc to stdout. -* If no paths specified, will scan '**/*.rb' - - -== 0.8.0 / 2009-10-09 - -This is the initial release of DNote. DNote is a spin-off -of a Syckle (formerlly Reap) plugin which scans source -code and compiles a list of developer notes. - -Changes: - -* Happy Birthday! - diff --git a/MANIFEST b/MANIFEST deleted file mode 100644 index 1720ec2..0000000 --- a/MANIFEST +++ /dev/null @@ -1,55 +0,0 @@ -#!mast .ruby .yardopts bin lib man spec test try [A-Z]*.* -.ruby -.yardopts -bin/dnote -lib/dnote/core_ext.rb -lib/dnote/format.rb -lib/dnote/note.rb -lib/dnote/notes.rb -lib/dnote/rake/dnotetask.rb -lib/dnote/session.rb -lib/dnote/templates/html/file.erb -lib/dnote/templates/html/label.erb -lib/dnote/templates/html/list.erb -lib/dnote/templates/html.erb -lib/dnote/templates/json/file.erb -lib/dnote/templates/json/label.erb -lib/dnote/templates/json/list.erb -lib/dnote/templates/json.erb -lib/dnote/templates/md/file.erb -lib/dnote/templates/md/label.erb -lib/dnote/templates/md/list.erb -lib/dnote/templates/md.erb -lib/dnote/templates/rdoc/file.erb -lib/dnote/templates/rdoc/label.erb -lib/dnote/templates/rdoc/list.erb -lib/dnote/templates/rdoc.erb -lib/dnote/templates/soap/file.erb -lib/dnote/templates/soap/label.erb -lib/dnote/templates/soap/list.erb -lib/dnote/templates/soap.erb -lib/dnote/templates/text/file.erb -lib/dnote/templates/text/label.erb -lib/dnote/templates/text/list.erb -lib/dnote/templates/text.erb -lib/dnote/templates/xml/file.erb -lib/dnote/templates/xml/label.erb -lib/dnote/templates/xml/list.erb -lib/dnote/templates/xml.erb -lib/dnote/templates/xoxo/file.erb -lib/dnote/templates/xoxo/label.erb -lib/dnote/templates/xoxo/list.erb -lib/dnote/templates/xoxo.erb -lib/dnote/templates/yaml/file.erb -lib/dnote/templates/yaml/label.erb -lib/dnote/templates/yaml/list.erb -lib/dnote/templates/yaml.erb -lib/dnote/version.rb -lib/dnote.rb -test/notes_case.rb -try/sample.bas -try/sample.js -try/sample.rb -HISTORY.rdoc -README.rdoc -COPYING.rdoc diff --git a/README.rdoc b/README.rdoc deleted file mode 100644 index d2103db..0000000 --- a/README.rdoc +++ /dev/null @@ -1,113 +0,0 @@ -= DNote - -* {Homepage}[http://rubyworks.github.com/dnote] -* {Mailing List}[http://googlegroups.com/group/rubyworks-mailinglist] -* {Source Code}[http://github.com/rubyworks/dnote] - - -== DESCRIPTION - -Extract development notes from source code and generate some nice -output formats for them. - - -== SYNOPSIS - -=== Note Structure - -DNote scans for the common note patterns used by developers of many languages in the form of an -all-caps labels followed by a colon. To be more specific, for DNote to recognize a note, -it needs to follow this simple set of rules: - -1) Notes start with an all-caps label punctuated with a colon, followed by the note's text. - - # LABEL: description ... - -2) Any note that requires more than one line must remain flush to the left -margin (the margin is set by the first line). This is done because RDoc will mistake -the note for a pre block if it is indented. - - # LABEL: description ... - # continue ... - -3) An alternative to the previous limitation is to indent the whole note, making it -a <pre> block when rendered by RDoc. Then the text layout is free-form. - - # This is a description of something... - # - # LABEL: description ... - # continue ... - -That's all there is to it, if I can convince the developers of RDoc to recognize labels, -we may eventually be able to relax the flush rule too, which would be very nice. - -There is also a command-line option, --no-colon, which deactives the need for -a colon after the note label. However this often produces false positives, so it's use is -discouraged. - - -=== Generating Notes - -As you can see the commandline interface is pretty straight-forward. - - USAGE: - - dnote [OPTIONS] path1 [path2 ...] - - OUTPUT FORMAT: (choose one) - -f, --format NAME select a format [text] - -c, --custom FILE use a custom ERB template - --file shortcut for text/file format - --list shortcut for text/list format - - OTHER OPTIONS: - -l, --label LABEL labels to collect - --[no-]colon match labels with/without colon suffix - -m, --marker MARK alternative remark marker - -u --url TEMPLATE url template for line entries (for HTML) - -x, --exclude PATH exclude file or directory - -i, --ignore NAME ignore based on any part of the pathname - -t, --title TITLE title to use in header - -o, --output PATH name of file or directory - -n, --dryrun do not actually write to disk - --debug debug mode - - COMMAND OPTIONS: - -T, --templates list available format templates - -h, --help show this help information - -The default path is **/*.rb and the default format is -f rdoc. -Here is an example of DNote's current notes in RDoc format: - - = Development Notes - - == TODO - - === file://lib/dnote/notes.rb - - * TODO: Add ability to read header notes. They often - have a outline format, rather then the single line. (19) - * TODO: Need good CSS file. (22) - * TODO: Need XSL? (24) - - === file://plug/syckle/services/dnote.rb - - * TODO: Should this service be part of the +site+ cycle? (18) - - (4 TODOs) - - -== INSTALLATION - -The usual RubyGem's command will do the trick. - - $ sudo gem install dnote - - -== COPYRIGHT - -Copyright (c) 2006 Thomas Sawyer, Rubyworks - -DNote is distributable in accordance with the terms of the *FreeBSD* license. - -See COPYING.rdoc for details. diff --git a/assets/images/fork-me.png b/assets/images/fork-me.png new file mode 100644 index 0000000..146ef8a Binary files /dev/null and b/assets/images/fork-me.png differ diff --git a/assets/images/logo.jpg b/assets/images/logo.jpg new file mode 100644 index 0000000..626f6f4 Binary files /dev/null and b/assets/images/logo.jpg differ diff --git a/bin/dnote b/bin/dnote deleted file mode 100755 index 7db04e2..0000000 --- a/bin/dnote +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby -require "dnote" -DNote::Session.main(*ARGV) - diff --git a/example.html b/example.html new file mode 100644 index 0000000..3ce9218 --- /dev/null +++ b/example.html @@ -0,0 +1,81 @@ + + + Developer's Notes + + + + +
+

Developer's Notes

+
+

CREDIT

+
    +
  1. lib/dnote/string.rb

      +
    1. Trans 19
    2. +
    3. Gavin Sinclair 37
    4. +
    5. Gavin Sinclair 50
    6. +
    7. Trans 51
    8. +
  2. +
+

TODO

+
    +
  1. test/cases/notes_case.rb

      +
    1. Do something or another!", 1, "foo.rb" 27
    2. +
    3. Do something or another!", 1, "foo.rb" 34
    4. +
  2. +
  3. lib/dnote/notes.rb

      +
    1. Add ability to read header notes. They often +have a outline format, rather then the single line. 16
    2. +
    3. Play gold with Notes#parse. 73
    4. +
    5. should this be done? 79
    6. +
    7. ruby-1.9.1-p378 reports: `match': invalid byte sequence in UTF-8 134
    8. +
    9. Would to_xoxo be better organized by label and or file? 254
    10. +
  4. +
  5. lib/plugins/syckle/dnote.rb

      +
    1. Should this service be part of the +site+ cycle? 18
    2. +
    3. Is #trial? correct? 79
    4. +
  6. +
  7. work/site.rb

      +
    1. Don't use chdir. 102
    2. +
  8. +
  9. lib/dnote/format.rb

      +
    1. Need good CSS file. 6
    2. +
    3. Need XSL? 8
    4. +
  10. +
+

TEST

+
    +
  1. lib/dnote.rb

      +
    1. This is a test of arbitraty labels. 31
    2. +
  2. +
+

NOTE

+
    +
  1. lib/dnote.rb

      +
    1. Toying with the idea of making DNote a class. 6
    2. +
  2. +
  3. lib/dnote/string.rb

      +
    1. This may still need a bit of tweaking. 17
    2. +
  4. +
  5. work/command.rb

      +
    1. If DNote were a class. 139
    2. +
  6. +
+
+
+ + diff --git a/example.xml b/example.xml new file mode 100644 index 0000000..69a7874 --- /dev/null +++ b/example.xml @@ -0,0 +1,51 @@ + + + + + + + diff --git a/example.yaml b/example.yaml new file mode 100644 index 0000000..fa5d043 --- /dev/null +++ b/example.yaml @@ -0,0 +1,83 @@ +--- +- label: NOTE + line: 6 + text: Toying with the idea of making DNote a class. + file: lib/dnote.rb +- label: TEST + line: 31 + text: This is a test of arbitraty labels. + file: lib/dnote.rb +- label: TODO + line: 6 + text: Need good CSS file. + file: lib/dnote/format.rb +- label: TODO + line: 8 + text: Need XSL? + file: lib/dnote/format.rb +- label: TODO + line: 16 + text: |- + Add ability to read header notes. They often + have a outline format, rather then the single line. + file: lib/dnote/notes.rb +- label: TODO + line: 73 + text: Play gold with Notes#parse. + file: lib/dnote/notes.rb +- label: TODO + line: 79 + text: should this be done? + file: lib/dnote/notes.rb +- label: TODO + line: 134 + text: "ruby-1.9.1-p378 reports: `match': invalid byte sequence in UTF-8" + file: lib/dnote/notes.rb +- label: TODO + line: 254 + text: Would to_xoxo be better organized by label and or file? + file: lib/dnote/notes.rb +- label: NOTE + line: 17 + text: This may still need a bit of tweaking. + file: lib/dnote/string.rb +- label: CREDIT + line: 19 + text: Trans + file: lib/dnote/string.rb +- label: CREDIT + line: 37 + text: Gavin Sinclair + file: lib/dnote/string.rb +- label: CREDIT + line: 50 + text: Gavin Sinclair + file: lib/dnote/string.rb +- label: CREDIT + line: 51 + text: Trans + file: lib/dnote/string.rb +- label: TODO + line: 18 + text: Should this service be part of the +site+ cycle? + file: lib/plugins/syckle/dnote.rb +- label: TODO + line: 79 + text: "Is #trial? correct?" + file: lib/plugins/syckle/dnote.rb +- label: TODO + line: 27 + text: Do something or another!", 1, "foo.rb" + file: test/cases/notes_case.rb +- label: TODO + line: 34 + text: Do something or another!", 1, "foo.rb" + file: test/cases/notes_case.rb +- label: NOTE + line: 139 + text: If DNote were a class. + file: work/command.rb +- label: TODO + line: 102 + text: Don't use chdir. + file: work/site.rb diff --git a/index.html b/index.html new file mode 100644 index 0000000..1a129e9 --- /dev/null +++ b/index.html @@ -0,0 +1,216 @@ + + + D'Note + + + + + + + + + + + +
+
+ +

Developer's take note! All those TODO's and FIXME's floating around + your source code are rotting away. They are trapped, and in desperate need of your attention.

+ +

But not to fret! D'Note will help you liberate them. D'Note will scan your + source code for labeled comments; collect, collate and sort them; and then return them to you in a + format of your choosing. Wunderbar!

+ +

Note Structure

+ +

D'Note scans for the common "LABEL:" pattern (all-caps label followed by a colon) used by many + developers of many languages. To be more specific, for D'Note to recognize a note, it needs to + conform to the following simple set of rules:

+ +

1) Notes start with an all-caps label punctuated with a colon, followed by the note's text.

+ +
+  # LABEL: description ...
+  
+ + + +

2) Any note that requires more than one line must remain flush to the left + margin (the margin is set by the first line). This is done because RDoc will mistake + the second line for a <pre> block if it is indented.

+ +
+  # LABEL: description ...
+  # continue ...
+  
+ +

3) An alternative to the limitation of the last rule is to indent the whole note (making + the whole note a <pre> block with regards to RDoc). Then the text layout is + free-form.

+ +
+  # This is a description of something...
+  #
+  #   LABEL: description ...
+  #          continue ...
+  
+ +

That's all there is to it. If I can convince the developers of RDoc to add recognition of + labels, we may eventually be able to relax the flush rule too, which would be very nice.

+ +

There is also a command-line option, --no-colon, which deactives the need for + a colon after the note label. However this often produces false positives, so it's use is + discouraged.

+ +

Generating Notes

+ +

As you can see the commandline interface is quite straight-forward.

+ +
+  USAGE:
+
+    dnote [OPTIONS] path1 [path2 ...]
+   
+  OUTPUT FORMAT: (choose one)
+      -f, --format NAME                select a format [text]
+      -C, --custom FILE                use a custom ERB template
+          --file                       shortcut for text/file format
+          --list                       shortcut for text/list format
+
+  OTHER OPTIONS:
+      -l, --label LABEL                labels to collect
+          --[no-]colon                 match labels with/without colon suffix
+      -m, --marker MARK                alternative remark marker
+      -u, --url TEMPLATE               url template for line entries (for HTML)
+      -c, --context INTEGER            number of lines of context to display
+      -x, --exclude PATH               exclude file or directory
+      -i, --ignore NAME                ignore file based on any part of pathname
+      -t, --title TITLE                title to use in header
+      -o, --output PATH                save to file or directory
+      -n, --dryrun                     do not actually write to disk
+          --debug                      debug mode
+   
+  COMMAND OPTIONS:
+      -T, --templates                  list available format templates
+      -h, --help                       show this help information
+  
+ +

There are a variety of formats are available, here are examples of some of the + XML, HTML and YAML + formats. You can get a list of all available format templates using the -T option.

+ +

The default path is **/*.rb and the default format -f text. + Here is an example of DNote's own notes in -f rdoc format:

+ +
+  = Development Notes
+
+  == TODO
+
+  === file://lib/dnote/notes.rb
+
+  * TODO: Add ability to read header notes. They often
+  have a outline format, rather then the single line. (19)
+  * TODO: Need CSS? (22)
+  * TODO: Need XSL? (24)
+
+  === file://plug/syckle/services/dnote.rb
+
+  * TODO: Should this service be part of the +site+ cycle? (18)
+
+  (4 TODOs)
+  
+ +

In the future the parsing may imnprove to allow page-top outlined notes as well.

+ +
+
+ + + +
+ +
+ +
+ + +
+ + + + diff --git a/lib/dnote.rb b/lib/dnote.rb deleted file mode 100644 index aeb13c5..0000000 --- a/lib/dnote.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'dnote/version' -require 'dnote/session' - -# TEST: This is a test of an arbitrary label. diff --git a/lib/dnote.yml b/lib/dnote.yml deleted file mode 120000 index 064ee51..0000000 --- a/lib/dnote.yml +++ /dev/null @@ -1 +0,0 @@ -../.ruby \ No newline at end of file diff --git a/lib/dnote/core_ext.rb b/lib/dnote/core_ext.rb deleted file mode 100644 index d66abad..0000000 --- a/lib/dnote/core_ext.rb +++ /dev/null @@ -1,92 +0,0 @@ -module Enumerable - - # Taken from Ruby Facets. - def group_by #:yield: - #h = k = e = nil - r = Hash.new - each{ |e| (r[yield(e)] ||= []) << e } - r - end unless method_defined?(:group_by) - -end - -module DNote - - # Extensions for String class. - # These methods are taken directly from Ruby Facets. - # - module String - - # Provides a margin controlled string. - # - # x = %Q{ - # | This - # | is - # | margin controlled! - # }.margin - # - # - # NOTE: This may still need a bit of tweaking. - # - # CREDIT: Trans - - def margin(n=0) - #d = /\A.*\n\s*(.)/.match( self )[1] - #d = /\A\s*(.)/.match( self)[1] unless d - d = ((/\A.*\n\s*(.)/.match(self)) || - (/\A\s*(.)/.match(self)))[1] - return '' unless d - if n == 0 - gsub(/\n\s*\Z/,'').gsub(/^\s*[#{d}]/, '') - else - gsub(/\n\s*\Z/,'').gsub(/^\s*[#{d}]/, ' ' * n) - end - end - - # Preserves relative tabbing. - # The first non-empty line ends up with n spaces before nonspace. - # - # CREDIT: Gavin Sinclair - - def tabto(n) - if self =~ /^( *)\S/ - indent(n - $1.length) - else - self - end - end - - # Indent left or right by n spaces. - # (This used to be called #tab and aliased as #indent.) - # - # CREDIT: Gavin Sinclair - # CREDIT: Trans - - def indent(n) - if n >= 0 - gsub(/^/, ' ' * n) - else - gsub(/^ {0,#{-n}}/, "") - end - end - - # - # - def tabset(n) - i = lines.map do |line| - line.strip.empty? ? nil : line.index(/\S/) - end - x = i.compact.min - t = n - x.to_i - t = 0 if t < 0 - indent(t) - end - - end - - class ::String #:nodoc: - include DNote::String - end - -end - diff --git a/lib/dnote/format.rb b/lib/dnote/format.rb deleted file mode 100644 index 5f507c5..0000000 --- a/lib/dnote/format.rb +++ /dev/null @@ -1,173 +0,0 @@ -module DNote - - # = Notes Formatter - # - #-- - # TODO: Need good CSS file. - # - # TODO: Need XSL? - #++ - class Format - - require 'fileutils' - require 'erb' - require 'rexml/text' - require 'dnote/core_ext' - - #DEFAULT_OUTPUT_DIR = "log/dnote" - - EXTENSIONS = { 'text'=>'txt', 'soap'=>'xml', 'xoxo'=>'xml' } - - # - attr :notes - - # - attr_accessor :format - - # - attr_accessor :subtype - - # - attr_accessor :output - - # - attr_accessor :template - - # - attr_accessor :title - - # - attr_accessor :dryrun - - # - def initialize(notes, options={}) - @notes = notes - @format = 'text' - @subtype = 'label' - @title = "Developer's Notes" - @dryrun = false - options.each{ |k,v| __send__("#{k}=", v) if v } - yield(self) if block_given? - end - - # - def render - if notes.empty? - $stderr << "No #{notes.labels.join(', ')} notes.\n" - else - case format - when 'custom' - render_custom - else - render_template - end - end - end - - # C U S T O M - - # - def render_custom - #raise ArgumentError unless File.exist?(template) - result = erb(template) - publish(result) - end - - # T E M P L A T E - - # - def render_template - template = File.join(File.dirname(__FILE__), 'templates', "#{format}.erb") - raise "No such format - #{format}" unless File.exist?(template) - result = erb(template) - publish(result) - end - - private - - # - def erb(file) - scope = ErbScope.new(:notes=>notes, :title=>title) - scope.render(file) - end - - # - def publish(result, fname=nil) - if output - write(result, fname) - else - puts(result) - end - $stderr << "(" + notes.counts.map{|l,n| "#{n} #{l}s"}.join(', ') + ")\n" - end - - # - def write(result, fname=nil) - if output.to_s[-1,1] == '/' || File.directory?(output) - fmt = format.split('/').first - ext = EXTENSIONS[fmt] || fmt - file = File.join(output, fname || "notes.#{ext}") - else - file = output - end - if dryrun? - puts "mkdir: #{File.dirname(file)}" - puts "write: #{file}" - else - dir = File.dirname(file) - fu.mkdir(dir) unless File.exist?(dir) - File.open(file, 'w'){ |f| f << result } - end - return file - end - - # - def dryrun? - @dryrun - end - - # - def debug? - $DEBUG - end - - # - def fu - @fu ||= ( - if dryrun? and debug? - FileUtils::DryRun - elsif dryrun? - FileUtils::Noop - elsif debug? - FileUtils::Verbose - else - FileUtils - end - ) - end - - # - class ErbScope - # - def initialize(data={}) - @data = data - end - # - def render(file) - erb = ERB.new(File.read(file), nil, '<>') - erb.result(binding) - end - # - def h(string) - REXML::Text.normalize(string) - end - # - def method_missing(s, *a) - @data[s.to_sym] - end - end - - end - -end - diff --git a/lib/dnote/note.rb b/lib/dnote/note.rb deleted file mode 100644 index 856769f..0000000 --- a/lib/dnote/note.rb +++ /dev/null @@ -1,150 +0,0 @@ -module DNote - - # The Note class encapsulates a single note made in a source file. - # - # Each note instance holds a reference, +notes+, to the set of notes - # being generated for a given session. This allows the note to access - # general options applicable to all notes. - class Note - - # Number of lines to provide in source context. - #CONTEXT_DEPTH = 5 - - # Set of notes to which this note belongs. - attr :notes - - # The file in which the note is made. - attr :file - - # The type of note. - attr :label - - # The line number of the note. - attr :line - - # The verbatim text of the note. - attr :text - - # Remark marker used in parsing the note. - attr :mark - - # Contextual lines of code. - attr :capture - - # Initialize new Note instance. - def initialize(notes, file, label, line, text, mark) - @notes = notes - - @file = file - @label = label - @line = line - @text = text.rstrip - @mark = mark - @capture = [] - end - - # Convert to string representation. - def to_s - "#{label}: #{text}" - end - - # Convert to string representation. - def to_str - "#{label}: #{text}" - end - - # Remove newlines from note text. - def textline - text.gsub("\n", " ") - end - - # Sort by file name and line number. - def <=>(other) - s = file <=> other.file - return s unless s == 0 - line <=> other.line - end - - # Convert to Hash. - #-- - # TODO: Add +url+? - # TODO: Add +code+? Problem is that xml needs code in CDATA. - #++ - def to_h - { 'label'=>label, 'text'=>textline, 'file'=>file, 'line'=>line } - end - - # Convert to Hash, leaving the note text verbatim. - def to_h_raw - { 'label'=>label, 'text'=>text, 'file'=>file, 'line'=>line, 'code'=>code } - end - - # Convert to JSON. - def to_json(*args) - to_h_raw.to_json(*args) - end - - # Convert to YAML. - def to_yaml(*args) - to_h_raw.to_yaml(*args) - end - - # Return line URL based on URL template. If no template was set, then - # returns the file. - def url - if notes.url - notes.url % [file, line] - else - file - end - end - - # - def code - unindent(capture).join - end - - # Is there code to show? - def code? - !capture.empty? - end - -=begin - # This isn't being used currently b/c the URL solution as deeemd better, - # but the code is here for custom templates. - def capture - @context ||= ( - lines = file_cache(file) #.lines.to_a - count = line() - count +=1 while /^\s*#{mark}/ =~ lines[count] - lines[count, context_depth] - ) - end - - # Read in +file+, parse into lines and cache. - def file_cache(file) - @@file_cache ||= {} - @@file_cache[file] ||= File.read(file).lines.to_a - end -=end - - private - - # Remove blank space from lines. - def unindent(lines) - dents = [] - lines.each do |line| - if md = /^([\ ]*)/.match(line) - size = md[1].size - dents << md[1] - end - end - dent = dents.min{ |a,b| a.size <=> b.size } - lines.map do |line| - line.sub(dent, '') - end - end - - end - -end diff --git a/lib/dnote/notes.rb b/lib/dnote/notes.rb deleted file mode 100644 index 9a29977..0000000 --- a/lib/dnote/notes.rb +++ /dev/null @@ -1,320 +0,0 @@ -require 'pathname' -require 'dnote/note' - -module DNote - - # = Developer Notes - # - # This class goes through you source files and compiles a list - # of any labeled comments. Labels are all-cap single word prefixes - # to a comment ending in a colon. - # - # Special labels do not require the colon. By default these are - # +TODO+, +FIXME+, +OPTIMIZE+, +THINK+ and +DEPRECATE+. - # - #-- - # TODO: Add ability to read header notes. They often - # have a outline format, rather then the single line. - #++ - class Notes - include Enumerable - - # Default paths (all ruby scripts). - DEFAULT_PATHS = ["**/*.rb"] - - # Default note labels to look for in source code. (NOT CURRENTLY USED!) - DEFAULT_LABELS = ['TODO', 'FIXME', 'OPTIMIZE', 'THINK', 'DEPRECATE'] - - # Files to search for notes. - attr_accessor :files - - # Labels to document. Defaults are: +TODO+, +FIXME+, +OPTIMIZE+ and +DEPRECATE+. - attr_accessor :labels - - # Require label colon? Default is +true+. - attr_accessor :colon - - # Specific remark marker (+nil+ for auto). - attr_accessor :marker - - # Link template. - attr_accessor :url - - # Number of lines of context to show. - attr_accessor :context - - # New set of notes for give +files+ and optional special labels. - def initialize(files, options={}) - @files = [files].flatten - @labels = [options[:labels] || DEFAULT_LABELS].flatten.compact - @colon = options[:colon].nil? ? true : options[:colon] - @marker = options[:marker] #|| '#' - @url = options[:url] - @context = options[:context] || 0 - - @remark = {} - - parse - end - - # Array of notes. - def notes - @notes - end - - # Notes counts by label. - def counts - @counts ||= ( - h = {} - by_label.each do |label, notes| - h[label] = notes.size - end - h - ) - end - - # Iterate through notes. - def each(&block) - notes.each(&block) - end - - # No notes? - def empty? - notes.empty? - end - - # Gather notes. - #-- - # TODO: Play golf with Notes#parse. - #++ - def parse - records = [] - files.each do |fname| - next unless File.file?(fname) - #next unless fname =~ /\.rb$/ # TODO: should this be done? - mark = remark(fname) - lineno, note, text, capt = 0, nil, nil, nil - File.readlines(fname).each do |line| - #while line = f.gets - lineno += 1 - note = match(line, lineno, fname) - if note - #file = fname - text = note.text - capt = note.capture - #note = {'label'=>label,'file'=>file,'line'=>line_no,'note'=>text} - records << note - else - if text - case line - when /^\s*#{mark}+\s*$/, /^\s*#{mark}\-\-/, /^\s*#{mark}\+\+/ - text.strip! - text = nil - when /^\s*#{mark}/ - if text[-1,1] == "\n" - text << line.gsub(/^\s*#{mark}\s*/,'') - else - text << "\n" << line.gsub(/^\s*#{mark}\s*/,'') - end - else - text.strip! - text = nil - end - else - if line !~ /^\s*#{mark}/ - capt << line if capt && capt.size < context - end - end - end - #end - end - end - - @notes = records.sort - end - - # Is this line a note? - def match(line, lineno, file) - if labels.empty? - match_general(line, lineno, file) - else - match_special(line, lineno, file) - end - end - - # Match special notes. - def match_special(line, lineno, file) - rec = nil - labels.each do |label| - if md = match_special_regex(label, file).match(line) - text = md[1] - #rec = {'label'=>label,'file'=>file,'line'=>lineno,'note'=>text} - rec = Note.new(self, file, label, lineno, text, remark(file)) - end - end - rec - end - - #-- - # TODO: ruby-1.9.1-p378 reports: `match': invalid byte sequence in UTF-8 - #++ - def match_special_regex(label, file) - mark = remark(file) - if colon - /#{mark}\s*#{Regexp.escape(label)}[:]\s+(.*?)$/ - else - /#{mark}\s*#{Regexp.escape(label)}[:]?\s+(.*?)$/ - end - end - - # Match notes that are labeled with a colon. - def match_general(line, lineno, file) - rec = nil - if md = match_general_regex(file).match(line) - label, text = md[1], md[2] - #rec = {'label'=>label,'file'=>file,'line'=>lineno,'note'=>text} - rec = Note.new(self, file, label, lineno, text, remark(file)) - end - return rec - end - - # Keep in mind that general non-colon matches have a higher potential - # of false positives. - def match_general_regex(file) - mark = remark(file) - if colon - /#{mark}\s*([A-Z]+)[:]\s+(.*?)$/ - else - /#{mark}\s*([A-Z]+)\s+(.*?)$/ - end - end - - # Organize notes into a hash with labels for keys. - def by_label - @by_label ||= ( - list = {} - notes.each do |note| - list[note.label] ||= [] - list[note.label] << note - list[note.label].sort #!{ |a,b| a.line <=> b.line } - end - list - ) - end - - # Organize notes into a hash with filename for keys. - def by_file - @by_file ||= ( - list = {} - notes.each do |note| - list[note.file] ||= [] - list[note.file] << note - list[note.file].sort! #!{ |a,b| a.line <=> b.line } - end - list - ) - end - - # Organize notes into a hash with labels for keys, followed - # by a hash with filename for keys. - def by_label_file - @by_label ||= ( - list = {} - notes.each do |note| - list[note.label] ||= {} - list[note.label][note.file] ||= [] - list[note.label][note.file] << note - list[note.label][note.file].sort! #{ |a,b| a.line <=> b.line } - end - list - ) - end - - # Organize notes into a hash with filenames for keys, followed - # by a hash with labels for keys. - def by_file_label - @by_file ||= ( - list = {} - notes.each do |note| - list[note.file] ||= {} - list[note.file][note.label] ||= [] - list[note.file][note.label] << note - list[note.file][note.label].sort! #{ |a,b| a.line <=> b.line } - end - list - ) - end - - # Convert to an array of hashes. - def to_a - notes.map{ |n| n.to_h } - end - - # Same as #by_label. - def to_h - by_label - end - - # - def remark(file) - @remark[File.extname(file)] ||= ( - mark = guess_marker(file) - Regexp.escape(mark) - ) - end - - # Guess marker based on file extension. Fallsback to '#' - # if the extension is unknown. - # - # TODO: Continue to add comment types. - def guess_marker(file) - return @marker if @marker # forced marker - case File.extname(file) - when '.js', '.c', 'cpp', '.css' - '//' - when '.bas' - "'" - when '.sql', '.ada' - '--' - when '.asm' - ';' - else - '#' - end - end - - # Convert to array of hashes then to YAML. - #def to_yaml - # require 'yaml' - # to_a.to_yaml - #end - - # Convert to array of hashes then to JSON. - #def to_json - # begin - # require 'json' - # rescue LoadError - # require 'json_pure' - # end - # to_a.to_json - #end - - # Convert to array of hashes then to a SOAP XML envelope. - #def to_soap - # require 'soap/marshal' - # SOAP::Marshal.marshal(to_a) - #end - - # XOXO microformat. - #-- - # TODO: Would to_xoxo be better organized by label and or file? - #++ - #def to_xoxo - # require 'xoxo' - # to_a.to_xoxo - #end - - end - -end - diff --git a/lib/dnote/rake/dnotetask.rb b/lib/dnote/rake/dnotetask.rb deleted file mode 100644 index f603471..0000000 --- a/lib/dnote/rake/dnotetask.rb +++ /dev/null @@ -1,116 +0,0 @@ -module DNote - - # = Developmer's Notes Rake Task - # - class RakeTask < Rake::TaskLib - - require 'rake/clean' - - # Default note labels to looked for in source code. - DEFAULT_LABELS = ['TODO', 'FIXME', 'OPTIMIZE', 'DEPRECATE'] - - # File paths to search. - attr_accessor :files - - # Labels to document. Defaults are: TODO, FIXME, OPTIMIZE and DEPRECATE. - attr_accessor :labels - - # Formats (xml, html, rdoc, rdoc/list and so on). - attr_accessor :formats - - # Exclude paths. - attr_accessor :exclude - - # Ignore paths based on any part of pathname. - attr_accessor :ignore - - # Output directory to save notes file. Defaults to dnote/ under - # the project log directory (eg. log/dnote/). - attr_accessor :output - - # Title to use if temaplte can use it. - attr_accessor :title - - # - def output=(path) - @output = Pathname.new(path) - end - - # - def init - require 'dnote' - require 'dnote/format' - @files = "**/*.rb" - @output = 'log/dnote' - @formats = ['index'] - @labels = nil #DEFAULT_LABELS - end - - # - def define - desc "Collect Developer's Notes" - task 'dnote' do - document - end - task 'dnote:clobber' do - clean - end - task :clobber => ['dnote:clobber'] - end - - # Generate notes document(s). - def document - abort "dnote: #{output} is not a directory" unless output.directory? - - session = ::DNote::Session.new do |s| - s.paths = files - s.exclude = exclude - s.ignore = ignore - s.labels = labels #|| DEFAULT_LABELS - s.title = title - s.output = output - s.dryrun = application.options.dryrun #trial? - end - - formats.each do |format| - if format == 'index' - session.format = 'html' - session.output = File.join(self.output, 'index.html') - else - session.format = format - end - session.run - report "Updated #{output.to_s.sub(Dir.pwd+'/','')}" unless trial? - end - end - - # Reset output directory, marking it as out-of-date. - def reset - #if File.directory?(output) - File.utime(0,0,output) unless $NOOP - puts "Marked #{output} as out-of-date" - #end - end - - # Remove output files. - def clean - #if File.directory?(output) - formats.each do |format| - if format == 'index' - file = (output + "index.html").to_s - else - ext = ::DNote::Format::EXTENSIONS[format] || format - file = (output + "notes.#{ext}").to_s - end - rm(file) - report "Removed #{output}" - end - #else - # rm(output) - # report "Removed #{output}" - #end - end - - end - -end diff --git a/lib/dnote/session.rb b/lib/dnote/session.rb deleted file mode 100644 index a0c911b..0000000 --- a/lib/dnote/session.rb +++ /dev/null @@ -1,269 +0,0 @@ -module DNote - - require 'dnote/core_ext' - require 'dnote/notes' - require 'dnote/format' - - # User session which is used by commandline interface. - # - # By making this a class it makes it easy for external - # libraries to use this library just as if they were - # calling the commandline, but without the need to shellout. - # - class Session - - # Directory relative to this script. This is used - # to lookup the available format templates. - DIR = File.dirname(__FILE__) - - # Default format. - DEFAULT_FORMAT = "text" - - # Default title. - DEFAULT_TITLE = "Developer's Notes" - - # Paths to include. - attr_accessor :paths - - # Paths to exclude (match by pathname). - attr_reader :exclude - - # Paths to ignore (match by basename). - attr_reader :ignore - - # Labels to lookup. - # By default these are TODO, FIXME and OPTIMIZE. - attr_accessor :labels - - # Selected labels can optionally do without the colon. - attr_accessor :colon - - # Alternate remark marker. Useful to other languages besides Ruby. - attr_accessor :marker - - # Output format. - attr_accessor :format - - # If custom format, specify template file. - attr_accessor :template - - # Some format put a title at the top of the output. - # The default is "Developer's Notes". - attr_accessor :title - - # Output to a file instead of STDOUT. - attr_accessor :output - - # If output path given, don't actually write to disk. - attr_accessor :dryrun - - # String template for line URLs (mainly for HTML format). For example, - # DNote uses GitHub so we could use a link template: - # - # "https://github.com/rubyworks/dnote/blob/master/%s#L%s" - # - attr_accessor :url - - # Number of lines of context to display. The default is zero. - attr_accessor :context - - private - - # New Session. - def initialize(options={}) - options ||= {} - initialize_defaults - options.each{ |k,v| __send__("#{k}=", v) } - yield(self) if block_given? - end - - # Set default values for attributes. - def initialize_defaults - @paths = [] - @labels = [] - @exclude = [] - @ignore = [] - @format = DEFAULT_FORMAT - @title = DEFAULT_TITLE - @dryrun = false - @marker = nil - @url = nil - @context = 0 - end - - public - - # Set exclude list ensuring that the value is an array. - def exclude=(list) - @exclude = [list].compact.flatten.compact - end - - # Set ignore list ensuring that the value is an array. - def ignore=(list) - @ignore = [list].compact.flatten.compact - end - - # Run session. - def run - notes = Notes.new(files, :labels=>labels, :colon=>colon, :marker=>marker, :url=>url, :context=>context) - formatter = Format.new(notes) do |f| - f.format = format - f.template = template - f.title = title - f.output = output - end - formatter.render - end - - # Collect path globs and remove exclusions. - # This method uses #paths, #exclude and #ignore to - # compile the list of files. - def files - list = [paths].flatten.compact - list = ['**/*.rb'] if list.empty? - list = glob(list) - list = list - glob(exclude) - list.reject do |path| - path.split('/').any?{ |part| ignore.any?{ |ig| File.fnmatch?(ig, part) } } - end - end - - # Collect the file glob of each path given. If - # a path is a directory, inclue all content. - def glob(paths) - paths.map do |path| - if File.directory?(path) - Dir.glob(File.join(path, '**/*')) - else - Dir.glob(path) - end - end.flatten.uniq - end - - # Set special labels. - #def labels=(labels) - # @labels = ( - # case labels - # when String - # labels.split(/[:;,]/) - # else - # labels = [labels].flatten.compact.uniq.map{ |s| s.to_s } - # end - # ) - #end - - # Commandline interface. - def self.main(*argv) - require 'optparse' - - session = Session.new - - opts = OptionParser.new do |opt| - opt.banner = "DNote v#{DNote::VERSION}" - - opt.separator(" ") - opt.separator("USAGE:\n dnote [OPTIONS] path1 [path2 ...]") - - opt.separator(" ") - opt.separator("OUTPUT FORMAT: (choose one)") - - opt.on("--format", "-f NAME", "select a format [text]") do |format| - session.format = format - end - - opt.on("--custom", "-C FILE", "use a custom ERB template") do |file| - session.format = 'custom' - session.template = file - end - - opt.on("--file", "shortcut for text/file format") do - session.format = 'text/file' - end - - opt.on("--list", "shortcut for text/list format") do - session.format = 'text/list' - end - - opt.separator(" ") - opt.separator("OTHER OPTIONS:") - - opt.on("--label", "-l LABEL", "labels to collect") do |lbl| - session.labels.concat(lbl.split(':')) - end - - opt.on("--[no-]colon", "match labels with/without colon suffix") do |val| - session.colon = val - end - - opt.on("--marker", "-m MARK", "alternative remark marker") do |mark| - session.marker = mark - end - - opt.on("--url", "-u TEMPLATE", "url template for line entries (for HTML)") do |url| - session.url = url - end - - opt.on("--context", "-c INTEGER", "number of lines of context to display") do |int| - session.context = int.to_i - end - - opt.on("--exclude", "-x PATH", "exclude file or directory") do |path| - session.exclude << path - end - - opt.on("--ignore", "-i NAME", "ignore file based on any part of pathname") do |name| - session.ignore << name - end - - opt.on("--title", "-t TITLE", "title to use in header") do |title| - session.title = title - end - - opt.on("--output", "-o PATH", "save to file or directory") do |path| - session.output = path - end - - opt.on("--dryrun", "-n", "do not actually write to disk") do - session.dryrun = true - end - - opt.on("--debug", "debug mode") do - $DEBUG = true - $VERBOSE = true - end - - opt.separator(" ") - opt.separator("COMMAND OPTIONS:") - - opt.on_tail('--templates', "-T", "list available format templates") do - tdir = File.join(DIR, 'templates') - tfiles = Dir[File.join(tdir, '**/*.erb')] - tnames = tfiles.map{ |tname| tname.sub(tdir+'/', '').chomp('.erb') } - groups = tnames.group_by{ |tname| tname.split('/').first } - groups.sort.each do |(type, names)| - puts("%-18s " * names.size % names.sort) - end - exit - end - - opt.on_tail('--help', '-h', "show this help information") do - puts opt - exit - end - end - - begin - opts.parse!(argv) - session.paths.replace(argv) - session.run - rescue => err - raise err if $DEBUG - puts err - exit 1 - end - end - - end - -end - diff --git a/lib/dnote/templates/html.erb b/lib/dnote/templates/html.erb deleted file mode 100644 index a16d15e..0000000 --- a/lib/dnote/templates/html.erb +++ /dev/null @@ -1,49 +0,0 @@ - - - <%= title %> - - - - -
-

<%= title %>

-
-<% notes.by_label_file.each do |label, per_file| %> -

<%= label %>

-
    -<% per_file.each do |file, line_notes| %> -
  1. <%= file %>

      -<% line_notes.sort!{ |a,b| a.line <=> b.line } %> -<% line_notes.each do |note| %> -
    1. - <%= h note.text %> <%= note.line %> -<% if note.code? %> -
      -<%= note.code %>
      -
      -<% end %> -
    2. -<% end %> -
  2. -<% end %> -
-<% end %> -
-
- - diff --git a/lib/dnote/templates/html/file.erb b/lib/dnote/templates/html/file.erb deleted file mode 100644 index 9d9beda..0000000 --- a/lib/dnote/templates/html/file.erb +++ /dev/null @@ -1,48 +0,0 @@ - - - <%= title %> - - - - -
-

<%= title %>

-
-<% notes.by_file_label.each do |file, per_label| %> -

<%= file %>

-
    -<% per_label.each do |label, lnotes| %> -
  1. <%= label %>

      -<% lnotes.each do |note| %> -
    1. - <%= h note.textline %> <%= note.line %> -<% if note.code? %> -
      -<%= note.code %>
      -
      -<% end %> -
    2. -<% end %> -
  2. -<% end %> -
-<% end %> -
-
- - diff --git a/lib/dnote/templates/html/label.erb b/lib/dnote/templates/html/label.erb deleted file mode 100644 index 3de45ba..0000000 --- a/lib/dnote/templates/html/label.erb +++ /dev/null @@ -1,49 +0,0 @@ - - - <%= title %> - - - - -
-

<%= title %>

-
-<% notes.by_label_file.each do |label, per_file| %> -

<%= label %>

-
    -<% per_file.each do |file, line_notes| %> -
  1. <%= file %>

      -<% line_notes.sort!{ |a,b| a.line <=> b.line } %> -<% line_notes.each do |note| %> -
    1. - <%= h note.text %> <%= note.line %> -<% if note.code? %> -
      -<%= note.code %>
      -
      -<% end %> -
    2. -<% end %> -
  2. -<% end %> -
-<% end %> -
-
- - diff --git a/lib/dnote/templates/html/list.erb b/lib/dnote/templates/html/list.erb deleted file mode 100644 index fd0c505..0000000 --- a/lib/dnote/templates/html/list.erb +++ /dev/null @@ -1,42 +0,0 @@ - - - <%= title %> - - - - -
-

<%= title %>

-
-
    -<% notes.each do |note| %> -
  1. - <%= note.label %>: <%= h note.text %> - <%= note.file %>: <%= note.line %> -<% if note.code? %> -
    -<%= note.code %>
    -
    -<$ end %> -
  2. -<% end %> -
-
-
- - diff --git a/lib/dnote/templates/json.erb b/lib/dnote/templates/json.erb deleted file mode 100644 index 097b934..0000000 --- a/lib/dnote/templates/json.erb +++ /dev/null @@ -1,8 +0,0 @@ -<%= -begin - require 'json' -rescue LoadError - require 'json_pure' -end -notes.map{ |n| n.to_h_raw }.to_json -%> diff --git a/lib/dnote/templates/json/file.erb b/lib/dnote/templates/json/file.erb deleted file mode 100644 index eb24ed4..0000000 --- a/lib/dnote/templates/json/file.erb +++ /dev/null @@ -1,8 +0,0 @@ -<%= -begin - require 'json' -rescue LoadError - require 'json_pure' -end -notes.by_file.to_json -%> diff --git a/lib/dnote/templates/json/label.erb b/lib/dnote/templates/json/label.erb deleted file mode 100644 index a742af4..0000000 --- a/lib/dnote/templates/json/label.erb +++ /dev/null @@ -1,8 +0,0 @@ -<%= -begin - require 'json' -rescue LoadError - require 'json_pure' -end -notes.by_label.to_json -%> diff --git a/lib/dnote/templates/json/list.erb b/lib/dnote/templates/json/list.erb deleted file mode 100644 index 097b934..0000000 --- a/lib/dnote/templates/json/list.erb +++ /dev/null @@ -1,8 +0,0 @@ -<%= -begin - require 'json' -rescue LoadError - require 'json_pure' -end -notes.map{ |n| n.to_h_raw }.to_json -%> diff --git a/lib/dnote/templates/md.erb b/lib/dnote/templates/md.erb deleted file mode 100644 index 6e1ce1b..0000000 --- a/lib/dnote/templates/md.erb +++ /dev/null @@ -1,19 +0,0 @@ -<%= title %> - -<%= '=' * title.to_s.size %> - -<% notes.by_label_file.each do |label, per_file| %> - -<%= label %> - -<%= '-' * (label.size) %> - -<% per_file.each do |file, line_notes| %> - -### file://<%= file %> - -<% line_notes.each do |note| %> -* <%= note %> (<%= note.line %>) -<% if note.code? %><%= "\n" + note.code.tabset(4).rstrip + "\n\n" %><% end %> -<% end; end; end %> - diff --git a/lib/dnote/templates/md/file.erb b/lib/dnote/templates/md/file.erb deleted file mode 100644 index 1922569..0000000 --- a/lib/dnote/templates/md/file.erb +++ /dev/null @@ -1,14 +0,0 @@ -<%= title %> - -<%= '=' * title.size %> - -<% notes.by_file.each do |file, list| %> - -file://<%= file %> -<%= '-' * (file.size + 7) %> - -<% list.each do |note| %> -* <%= note %> (<%= note.line %>) -<% if note.code? %><%= "\n" + note.code.tabset(4).rstrip + "\n\n" %><% end %> -<% end; end %> - diff --git a/lib/dnote/templates/md/label.erb b/lib/dnote/templates/md/label.erb deleted file mode 100644 index 4833f26..0000000 --- a/lib/dnote/templates/md/label.erb +++ /dev/null @@ -1,19 +0,0 @@ -<%= title %> - -<%= '=' * title.size %> - -<% notes.by_label_file.each do |label, per_file| %> - -<%= label %> - -<%= '-' * (label.size) %> - -<% per_file.each do |file, line_notes| %> - -### file://<%= file %> - -<% line_notes.each do |note| %> -* <%= note %> (<%= note.line %>) -<% if note.code? %><%= "\n" + note.code.tabset(4).rstrip + "\n\n" %><% end %> -<% end; end; end %> - diff --git a/lib/dnote/templates/md/list.erb b/lib/dnote/templates/md/list.erb deleted file mode 100644 index 91a243a..0000000 --- a/lib/dnote/templates/md/list.erb +++ /dev/null @@ -1,10 +0,0 @@ -<%= title %> - -<%= '=' * title.size %> - - -<% notes.each_with_index do |note, index| %> -<%= "%s" % [index+1] %>. <%= note.label %>: <%= h note.textline %> (<%= note.file %>: <%= note.line %>) -<% if note.code? %><%= "\n" + note.code.tabset(4).rstrip + "\n\n" %><% end %> -<% end %> - diff --git a/lib/dnote/templates/rdoc.erb b/lib/dnote/templates/rdoc.erb deleted file mode 100644 index 19f49b1..0000000 --- a/lib/dnote/templates/rdoc.erb +++ /dev/null @@ -1,12 +0,0 @@ -= <%= title %><% notes.by_label_file.each do |label, per_file| %> - -== <%= label %> -<% per_file.each do |file, line_notes| %> - -=== file://<%= file %> - -<% line_notes.each do |note| %> -* <%= note %> (<%= note.line %>) -<% if note.code? %><%= "\n" + note.code.tabset(4).rstrip + "\n\n" %><% end %> -<% end; end; end %> - diff --git a/lib/dnote/templates/rdoc/file.erb b/lib/dnote/templates/rdoc/file.erb deleted file mode 100644 index 9714657..0000000 --- a/lib/dnote/templates/rdoc/file.erb +++ /dev/null @@ -1,10 +0,0 @@ -= <%= title %> -<% notes.by_file.each do |file, list| %> - -== file://<%= file %> - -<% list.each do |note| %> -* <%= note %> (<%= note.line %>) -<% if note.code? %><%= "\n" + note.code.tabset(4).rstrip + "\n\n" %><% end %> -<% end; end %> - diff --git a/lib/dnote/templates/rdoc/label.erb b/lib/dnote/templates/rdoc/label.erb deleted file mode 100644 index 19f49b1..0000000 --- a/lib/dnote/templates/rdoc/label.erb +++ /dev/null @@ -1,12 +0,0 @@ -= <%= title %><% notes.by_label_file.each do |label, per_file| %> - -== <%= label %> -<% per_file.each do |file, line_notes| %> - -=== file://<%= file %> - -<% line_notes.each do |note| %> -* <%= note %> (<%= note.line %>) -<% if note.code? %><%= "\n" + note.code.tabset(4).rstrip + "\n\n" %><% end %> -<% end; end; end %> - diff --git a/lib/dnote/templates/rdoc/list.erb b/lib/dnote/templates/rdoc/list.erb deleted file mode 100644 index bb89897..0000000 --- a/lib/dnote/templates/rdoc/list.erb +++ /dev/null @@ -1,7 +0,0 @@ -= <%= title %> - -<% notes.each_with_index do |note, index| %> -* <%= note.label %>: <%= h note.textline %> (<%= note.file %>: <%= note.line %>) -<% if note.code? %><%= "\n" + note.code.tabset(4).rstrip + "\n\n" %><% end %> -<% end %> - diff --git a/lib/dnote/templates/soap.erb b/lib/dnote/templates/soap.erb deleted file mode 100644 index 34b6ae2..0000000 --- a/lib/dnote/templates/soap.erb +++ /dev/null @@ -1,4 +0,0 @@ -<%= - require 'soap/marshal' - ::SOAP::Marshal.marshal(notes.to_a) -%> diff --git a/lib/dnote/templates/soap/file.erb b/lib/dnote/templates/soap/file.erb deleted file mode 100644 index 4c2a6f8..0000000 --- a/lib/dnote/templates/soap/file.erb +++ /dev/null @@ -1,4 +0,0 @@ -<%= - require 'soap/marshal' - ::SOAP::Marshal.marshal(notes.by_file) -%> diff --git a/lib/dnote/templates/soap/label.erb b/lib/dnote/templates/soap/label.erb deleted file mode 100644 index 126f2e3..0000000 --- a/lib/dnote/templates/soap/label.erb +++ /dev/null @@ -1,4 +0,0 @@ -<%= - require 'soap/marshal' - ::SOAP::Marshal.marshal(notes.by_label) -%> diff --git a/lib/dnote/templates/soap/list.erb b/lib/dnote/templates/soap/list.erb deleted file mode 100644 index 34b6ae2..0000000 --- a/lib/dnote/templates/soap/list.erb +++ /dev/null @@ -1,4 +0,0 @@ -<%= - require 'soap/marshal' - ::SOAP::Marshal.marshal(notes.to_a) -%> diff --git a/lib/dnote/templates/text.erb b/lib/dnote/templates/text.erb deleted file mode 100644 index 45adfed..0000000 --- a/lib/dnote/templates/text.erb +++ /dev/null @@ -1,12 +0,0 @@ -<%= title %> - -<% notes.by_label.each do |label, line_notes| %> - -<%= label %> - - -<% line_notes.each_with_index do |note, i| %> -<%= note.text.indent(6).sub(' ' * 6,(" %3s. " % [i+1])) %> (<%= note.file %>:<%= note.line %>) -<% if note.code? %><%= "\n" + note.code.tabset(8) + "\n" %><% end %> -<% end; end %> - diff --git a/lib/dnote/templates/text/file.erb b/lib/dnote/templates/text/file.erb deleted file mode 100644 index 3cd66fb..0000000 --- a/lib/dnote/templates/text/file.erb +++ /dev/null @@ -1,11 +0,0 @@ -<%= title %> - -<% notes.by_file.each do |file, line_notes| %> - -<%= file %>: - -<% line_notes.sort!{ |a,b| a.line <=> b.line } %><% line_notes.each do |note| %> -<%= note.to_s.indent(4).sub(' ' * 4,' * ') %> (<%= note.line %>) -<% if note.code? %><%= "\n" + note.code.tabset(10) + "\n" %><% end %> -<% end; end %> - diff --git a/lib/dnote/templates/text/label.erb b/lib/dnote/templates/text/label.erb deleted file mode 100644 index a27cb65..0000000 --- a/lib/dnote/templates/text/label.erb +++ /dev/null @@ -1,11 +0,0 @@ -<%= title %> - -<% notes.by_label.each do |label, line_notes| %> - -<%= label %> - - -<% line_notes.each_with_index do |note, i| %> -<%= note.text.indent(6).sub(' ' * 6,(" %3s. " % [i+1])) %> (<%= note.file %>:<%= note.line %>) -<% end; end %> - diff --git a/lib/dnote/templates/text/list.erb b/lib/dnote/templates/text/list.erb deleted file mode 100644 index 2bda81e..0000000 --- a/lib/dnote/templates/text/list.erb +++ /dev/null @@ -1,8 +0,0 @@ -<%= title %> - - -<% notes.each_with_index do |note, index| %> -<%= "%4s %s %s" % [index+1, note.label, note.text.gsub("\n", ' ')] %> (<%= note.file %>:<%= note.line %>) -<% if note.code? %><%= "\n" + note.code.tabset(8) + "\n" %><% end %> -<% end %> - diff --git a/lib/dnote/templates/xml.erb b/lib/dnote/templates/xml.erb deleted file mode 100644 index 5e5793b..0000000 --- a/lib/dnote/templates/xml.erb +++ /dev/null @@ -1,23 +0,0 @@ - - -<% notes.by_label_file.each do |label, per_file| %> - -<% end %> - diff --git a/lib/dnote/templates/xml/file.erb b/lib/dnote/templates/xml/file.erb deleted file mode 100644 index 0892ba0..0000000 --- a/lib/dnote/templates/xml/file.erb +++ /dev/null @@ -1,23 +0,0 @@ - - -<% notes.by_file_label.each do |file, per_label| %> - -<% per_label.each do |label, lnotes| %> - -<% end %> - -<% end %> - diff --git a/lib/dnote/templates/xml/label.erb b/lib/dnote/templates/xml/label.erb deleted file mode 100644 index 573bceb..0000000 --- a/lib/dnote/templates/xml/label.erb +++ /dev/null @@ -1,23 +0,0 @@ - - -<% notes.by_label_file.each do |label, per_file| %> - -<% end %> - diff --git a/lib/dnote/templates/xml/list.erb b/lib/dnote/templates/xml/list.erb deleted file mode 100644 index e7cce98..0000000 --- a/lib/dnote/templates/xml/list.erb +++ /dev/null @@ -1,14 +0,0 @@ - - -<% notes.each do |note| %> - - <%= h note.textline %> -<% if note.code? %> - - -]]> -<% end %> - -<% end %> - diff --git a/lib/dnote/templates/xoxo.erb b/lib/dnote/templates/xoxo.erb deleted file mode 100644 index 32b263b..0000000 --- a/lib/dnote/templates/xoxo.erb +++ /dev/null @@ -1,4 +0,0 @@ -<%= - require 'xoxo' - notes.by_label.to_xoxo -%> diff --git a/lib/dnote/templates/xoxo/file.erb b/lib/dnote/templates/xoxo/file.erb deleted file mode 100644 index bfb87e2..0000000 --- a/lib/dnote/templates/xoxo/file.erb +++ /dev/null @@ -1,4 +0,0 @@ -<%= - require 'xoxo' - notes.by_file.to_xoxo -%> diff --git a/lib/dnote/templates/xoxo/label.erb b/lib/dnote/templates/xoxo/label.erb deleted file mode 100644 index 32b263b..0000000 --- a/lib/dnote/templates/xoxo/label.erb +++ /dev/null @@ -1,4 +0,0 @@ -<%= - require 'xoxo' - notes.by_label.to_xoxo -%> diff --git a/lib/dnote/templates/xoxo/list.erb b/lib/dnote/templates/xoxo/list.erb deleted file mode 100644 index dac0c02..0000000 --- a/lib/dnote/templates/xoxo/list.erb +++ /dev/null @@ -1,6 +0,0 @@ -<%= - require 'xoxo' - notes.map{ |n| - { 'label'=>n.label, 'text'=>n.textline, 'file'=>n.file, 'line'=>n.line } - }.to_xoxo -%> diff --git a/lib/dnote/templates/yaml.erb b/lib/dnote/templates/yaml.erb deleted file mode 100644 index 91a65e4..0000000 --- a/lib/dnote/templates/yaml.erb +++ /dev/null @@ -1 +0,0 @@ -<%= require 'yaml'; notes.map{ |n| n.to_h_raw }.to_yaml %> diff --git a/lib/dnote/templates/yaml/file.erb b/lib/dnote/templates/yaml/file.erb deleted file mode 100644 index 26f6db3..0000000 --- a/lib/dnote/templates/yaml/file.erb +++ /dev/null @@ -1 +0,0 @@ -<%= require 'yaml'; notes.by_file.to_yaml %> diff --git a/lib/dnote/templates/yaml/label.erb b/lib/dnote/templates/yaml/label.erb deleted file mode 100644 index 3e6d16f..0000000 --- a/lib/dnote/templates/yaml/label.erb +++ /dev/null @@ -1 +0,0 @@ -<%= require 'yaml'; notes.by_label.to_yaml %> diff --git a/lib/dnote/templates/yaml/list.erb b/lib/dnote/templates/yaml/list.erb deleted file mode 100644 index 91a65e4..0000000 --- a/lib/dnote/templates/yaml/list.erb +++ /dev/null @@ -1 +0,0 @@ -<%= require 'yaml'; notes.map{ |n| n.to_h_raw }.to_yaml %> diff --git a/lib/dnote/version.rb b/lib/dnote/version.rb deleted file mode 100644 index 2f93f10..0000000 --- a/lib/dnote/version.rb +++ /dev/null @@ -1,16 +0,0 @@ -module DNote - - # - def self.metadata - @metadata ||= ( - require 'yaml' - YAML.load_file(File.dirname(__FILE__) + '/../dnote.yml') - ) - end - - # - def self.const_missing(name) - metadata[name.to_s.downcase] || super(name) - end - -end diff --git a/test/notes_case.rb b/test/notes_case.rb deleted file mode 100644 index 6691e48..0000000 --- a/test/notes_case.rb +++ /dev/null @@ -1,64 +0,0 @@ -require 'lemon' -require 'ae' -require 'dnote/notes' - -testcase DNote::Notes do - - concern "Coverage of DNote::Notes class." - - method :labels do - test 'returns the list of labels' do - notes = DNote::Notes.new([], :labels=>['TODO']) - notes.labels.assert == ['TODO'] #DNote::Notes::DEFAULT_LABELS - end - end - - method :files do - test 'returns the files attribute' do - notes = DNote::Notes.new(["example1.rb"]) - notes.assert.files == ["example1.rb"] - notes = DNote::Notes.new([], :paths => ["example2.rb"]) - notes.assert.files == ["example2.rb"] - end - end - - method :files do - test 'changes the paths attribute' do - notes = DNote::Notes.new([]) - notes.files = ["example1.rb"] - notes.assert.files == ["example1.rb"] - end - end - - method :match_general do - test 'works' do - notes = DNote::Notes.new([]) - line, lineno, file = "# TODO: Do something or another!", 1, "foo.rb" - rec = notes.match_general(line, lineno, file) - rec.to_h.assert == {'label'=>"TODO",'file'=>file,'line'=>lineno,'text'=>"Do something or another!"} - end - end - - method :match_special do - test 'works' do - notes = DNote::Notes.new([], :labels=>['TODO']) - line, lineno, file = "# TODO: Do something or another!", 1, "foo.rb" - rec = notes.match_special(line, lineno, file) - rec.to_h.assert == {'label'=>"TODO",'file'=>file,'line'=>lineno,'text'=>"Do something or another!"} - end - end - - method :counts do - test{ raise NotImplementedError } - end - - method :notes do - test{ raise NotImplementedError } - end - - method :parse do - test{ raise NotImplementedError } - end - -end - diff --git a/try/sample.bas b/try/sample.bas deleted file mode 100644 index 45b9ac8..0000000 --- a/try/sample.bas +++ /dev/null @@ -1,7 +0,0 @@ -' Here is a sample of Javascript. -' -' TODO: This is what we will do. -' -' FIXME: And this is something urgant - - diff --git a/try/sample.js b/try/sample.js deleted file mode 100644 index c438f4d..0000000 --- a/try/sample.js +++ /dev/null @@ -1,11 +0,0 @@ -// Here is a sample of Javascript. -// -// TODO: This is what we will do. -// -// FIXME: And this is something urgant - -function sample() [ - var n = 100; - return n; -} - diff --git a/try/sample.rb b/try/sample.rb deleted file mode 100644 index 5809fc6..0000000 --- a/try/sample.rb +++ /dev/null @@ -1,11 +0,0 @@ -# Here is a sample of Javascript. -# -# TODO: This is what we will do. -# -# FIXME: And this is something urgant - -def sample - n = 100 - n -end - diff --git a/var/authors b/var/authors deleted file mode 100644 index ba213a0..0000000 --- a/var/authors +++ /dev/null @@ -1,2 +0,0 @@ ---- -- Thomas Sawyer diff --git a/var/copyrights b/var/copyrights deleted file mode 100644 index f8beb78..0000000 --- a/var/copyrights +++ /dev/null @@ -1,2 +0,0 @@ ---- -- (c) 2009 Thomas Sawyer, Rubyworks diff --git a/var/created b/var/created deleted file mode 100644 index 3fcb274..0000000 --- a/var/created +++ /dev/null @@ -1 +0,0 @@ -2009-10-09 \ No newline at end of file diff --git a/var/description b/var/description deleted file mode 100644 index 4ab59b8..0000000 --- a/var/description +++ /dev/null @@ -1,2 +0,0 @@ -DNote makes it easy to extract developer's notes from source code, -and supports almost any language. diff --git a/var/name b/var/name deleted file mode 100644 index 6a74686..0000000 --- a/var/name +++ /dev/null @@ -1 +0,0 @@ -dnote \ No newline at end of file diff --git a/var/organization b/var/organization deleted file mode 100644 index da36cd8..0000000 --- a/var/organization +++ /dev/null @@ -1 +0,0 @@ -RubyWorks \ No newline at end of file diff --git a/var/repositories b/var/repositories deleted file mode 100644 index dc7bd79..0000000 --- a/var/repositories +++ /dev/null @@ -1,2 +0,0 @@ ---- -upstream: git://github.com/rubyworks/dnote.git diff --git a/var/requirements b/var/requirements deleted file mode 100644 index 2c1a933..0000000 --- a/var/requirements +++ /dev/null @@ -1,6 +0,0 @@ ---- -- lemon (test) -- ae (test) -- detroit (build) -- reap (build) - diff --git a/var/resources b/var/resources deleted file mode 100644 index 3ba7c88..0000000 --- a/var/resources +++ /dev/null @@ -1,8 +0,0 @@ ---- -home: http://rubyworks.github.com/dnote -code: http://github.com/rubyworks/dnote -wiki: http://wiki.github.com/rubyworks/dnote -api: http://rubydoc.info/gems/dnote -bugs: http://github.com/rubyworks/dnote/issues -mail: http://groups.google.com/groups/rubyworks-mailinglist - diff --git a/var/summary b/var/summary deleted file mode 100644 index bb463c0..0000000 --- a/var/summary +++ /dev/null @@ -1 +0,0 @@ -Extract developer's notes from source code. diff --git a/var/title b/var/title deleted file mode 100644 index e4be03e..0000000 --- a/var/title +++ /dev/null @@ -1 +0,0 @@ -DNote \ No newline at end of file diff --git a/var/version b/var/version deleted file mode 100644 index bd8bf88..0000000 --- a/var/version +++ /dev/null @@ -1 +0,0 @@ -1.7.0 diff --git a/work/command.rb b/work/command.rb deleted file mode 100644 index ead1f5f..0000000 --- a/work/command.rb +++ /dev/null @@ -1,149 +0,0 @@ -#!/usr/bin/env ruby - -module DNote - require 'optparse' - require 'dnote' - - def self.run - options = {} - format = 'rdoc' - - opts = OptionParser.new do |opt| - - opt.banner = "Usage: dnote [OPTIONS] path1 [path2 ...]" - - opt.separator(" ") - opt.separator("OUTPUT FORMAT: (choose one)") - - opt.on("--gnu", "Plain text format (default)") do - options[:format] = 'gnu' - end - - opt.on("--gnufile", "Plain text format by file") do - options[:format] = 'gnufile' - end - - opt.on("--rdoc", "RDoc comment format") do - options[:format] = 'rdoc' - end - - opt.on("--markdown", "Markdown wiki format") do - options[:format] = 'markdown' - end - - opt.on("--soap", "SOAP XML envelope format") do - options[:format] = 'soap' - end - - opt.on("--xoxo", "XOXO microformat format") do - options[:format] = 'xoxo' - end - - opt.on("--xml", "XML markup format") do - options[:format] = 'xml' - end - - opt.on("--html", "HTML markup format") do - options[:format] = 'html' - end - - opt.on("--yaml", "YAML serialization format") do - options[:format] = 'yaml' - end - - opt.on("--json", "JSON serialization format") do - options[:format] = 'json' - end - - # TODO - opt.on("--format", "-f NAME", "Select a format") do |format| - options[:format] = format - end - - opt.on("--template", "-t FILE", "Use a custom Erb template") do |file| - options[:format] = 'custom' - options[:template] = file - end - - opt.separator(" ") - opt.separator("OTHER OPTIONS:") - - opt.on("--label", "labels to collect") do |lbl| - options[:labels] ||= [] - options[:labels] << lbl - end - - # TODO - opt.on("--exclude", "-x PATH", "exclude file or directory") do |path| - options[:exclude] ||= [] - options[:exclude] << path - end - - opt.on("--title", "-T TITLE", "title to use in headers") do |title| - options[:title] = title - end - - opt.on("--output", "-o PATH", "name of file or directory") do |path| - options[:output] = path - end - - opt.separator(" ") - opt.separator("STANDARD OPTIONS:") - - #opt.on("--verbose", "-v", "extra verbose output") do - # options[:verbose] = true - #end - - opt.on("--debug", "debug mode") do - $DEBUG = true - end - - #opt.on("--quiet", "-q", "surpress non-essential output") do - # options[:quiet] = true - #end - - #opt.on("--noharm", "-n", "only pretend to write to disk") do - # options[:noharm] = true - #end - - opt.on("--dryrun", "-n", "do not actually write to disk") do - options[:dryrun] = true - end - - #opt.on("--trace", "debug and verbose modes combined") do - # $DEBUG = true - # options[:verbose] = true - #end - - opt.on_tail('--help', '-h', "show this help information") do - puts opt - exit - end - - end - - begin - opts.parse! - rescue => err - puts err - exit 1 - end - - paths = ARGV.dup - paths = ['**/*.rb'] if paths.empty? - - notes = Notes.new(paths, options[:labels]) - format = Format.new(notes, options) - format.render - - # NOTE: If DNote were a class. - - #if output - # dnote.save(format, output) - #else - # dnote.display(format) - #end - end - -end - diff --git a/work/site.rb b/work/site.rb deleted file mode 100644 index bdbe6eb..0000000 --- a/work/site.rb +++ /dev/null @@ -1,140 +0,0 @@ -module DNote - - require 'dnote/notes' - - # Site class is used to build a "pretty" output set. - # The template files are saved to the +output+ directory. - # Additional +formats+ can be saved to the directory - # as well. - - class Site - - # Default output directory is +log/dnote/+. - DEFAULT_OUTPUT = Pathname.new('log/dnote') - - # Title to use in any headers. - attr_accessor :title - - # Directory to save output. - attr_accessor :output - - # Additional Formats to supply besides the html (xml, rdoc, markdown, etc.) - attr_accessor :formats - - # Notes object. - attr_reader :notes - - def initialize(paths, options) - initialize_defaults - - self.title = options[:title] if options[:title] - - self.output = options.delete(:output) if options[:output] - self.formats = options.delete(:formats) if options[:formats] - - @notes = Notes.new(paths, options) - end - - # - def initialize_defaults - @output = DEFAULT_OUTPUT - @title = "Development Notes" - @formats = ['html'] - end - - # - def output=(path) - raise "output cannot be root" if File.expand_path(path) == "/" - @output = Pathname.new(path) - end - - # - def document - fu.mkdir_p(output) - - # produce requested additional formats - formats.each do |format| -=begin - tdir = tempdir(format) - - # copy non-erb files - files = Dir.entries(tdir) - ['.', '..'] - files = files.reject{ |file| File.extname(file) == '.erb' } - files.each do |file| - dest = File.dirname(file).sub(tdir, '') - fu.cp_r(File.join(tdir, file), output) - end - - # write the erb templates - templates(format).each do |temp| - file = File.join(tdir, temp) - erb = ERB.new(File.read(file)) - text = erb.result(binding) - write(temp.chomp('.erb'), text) - end -=end - text = notes.to(format) - write("notes.#{format}", text) - end - end - - # Reset output directory, marking it as out-of-date. - def reset - if File.directory?(output) - File.utime(0,0,output) unless $NOOP - puts "marked #{output}" - end - end - - # Remove output directory. - def clean - if File.directory?(output) - fu.rm_r(output) - puts "removed #{output}" - end - end - - # - tempdir(format) - "#{__DIR__}/templates/#{format}" - end - - # TODO: Don't use chdir. - def templates(format) - temps = [] - Dir.chdir(tempdir(format)) do - temps = Dir['**/*.erb'] - end - temps - end - - # Save file to output. - # - def write(fname, text) - file = output + fname - fu.mkdir_p(file.parent) - File.open(file, 'w') { |f| f << text } unless $NOOP - end - - def __DIR__ - File.dirname(__FILE__) - end - - # - def fu - @fu ||= ( - if $NOOP and $DEBUG - FileUtils::DryRun - elsif $NOOP - FileUtils::Noop - elsif $DEBUG - FileUtils::Verbose - else - FileUtils - end - ) - end - - end - - end