buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From boisv...@apache.org
Subject svn commit: r1002438 - in /buildr/trunk: CHANGELOG lib/buildr/core/doc.rb lib/buildr/java/doc.rb lib/buildr/scala/doc.rb spec/core/doc_spec.rb spec/java/compiler_spec.rb spec/java/doc_spec.rb spec/scala/doc_spec.rb
Date Wed, 29 Sep 2010 00:58:46 GMT
Author: boisvert
Date: Wed Sep 29 00:58:46 2010
New Revision: 1002438

URL: http://svn.apache.org/viewvc?rev=1002438&view=rev
Log:
BUILDR-520 Scaladoc 2.8 no longer support -windowtitle, use -doc-title instead.
also,
1) separate out doc specs 
2) introduce java & scala specific specs
3) doc defaults now injected through after_define extensions

Added:
    buildr/trunk/spec/core/doc_spec.rb
    buildr/trunk/spec/java/doc_spec.rb
    buildr/trunk/spec/scala/doc_spec.rb
Modified:
    buildr/trunk/CHANGELOG
    buildr/trunk/lib/buildr/core/doc.rb
    buildr/trunk/lib/buildr/java/doc.rb
    buildr/trunk/lib/buildr/scala/doc.rb
    buildr/trunk/spec/java/compiler_spec.rb

Modified: buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=1002438&r1=1002437&r2=1002438&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Wed Sep 29 00:58:46 2010
@@ -1,4 +1,5 @@
 1.4.3 (Pending)
+* Fixed:  BUILDR-520 Scaladoc 2.8 no longer support -windowtitle, use -doc-title instead.
 * Fixed:  BUILDR-512 Buildr::Util.ruby invokes non existent method (Peter Donald)
 * Fixed:  BUILDR-513 --trace fails with NoMethodError : undefined method 
           `include?' for nil:NilClass

Modified: buildr/trunk/lib/buildr/core/doc.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/core/doc.rb?rev=1002438&r1=1002437&r2=1002438&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/core/doc.rb (original)
+++ buildr/trunk/lib/buildr/core/doc.rb Wed Sep 29 00:58:46 2010
@@ -74,7 +74,6 @@ module Buildr
       # Returns the documentation tool options.
       attr_reader :options
 
-      
       attr_reader :project # :nodoc:
 
       def initialize(*args) #:nodoc:
@@ -159,6 +158,19 @@ module Buildr
       end
 
       # :call-seq:
+      #   engine?(clazz) => boolean
+      #
+      # Check if the underlying engine is an instance of the given class
+      def engine?(clazz)
+        begin
+          @engine ||= guess_engine if project.compile.language
+        rescue
+          return false
+        end
+        @engine.is_a?(clazz) if @engine
+      end
+
+      # :call-seq:
       #   from(*sources) => self
       #
       # Includes files, directories and projects in the documentation and returns self.
@@ -221,15 +233,14 @@ module Buildr
       Project.local_task :doc
     end
 
-    before_define do |project|
+    before_define(:doc) do |project|
       DocTask.define_task('doc').tap do |doc|
         doc.send(:associate_with, project)
         doc.into project.path_to(:target, :doc)
-        doc.using :windowtitle=>project.comment || project.name
       end
     end
 
-    after_define do |project|
+    after_define(:doc) do |project|
       project.doc.from project
     end
 

Modified: buildr/trunk/lib/buildr/java/doc.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/java/doc.rb?rev=1002438&r1=1002437&r2=1002438&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/java/doc.rb (original)
+++ buildr/trunk/lib/buildr/java/doc.rb Wed Sep 29 00:58:46 2010
@@ -18,6 +18,18 @@ require 'buildr/core/doc'
 module Buildr
   module Doc
 
+    module JavadocDefaults
+      include Extension
+
+      # Default javadoc -windowtitle to project's comment or name
+      after_define(:javadoc => :doc) do |project|
+        if project.doc.engine? Javadoc
+          options = project.doc.options
+          options[:windowtitle] = (project.comment || project.name) unless options[:windowtitle]
+        end
+      end
+    end
+
     # A convenient task for creating Javadocs from the project's compile task. Minimizes
all
     # the hard work to calling #from and #using.
     #
@@ -65,6 +77,10 @@ module Buildr
       end
     end
   end
+
+  class Project
+    include JavadocDefaults
+  end
 end
 
 Buildr::Doc.engines << Buildr::Doc::Javadoc

Modified: buildr/trunk/lib/buildr/scala/doc.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/scala/doc.rb?rev=1002438&r1=1002437&r2=1002438&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/scala/doc.rb (original)
+++ buildr/trunk/lib/buildr/scala/doc.rb Wed Sep 29 00:58:46 2010
@@ -18,6 +18,20 @@ require 'buildr/scala/compiler'   # ensu
 
 module Buildr
   module Doc
+
+    module ScaladocDefaults
+      include Extension
+
+      # Default scaladoc -doc-title to project's comment or name
+      after_define(:scaladoc => :doc) do |project|
+        if project.doc.engine? Scaladoc
+          options = project.doc.options
+          key = Scala.compatible_28? ? "doc-title".to_sym : :windowtitle
+          options[key] = (project.comment || project.name) unless options[key]
+        end
+      end
+    end
+
     class Scaladoc < Base
       specify :language => :scala, :source_ext => 'scala'
 
@@ -100,6 +114,10 @@ module Buildr
       end
     end
   end
+
+  class Project
+    include ScaladocDefaults
+  end
 end
 
 Buildr::Doc.engines << Buildr::Doc::Scaladoc

Added: buildr/trunk/spec/core/doc_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/core/doc_spec.rb?rev=1002438&view=auto
==============================================================================
--- buildr/trunk/spec/core/doc_spec.rb (added)
+++ buildr/trunk/spec/core/doc_spec.rb Wed Sep 29 00:58:46 2010
@@ -0,0 +1,195 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+
+require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
+
+
+describe Project, '#doc' do
+  def sources
+    @sources ||= (1..3).map { |i| "Test#{i}" }.
+      each { |name| write "src/main/java/foo/#{name}.java", "package foo; public class #{name}{}"
}.
+      map { |name| "src/main/java/foo/#{name}.java" }
+  end
+
+  it 'should return the project\'s Javadoc task' do
+    define('foo') { compile.using(:javac) }
+    project('foo').doc.name.should eql('foo:doc')
+  end
+
+  it 'should return a DocTask' do
+    define('foo') { compile.using(:javac) }
+    project('foo').doc.should be_kind_of(Doc::DocTask)
+  end
+
+  it 'should set target directory to target/doc' do
+    define 'foo' do
+      compile.using(:javac)
+      doc.target.to_s.should point_to_path('target/doc')
+    end
+  end
+
+  it 'should create file task for target directory' do
+    define 'foo' do
+      compile.using(:javac)
+      doc.should_receive(:invoke_prerequisites)
+    end
+    project('foo').file('target/doc').invoke
+  end
+
+  it 'should respond to into() and return self' do
+    define 'foo' do
+      compile.using(:javac)
+      doc.into('docs').should be(doc)
+    end
+  end
+
+  it 'should respond to into() and change target directory' do
+    define 'foo' do
+      compile.using(:javac)
+      doc.into('docs')
+      doc.should_receive(:invoke_prerequisites)
+    end
+    file('docs').invoke
+  end
+
+  it 'should respond to from() and return self' do
+    task = nil
+    define('foo') do
+      compile.using(:javac)
+      task = doc.from('srcs')
+    end
+    task.should be(project('foo').doc)
+  end
+
+  it 'should respond to from() and add sources' do
+    define 'foo' do
+      compile.using(:javac)
+      doc.from('srcs').should be(doc)
+    end
+  end
+
+  it 'should respond to from() and add file task' do
+    define 'foo' do
+      compile.using(:javac)
+      doc.from('srcs').should be(doc)
+    end
+    project('foo').doc.source_files.first.should point_to_path('srcs')
+  end
+
+  it 'should respond to from() and add project\'s sources and dependencies' do
+    write 'bar/src/main/java/Test.java'
+    define 'foo' do
+      compile.using(:javac)
+      define('bar') { compile.using(:javac).with 'group:id:jar:1.0' }
+      doc.from project('foo:bar')
+    end
+    project('foo').doc.source_files.first.should point_to_path('bar/src/main/java/Test.java')
+    project('foo').doc.classpath.map(&:to_spec).should include('group:id:jar:1.0')
+  end
+
+  it 'should generate docs from project' do
+    sources
+    define('foo') { compile.using(:javac) }
+    project('foo').doc.source_files.sort.should == sources.sort.map { |f| File.expand_path(f)
}
+  end
+
+  it 'should include compile dependencies' do
+    define('foo') { compile.using(:javac).with 'group:id:jar:1.0' }
+    project('foo').doc.classpath.map(&:to_spec).should include('group:id:jar:1.0')
+  end
+
+  it 'should respond to include() and return self' do
+    define 'foo' do
+      compile.using(:javac)
+      doc.include('srcs').should be(doc)
+    end
+  end
+
+  it 'should respond to include() and add files' do
+    included = sources.first
+    define 'foo' do
+      compile.using(:javac)
+      doc.include included
+    end
+    project('foo').doc.source_files.should include(included)
+  end
+
+  it 'should respond to exclude() and return self' do
+    define 'foo' do
+      compile.using(:javac)
+      doc.exclude('srcs').should be(doc)
+    end
+  end
+
+  it 'should respond to exclude() and ignore files' do
+    excluded = sources.first
+    define 'foo' do
+      compile.using(:javac)
+      doc.exclude excluded
+    end
+    sources
+    project('foo').doc.source_files.sort.should == sources[1..-1].map { |f| File.expand_path(f)
}
+  end
+
+  it 'should respond to using() and return self' do
+    define 'foo' do
+      compile.using(:javac)
+      doc.using(:foo=>'Fooing').should be(doc)
+    end
+  end
+
+  it 'should respond to using() and accept options' do
+    define 'foo' do
+      compile.using(:javac)
+      doc.using :foo=>'Fooing'
+    end
+    project('foo').doc.options[:foo].should eql('Fooing')
+  end
+
+  it 'should produce documentation' do
+    sources
+    define('foo') { compile.using(:javac) }
+    project('foo').doc.invoke
+    (1..3).map { |i| "target/doc/foo/Test#{i}.html" }.each { |f| file(f).should exist }
+  end
+
+  it 'should fail on error' do
+    write 'Test.java', 'class Test {}'
+    define 'foo' do
+      compile.using(:javac)
+      doc.include 'Test.java'
+    end
+    lambda { project('foo').doc.invoke }.should raise_error(RuntimeError, /Failed to generate
Javadocs/)
+  end
+
+  it 'should be local task' do
+    define 'foo' do
+      define('bar') { compile.using(:javac) }
+    end
+    project('foo:bar').doc.should_receive(:invoke_prerequisites)
+    in_original_dir(project('foo:bar').base_dir) { task('doc').invoke }
+  end
+
+  it 'should not recurse' do
+    define 'foo' do
+      compile.using(:javac)
+      define('bar') { compile.using(:javac) }
+    end
+    project('foo:bar').doc.should_not_receive(:invoke_prerequisites)
+    project('foo').doc.invoke
+  end
+end
+

Modified: buildr/trunk/spec/java/compiler_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/java/compiler_spec.rb?rev=1002438&r1=1002437&r2=1002438&view=diff
==============================================================================
--- buildr/trunk/spec/java/compiler_spec.rb (original)
+++ buildr/trunk/spec/java/compiler_spec.rb Wed Sep 29 00:58:46 2010
@@ -250,197 +250,3 @@ describe 'javac compiler options' do
   end
 end
 
-
-describe Project, '#doc' do
-  def sources
-    @sources ||= (1..3).map { |i| "Test#{i}" }.
-      each { |name| write "src/main/java/foo/#{name}.java", "package foo; public class #{name}{}"
}.
-      map { |name| "src/main/java/foo/#{name}.java" }
-  end
-
-  it 'should return the project\'s Javadoc task' do
-    define('foo') { compile.using(:javac) }
-    project('foo').doc.name.should eql('foo:doc')
-  end
-
-  it 'should return a DocTask' do
-    define('foo') { compile.using(:javac) }
-    project('foo').doc.should be_kind_of(Doc::DocTask)
-  end
-
-  it 'should set target directory to target/doc' do
-    define 'foo' do
-      compile.using(:javac)
-      doc.target.to_s.should point_to_path('target/doc')
-    end
-  end
-
-  it 'should create file task for target directory' do
-    define 'foo' do
-      compile.using(:javac)
-      doc.should_receive(:invoke_prerequisites)
-    end
-    project('foo').file('target/doc').invoke
-  end
-
-  it 'should respond to into() and return self' do
-    define 'foo' do
-      compile.using(:javac)
-      doc.into('docs').should be(doc)
-    end
-  end
-
-  it 'should respond to into() and change target directory' do
-    define 'foo' do
-      compile.using(:javac)
-      doc.into('docs')
-      doc.should_receive(:invoke_prerequisites)
-    end
-    file('docs').invoke
-  end
-
-  it 'should respond to from() and return self' do
-    task = nil
-    define('foo') { task = doc.from('srcs') }
-    task.should be(project('foo').doc)
-  end
-
-  it 'should respond to from() and add sources' do
-    define 'foo' do
-      compile.using(:javac)
-      doc.from('srcs').should be(doc)
-    end
-  end
-
-  it 'should respond to from() and add file task' do
-    define 'foo' do
-      compile.using(:javac)
-      doc.from('srcs').should be(doc)
-    end
-    project('foo').doc.source_files.first.should point_to_path('srcs')
-  end
-
-  it 'should respond to from() and add project\'s sources and dependencies' do
-    write 'bar/src/main/java/Test.java'
-    define 'foo' do
-      compile.using(:javac)
-      define('bar') { compile.using(:javac).with 'group:id:jar:1.0' }
-      doc.from project('foo:bar')
-    end
-    project('foo').doc.source_files.first.should point_to_path('bar/src/main/java/Test.java')
-    project('foo').doc.classpath.map(&:to_spec).should include('group:id:jar:1.0')
-  end
-
-  it 'should generate docs from project' do
-    sources
-    define('foo') { compile.using(:javac) }
-    project('foo').doc.source_files.sort.should == sources.sort.map { |f| File.expand_path(f)
}
-  end
-
-  it 'should include compile dependencies' do
-    define('foo') { compile.using(:javac).with 'group:id:jar:1.0' }
-    project('foo').doc.classpath.map(&:to_spec).should include('group:id:jar:1.0')
-  end
-
-  it 'should respond to include() and return self' do
-    define 'foo' do
-      compile.using(:javac)
-      doc.include('srcs').should be(doc)
-    end
-  end
-
-  it 'should respond to include() and add files' do
-    included = sources.first
-    define 'foo' do
-      compile.using(:javac)
-      doc.include included
-    end
-    project('foo').doc.source_files.should include(included)
-  end
-
-  it 'should respond to exclude() and return self' do
-    define 'foo' do
-      compile.using(:javac)
-      doc.exclude('srcs').should be(doc)
-    end
-  end
-
-  it 'should respond to exclude() and ignore files' do
-    excluded = sources.first
-    define 'foo' do
-      compile.using(:javac)
-      doc.exclude excluded
-    end
-    sources
-    project('foo').doc.source_files.sort.should == sources[1..-1].map { |f| File.expand_path(f)
}
-  end
-
-  it 'should respond to using() and return self' do
-    define 'foo' do
-      compile.using(:javac)
-      doc.using(:windowtitle=>'Fooing').should be(doc)
-    end
-  end
-
-  it 'should respond to using() and accept options' do
-    define 'foo' do
-      compile.using(:javac)
-      doc.using :windowtitle=>'Fooing'
-    end
-    project('foo').doc.options[:windowtitle].should eql('Fooing')
-  end
-
-  it 'should pick -windowtitle from project name' do
-    define 'foo' do
-      compile.using(:javac)
-      doc.options[:windowtitle].should eql('foo')
-
-      define 'bar' do
-        compile.using(:javac)
-        doc.options[:windowtitle].should eql('foo:bar')
-      end
-    end
-  end
-
-  it 'should pick -windowtitle from project description' do
-    desc 'My App'
-    define 'foo' do
-      compile.using(:javac)
-      doc.options[:windowtitle].should eql('My App')
-    end
-  end
-
-  it 'should produce documentation' do
-    sources
-    define('foo') { compile.using(:javac) }
-    project('foo').doc.invoke
-    (1..3).map { |i| "target/doc/foo/Test#{i}.html" }.each { |f| file(f).should exist }
-  end
-
-  it 'should fail on error' do
-    write 'Test.java', 'class Test {}'
-    define 'foo' do
-      compile.using(:javac)
-      doc.include 'Test.java'
-    end
-    lambda { project('foo').doc.invoke }.should raise_error(RuntimeError, /Failed to generate
Javadocs/)
-  end
-
-  it 'should be local task' do
-    define 'foo' do
-      define('bar') { compile.using(:javac) }
-    end
-    project('foo:bar').doc.should_receive(:invoke_prerequisites)
-    in_original_dir(project('foo:bar').base_dir) { task('doc').invoke }
-  end
-
-  it 'should not recurse' do
-    define 'foo' do
-      compile.using(:javac)
-      define('bar') { compile.using(:javac) }
-    end
-    project('foo:bar').doc.should_not_receive(:invoke_prerequisites)
-    project('foo').doc.invoke
-  end
-end
-

Added: buildr/trunk/spec/java/doc_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/java/doc_spec.rb?rev=1002438&view=auto
==============================================================================
--- buildr/trunk/spec/java/doc_spec.rb (added)
+++ buildr/trunk/spec/java/doc_spec.rb Wed Sep 29 00:58:46 2010
@@ -0,0 +1,56 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+
+require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
+
+describe 'Javadoc' do
+  def sources
+    @sources ||= (1..3).map { |i| "Test#{i}" }.
+      each { |name| write "src/main/java/foo/#{name}.java", "package foo; public class #{name}{}"
}.
+      map { |name| "src/main/java/foo/#{name}.java" }
+  end
+
+  it 'should pick -windowtitle from project name by default' do
+    define 'foo' do
+      compile.using(:javac)
+
+      define 'bar' do
+        compile.using(:javac)
+      end
+    end
+
+    project('foo').doc.options[:windowtitle].should eql('foo')
+    project('foo:bar').doc.options[:windowtitle].should eql('foo:bar')
+  end
+
+  it 'should pick -windowtitle from project description by default, if available' do
+    desc 'My App'
+    define 'foo' do
+      compile.using(:javac)
+    end
+    project('foo').doc.options[:windowtitle].should eql('My App')
+  end
+
+  it 'should not override explicit :windowtitle' do
+    define 'foo' do
+      compile.using(:javac)
+      doc.using :windowtitle => 'explicit'
+    end
+    project('foo').doc.options[:windowtitle].should eql('explicit')
+  end
+
+end
+

Added: buildr/trunk/spec/scala/doc_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/scala/doc_spec.rb?rev=1002438&view=auto
==============================================================================
--- buildr/trunk/spec/scala/doc_spec.rb (added)
+++ buildr/trunk/spec/scala/doc_spec.rb Wed Sep 29 00:58:46 2010
@@ -0,0 +1,67 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+
+require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
+
+describe "Scaladoc" do
+
+  before(:each) do
+    # Force Scala 2.8.0 for specs; don't want to rely on SCALA_HOME
+    Buildr.settings.build['scala.version'] = "2.8.0"
+  end
+
+  it 'should pick -doc-title from project name by default' do
+    define 'foo' do
+      compile.using(:scalac)
+
+      define 'bar' do
+        compile.using(:scalac)
+      end
+    end
+
+    project('foo').doc.options[:"doc-title"].should eql('foo')
+    project('foo:bar').doc.options[:"doc-title"].should eql('foo:bar')
+  end
+
+  it 'should pick -doc-title from project description by default, if available' do
+    desc 'My App'
+    define 'foo' do
+      compile.using(:scalac)
+    end
+    project('foo').doc.options[:"doc-title"].should eql('My App')
+  end
+
+  it 'should not override explicit "doc-title" option' do
+    define 'foo' do
+      compile.using(:scalac)
+      doc.using "doc-title" => 'explicit'
+    end
+    project('foo').doc.options[:"doc-title"].should eql('explicit')
+  end
+
+  it 'should convert :windowtitle to -doc-title for Scala 2.8.0' do
+    write 'src/main/scala/com/example/Test.scala', 'package com.example; class Test { val
i = 1 }'
+    define('foo') do
+      doc.using :windowtitle => "foo"
+    end
+    Java.scala.tools.nsc.ScalaDoc.should_receive(:main) do |args|
+      args.map(&:toString).should include("-doc-title")
+      0 # normal return
+    end
+    project('foo').doc.invoke
+  end
+
+end



Mime
View raw message