You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by as...@apache.org on 2008/01/26 01:38:58 UTC

svn commit: r615414 - in /incubator/buildr/docter/trunk: CHANGELOG Rakefile lib/docter.rb lib/docter/common.rb lib/docter/page.rb lib/docter/template.rb

Author: assaf
Date: Fri Jan 25 16:38:57 2008
New Revision: 615414

URL: http://svn.apache.org/viewvc?rev=615414&view=rev
Log:
Changes mostly do deal with XHTML conformance and list_links fixes

Modified:
    incubator/buildr/docter/trunk/CHANGELOG
    incubator/buildr/docter/trunk/Rakefile
    incubator/buildr/docter/trunk/lib/docter.rb
    incubator/buildr/docter/trunk/lib/docter/common.rb
    incubator/buildr/docter/trunk/lib/docter/page.rb
    incubator/buildr/docter/trunk/lib/docter/template.rb

Modified: incubator/buildr/docter/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/incubator/buildr/docter/trunk/CHANGELOG?rev=615414&r1=615413&r2=615414&view=diff
==============================================================================
--- incubator/buildr/docter/trunk/CHANGELOG (original)
+++ incubator/buildr/docter/trunk/CHANGELOG Fri Jan 25 16:38:57 2008
@@ -1,3 +1,11 @@
+1.1.2 (2007-01-25)
+* Changed: list_links now limits itself so HTTP URLs (no mailto:, FTP).
+* Changed: Upgraded to HAML 1.8.
+* Fixed:   list_links returns URLs in alphabetical order (of title) capitializing first letter of title.
+* Fixed:   list_links no longer returns URLs that have no title.
+* Fixed:   Generated IDs for headers conform to HTML spec (i.e. a-z, 0-9, hyphen, underscore, colon and period).
+* Fixed:   Empty ToC no longer included in HTML.
+
 1.1.1 (2007-01-03)
 * Fixed: Upgraded to Facets 2.2.1 to prevent conflict with Buildr.
 

Modified: incubator/buildr/docter/trunk/Rakefile
URL: http://svn.apache.org/viewvc/incubator/buildr/docter/trunk/Rakefile?rev=615414&r1=615413&r2=615414&view=diff
==============================================================================
--- incubator/buildr/docter/trunk/Rakefile (original)
+++ incubator/buildr/docter/trunk/Rakefile Fri Jan 25 16:38:57 2008
@@ -23,10 +23,11 @@
   spec.rubyforge_project = 'buildr'
 
   # Tested against these dependencies.
-  spec.add_dependency 'facets',   '~> 2.2'
-  spec.add_dependency 'RedCloth', '~> 3.0'
-  spec.add_dependency 'haml',     '~> 1.7'
-  spec.add_dependency 'mongrel',  '~> 1.1'
+  spec.add_dependency 'facets',      '~> 2.2'
+  spec.add_dependency 'RedCloth',    '~> 3.0'
+  spec.add_dependency 'haml',        '~> 1.8'
+  spec.add_dependency 'mongrel',     '~> 1.1'
+  spec.add_dependency 'ultraviolet', '~> 0.10'
 end
 
 

Modified: incubator/buildr/docter/trunk/lib/docter.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/docter/trunk/lib/docter.rb?rev=615414&r1=615413&r2=615414&view=diff
==============================================================================
--- incubator/buildr/docter/trunk/lib/docter.rb (original)
+++ incubator/buildr/docter/trunk/lib/docter.rb Fri Jan 25 16:38:57 2008
@@ -5,7 +5,7 @@
 require 'facets/kernel/__DIR__'
 
 module Docter
-  VERSION = '1.1.1'.freeze
+  VERSION = '1.1.2'.freeze
 end
 
 $LOAD_PATH.unshift __DIR__

Modified: incubator/buildr/docter/trunk/lib/docter/common.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/docter/trunk/lib/docter/common.rb?rev=615414&r1=615413&r2=615414&view=diff
==============================================================================
--- incubator/buildr/docter/trunk/lib/docter/common.rb (original)
+++ incubator/buildr/docter/trunk/lib/docter/common.rb Fri Jan 25 16:38:57 2008
@@ -271,7 +271,7 @@
       options = Hash === args.last ? args.pop.clone : {}
       args.each { |arg| options[arg.to_sym] = true }
       cls = %{ class="#{options[:class]}"} if options[:class]
-      %{<ol #{cls}>#{map { |entry| entry.to_html(options) }}</ol>}
+      %{<ol #{cls}>#{map { |entry| entry.to_html(options) }}</ol>} unless empty?
     end
 
   protected

Modified: incubator/buildr/docter/trunk/lib/docter/page.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/docter/trunk/lib/docter/page.rb?rev=615414&r1=615413&r2=615414&view=diff
==============================================================================
--- incubator/buildr/docter/trunk/lib/docter/page.rb (original)
+++ incubator/buildr/docter/trunk/lib/docter/page.rb Fri Jan 25 16:38:57 2008
@@ -203,7 +203,7 @@
         # Make sure all H2/H3 headers have a usable ID, create once if necessary.
         id = CGI.unescape($3) if attributes[regexp_attribute('id')]
         if id.to_s.blank?
-          id = CGI.unescapeHTML(text.downcase.gsub(' ', '_'))
+          id = CGI.unescapeHTML(text.downcase).gsub(/\s+/, '_').gsub(/[^A-Za-z0-9\-_:.]/, '')
           header = %{<#{tag} #{attributes} id='#{id}'>#{text}</#{tag}>}
         end
         if tag == 'h2'

Modified: incubator/buildr/docter/trunk/lib/docter/template.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/docter/trunk/lib/docter/template.rb?rev=615414&r1=615413&r2=615414&view=diff
==============================================================================
--- incubator/buildr/docter/trunk/lib/docter/template.rb (original)
+++ incubator/buildr/docter/trunk/lib/docter/template.rb Fri Jan 25 16:38:57 2008
@@ -17,10 +17,11 @@
         @links ||= []
         content.gsub(regexp_element('a')) do |link|
           url = $3 if link =~ regexp_attribute('href')
-          if url =~ /^\w+:/
+          text = inner_text_from(link)
+          if url =~ /^\w+:/ && url != text
             unless index = @links.index(url)
               index = @links.size
-              @links << [url, inner_text_from(link)]
+              @links << [url, text]
             end
             mark ? "#{link}<sup>[#{index + 1}]</sup>" : link
           else
@@ -31,9 +32,10 @@
 
       def list_links(cls = nil)
         # Remove duplicate links (same URL), sort by text and convert into DT/DD pairs.
-        links = @links.inject({}) { |hash, link| hash[link.first] ||= link.last ; hash }.
-          sort { |a,b| a.last <=> b.last }.
-          map { |url, text| %{<dt>#{text.capitalize}</dt><dd><a href='#{url}'>#{url}</a></dd>} }
+        links = @links.select { |url, text| url =~ /^http(s?):/ }.
+          inject({}) { |hash, link| hash[link.first] ||= link.last ; hash }.
+          sort { |a,b| a.last.downcase <=> b.last.downcase }.
+          map { |url, text| %{<dt>#{text.gsub(/^\w/) { |a| a.upcase }}</dt><dd><a href='#{url}'>#{url}</a></dd>} }
         %{<dl class='#{cls}'>#{links.join}</dl>}
       end
 
@@ -118,8 +120,7 @@
     #   map.find('images/logo.png') => 'images/logo.png'
     #   map.find('fancy.css') => 'css/fancy.css'
     def find(path)
-      @sources.inject(nil) do |found, file|
-        break found if found
+      @sources.find do |file|
         if File.directory?(file)
           base = File.dirname(file) + '/'
           FileList["#{file}/**/*"].find { |file| file.sub(base, '') == path }