public
Rubygem
Description: Official repository for YARD: Yay! A Ruby Documentation-tool.
Homepage: http://yard.soen.ca / IRC: #yard on irc.freenode.net
Clone URL: git://github.com/lsegal/yard.git
Search Repo:
Click here to lend your support to: yard and make a donation at www.pledgie.com !
Updated YARD logger to be namespaced and know how to handle different 
level requirements; Added tag specs.
wycats (author)
Wed May 14 18:07:36 -0700 2008
commit  f012d881b6add5b3fde55a0fbaed53a10bc0d0a2
tree    06dd9955211ab1ad5b92220b087d59dbd1c94759
parent  8134b2aa9521a7f8135a2d3de920973edd693494
...
3
4
5
6
 
7
8
9
...
22
23
24
 
 
25
26
27
...
37
38
39
40
 
41
42
43
...
3
4
5
 
6
7
8
9
...
22
23
24
25
26
27
28
29
...
39
40
41
 
42
43
44
45
0
@@ -3,7 +3,7 @@
0
 
0
 $LOAD_PATH.unshift(YARD_ROOT)
0
 
0
-['logger'].each do |file|
0
+['yard_logger'].each do |file|
0
   require File.join(File.dirname(__FILE__), 'yard', file)
0
 end
0
 
0
@@ -22,6 +22,8 @@
0
   end
0
 end
0
 
0
+YARD.logger.level = YARD.level
0
+
0
 %w[
0
   symbol_hash
0
   tags/*
0
@@ -37,7 +39,7 @@
0
   file = File.join(File.dirname(__FILE__), 'yard', file + ".rb")
0
   Dir[file].each do |f|
0
     if require(f)
0
- log.debug "Loading #{f}..."
0
+ YARD.logger.debug "Loading #{f}..."
0
     end
0
   end
0
 end
...
81
82
83
84
 
85
86
87
...
81
82
83
 
84
85
86
87
0
@@ -81,7 +81,7 @@
0
             raise ArgumentError
0
           end
0
         rescue ArgumentError
0
- log.debug "Ignoring invalid section in #{self.class}"
0
+ YARD.logger.debug "Ignoring invalid section in #{self.class}"
0
         end
0
       end
0
       
...
9
10
11
12
 
13
14
15
...
9
10
11
 
12
13
14
15
0
@@ -9,7 +9,7 @@
0
       symbols = eval("[" + statement.tokens[1..-1].to_s + "]")
0
       read, write = true, false
0
     rescue SyntaxError
0
- Logger.warning "in AttributeHandler: Undocumentable attribute statement: '#{statement.tokens.to_s}'\n" +
0
+ YARD.logger.warning "in AttributeHandler: Undocumentable attribute statement: '#{statement.tokens.to_s}'\n" +
0
                      "\tin file '#{parser.file}':#{statement.tokens.first.line_no}"
0
       return
0
     end
...
17
18
19
20
 
21
22
23
24
25
 
26
27
28
...
17
18
19
 
20
21
22
23
24
 
25
26
27
28
0
@@ -17,12 +17,12 @@
0
       if $1 == "self"
0
         parse_block(:namespace => namespace, :scope => :class)
0
       else
0
- log.warning "in ClassHandler: Undocumentable class: '#{$1}'\n"
0
+ YARD.logger.warning "in ClassHandler: Undocumentable class: '#{$1}'\n"
0
                     "\tin file '#{parser.file}':#{statement.tokens.first.line_no}"
0
         return
0
       end
0
     else
0
- log.warning "in ClassHandler: Undocumentable class: #{statement.tokens}\n" +
0
+ YARD.logger.warning "in ClassHandler: Undocumentable class: #{statement.tokens}\n" +
0
                   "\tin file '#{parser.file}':#{statement.tokens.first.line_no}"
0
       return
0
     end
...
1
2
3
4
5
6
7
8
...
 
 
 
 
 
 
 
 
0
@@ -1,9 +1 @@
0
-module Logger
0
- def self.method_missing(meth, message = "", prefix = true)
0
- prefix = prefix ? "[#{meth.to_s.upcase}]: " : ""
0
- STDOUT.puts "#{prefix}#{message}"
0
- end
0
-end
0
-
0
-def log; Logger end
...
54
55
56
57
58
59
60
 
 
 
 
61
62
63
...
54
55
56
 
 
 
 
57
58
59
60
61
62
63
0
@@ -54,10 +54,10 @@
0
                 begin
0
                   handler.new(self, stmt).process
0
                 rescue => e
0
- log.error "#{handler.to_s} error in `#{file}`:#{stmt.tokens.first.line_no}: #{stmt.tokens.to_s}"
0
- log.error "Exception message: #{e.message}"
0
- log.error e.backtrace[0..5].map {|x| "\n#{x}" }
0
- log.error
0
+ YARD.logger.error "#{handler.to_s} error in `#{file}`:#{stmt.tokens.first.line_no}: #{stmt.tokens.to_s}"
0
+ YARD.logger.error "Exception message: #{e.message}"
0
+ YARD.logger.error e.backtrace[0..5].map {|x| "\n#{x}" }
0
+ YARD.logger.error
0
                 end
0
               end
0
             end
...
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
0
@@ -1 +1,8 @@
0
+require "logger"
0
+
0
+module YARD
0
+ def self.logger
0
+ @logger ||= Logger.new(STDOUT)
0
+ end
0
+end
...
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
0
@@ -1 +1,9 @@
0
+class Foo
0
+
0
+ # @api public
0
+ # @returns nil
0
+ def foo
0
+ end
0
+
0
+end
...
 
 
1
...
1
2
3
0
@@ -1,2 +1,4 @@
0
+require File.join(File.dirname(__FILE__), "..", "spec_helper")
0
+
0
 include Handlers
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
0
@@ -1 +1,19 @@
0
+require File.dirname(__FILE__) + '/spec_helper'
0
+
0
+describe YARD::Handlers::VisibilityHandler do
0
+ before { parse_file :tag_handler_001, __FILE__ }
0
+
0
+ it "should know the list of all available tags" do
0
+ Registry.at("Foo#foo").tags.should include(Registry.at("Foo#foo").tag(:api))
0
+ end
0
+
0
+ it "should know the text of tags on a method" do
0
+ Registry.at("Foo#foo").tag(:api).text.should == "public"
0
+ end
0
+
0
+ it "should return true when asked whether a tag exists" do
0
+ Registry.at("Foo#foo").has_tag?(:api).should == true
0
+ end
0
+
0
+end
...
1
2
 
 
 
 
 
 
 
3
4
5
...
1
2
3
4
5
6
7
8
9
10
11
12
0
@@ -1,5 +1,12 @@
0
 require "rubygems"
0
 require "spec"
0
+
0
+module YARD
0
+ def self.level
0
+ Logger::INFO
0
+ end
0
+end
0
+
0
 require File.join(File.dirname(__FILE__), '..', 'lib', 'yard')
0
 
0
 def parse_file(file, thisfile = __FILE__)

Comments

    No one has commented yet.