autobuild 1.6.2.b11 → 1.6.2.b12

Sign up to get free protection for your applications and to get access to all the features.
@@ -101,7 +101,7 @@ module Autobuild
101
101
  # false.
102
102
  def updated?; !!@updated end
103
103
 
104
- def initialize(spec)
104
+ def initialize(spec = Hash.new)
105
105
  @dependencies = Array.new
106
106
  @provides = Array.new
107
107
  @parallel_build_level = nil
@@ -374,27 +374,31 @@ module Autobuild
374
374
  # In general, specific package types define a meaningful #with_doc
375
375
  # method which calls this method internally.
376
376
  def doc_task
377
- task "#{name}-doc" do
378
- @installed_doc = false
379
- catch(:doc_disabled) do
380
- begin
381
- yield if block_given?
382
-
383
- unless @installed_doc
384
- install_doc
385
- end
377
+ @doc_task = task "#{name}-doc" do
378
+ # This flag allows to disable documentation generation
379
+ # once doc_task has been called
380
+ if generates_doc?
381
+ @installed_doc = false
382
+ catch(:doc_disabled) do
383
+ begin
384
+ yield if block_given?
385
+
386
+ unless @installed_doc
387
+ install_doc
388
+ end
386
389
 
387
- rescue Interrupt
388
- raise
389
- rescue ::Exception => e
390
- if Autobuild.doc_errors
390
+ rescue Interrupt
391
391
  raise
392
- else
393
- warn "%s: failed to generate documentation"
394
- if e.kind_of?(SubcommandFailed)
395
- warn "%s: see #{e.logfile} for more details"
392
+ rescue ::Exception => e
393
+ if Autobuild.doc_errors
394
+ raise
396
395
  else
397
- warn "%s: #{e.message}"
396
+ warn "%s: failed to generate documentation"
397
+ if e.kind_of?(SubcommandFailed)
398
+ warn "%s: see #{e.logfile} for more details"
399
+ else
400
+ warn "%s: #{e.message}"
401
+ end
398
402
  end
399
403
  end
400
404
  end
@@ -404,6 +408,30 @@ module Autobuild
404
408
  task :doc => "#{name}-doc"
405
409
  end
406
410
 
411
+ # True if some documentation will be generated and false otherwise.
412
+ #
413
+ # This will return true only if a documentation task has been defined by
414
+ # calling #doc_task _and_ #disable_doc has not been called (or if
415
+ # #enable_doc has been called after the last call to #disable_doc).
416
+ def generates_doc?
417
+ if @doc_disabled
418
+ return false
419
+ else
420
+ return !!@doc_task
421
+ end
422
+ end
423
+
424
+ # Re-enables documentation generation after #disable_doc has been called
425
+ def enable_doc
426
+ @doc_disabled = false
427
+ end
428
+
429
+ # Disables any documentation generation, regardless of whether doc_task
430
+ # has been called or not.
431
+ def disable_doc
432
+ @doc_disabled = true
433
+ end
434
+
407
435
  def install_doc
408
436
  if !File.directory?(self.doc_dir)
409
437
  raise "#{self.doc_dir} was expected to be a directory, but it is not. Check the package's documentation generation, the generated documentation should be in #{self.doc_dir}"
@@ -1,5 +1,5 @@
1
1
  module Autobuild
2
- VERSION = "1.6.2.b11" unless defined? Autobuild::VERSION
2
+ VERSION = "1.6.2.b12" unless defined? Autobuild::VERSION
3
3
  end
4
4
 
5
5
 
@@ -0,0 +1,21 @@
1
+ $LOAD_PATH.unshift File.expand_path('..', File.dirname(__FILE__))
2
+ $LOAD_PATH << File.expand_path('../lib', File.dirname(__FILE__))
3
+ require 'test/unit'
4
+ require 'test/tools'
5
+ require 'autobuild'
6
+
7
+ class TC_Package < Test::Unit::TestCase
8
+ include Autobuild
9
+
10
+ def test_generates_doc_p
11
+ pkg = Autobuild::Package.new
12
+ assert !pkg.generates_doc?
13
+ pkg.doc_task
14
+ assert pkg.generates_doc?
15
+ pkg.disable_doc
16
+ assert !pkg.generates_doc?
17
+ pkg.enable_doc
18
+ assert pkg.generates_doc?
19
+ end
20
+ end
21
+
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autobuild
3
3
  version: !ruby/object:Gem::Version
4
- hash: -3493996294
4
+ hash: 4225852661
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 1
8
8
  - 6
9
9
  - 2
10
10
  - b
11
- - 11
12
- version: 1.6.2.b11
11
+ - 12
12
+ version: 1.6.2.b12
13
13
  platform: ruby
14
14
  authors:
15
15
  - Sylvain Joyeux
@@ -134,6 +134,7 @@ files:
134
134
  - test/test_import_tar.rb
135
135
  - test/test_subcommand.rb
136
136
  - test/tools.rb
137
+ - test/test_package.rb
137
138
  - .gemtest
138
139
  homepage: http://rock-robotics.org/stable/documentation/autoproj
139
140
  licenses: []
@@ -175,4 +176,5 @@ test_files:
175
176
  - test/test_import_svn.rb
176
177
  - test/test_import_tar.rb
177
178
  - test/test_subcommand.rb
179
+ - test/test_package.rb
178
180
  - test/test_import_cvs.rb