Commit 8a958285 authored by Fabio Pelosin's avatar Fabio Pelosin

[Documentation] Use public headers if specified.

Closes #318.
parent c9dd6934
...@@ -42,7 +42,7 @@ module Pod ...@@ -42,7 +42,7 @@ module Pod
end end
def files def files
@pod.all_specs_public_header_files.map{ |f| f.relative_path_from(@pod.root).to_s } @pod.documentation_headers.map{ |f| f.relative_path_from(@pod.root).to_s }
end end
def index_file def index_file
......
...@@ -316,27 +316,35 @@ module Pod ...@@ -316,27 +316,35 @@ module Pod
end end
# Computes the paths of all the public headers of the pod including every # Computes the paths of all the public headers of the pod including every
# subspec. For this reason the pod must not be cleaned before calling it. # subspec (activated or not).
# For this reason the pod must not be cleaned when calling this command.
# #
# This method is used by {Generator::Documentation}. # This method is used by {Generator::Documentation}.
# #
# @raise [Informative] If the pod was cleaned. # @raise [Informative] If the pod was cleaned.
# #
# @todo Merge with #221
#
# @return [Array<Pathname>] The path of all the public headers of the pod. # @return [Array<Pathname>] The path of all the public headers of the pod.
# #
def all_specs_public_header_files def documentation_headers
if @cleaned if @cleaned
raise Informative, "The pod is cleaned and cannot compute the " \ raise Informative, "The pod is cleaned and cannot compute the " \
"header files, as some might have been deleted." "header files, as some might have been deleted."
end end
all_specs = [ top_specification ] + top_specification.subspecs specs = [top_specification] + top_specification.recursive_subspecs
options = {:glob => '*.{h}'} source_files = paths_by_spec(:source_files, { :glob => '*.{h}'}, specs)
files = paths_by_spec(:source_files, options, all_specs).values.flatten public_headers = paths_by_spec(:public_header_files,{ :glob => '*.{h}'}, specs)
headers = files.select { |f| f.extname == '.h' }
headers result = []
specs.each do |spec|
if (public_h = public_headers[spec]) && !public_h.empty?
result += public_h
elsif (source_f = source_files[spec]) && !source_f.empty?
build_h = source_f.select { |f| f.extname == '.h' }
result += build_h unless build_h.empty?
end
end
result
end end
# @!group Target integration # @!group Target integration
......
...@@ -35,8 +35,6 @@ describe Pod::Generator::Documentation do ...@@ -35,8 +35,6 @@ describe Pod::Generator::Documentation do
'--keep-intermediate-files', '--keep-intermediate-files',
'--exit-threshold', '2', '--exit-threshold', '2',
'--index-desc', 'README', '--index-desc', 'README',
# TODO We need to either make this a hash so that options can be merged
# or not use any defaults in case an options are specified.
'--project-company', 'Banana Corp', '--project-company', 'Banana Corp',
'--company-id', 'com.banana' '--company-id', 'com.banana'
] ]
......
...@@ -11,7 +11,7 @@ describe Pod::LocalPod do ...@@ -11,7 +11,7 @@ describe Pod::LocalPod do
copy_fixture_to_pod('banana-lib', @pod) copy_fixture_to_pod('banana-lib', @pod)
end end
it 'returns the Pod root directory path' do it "returns the Pod root directory path" do
@pod.root.should == @sandbox.root + 'BananaLib' @pod.root.should == @sandbox.root + 'BananaLib'
end end
...@@ -25,20 +25,20 @@ describe Pod::LocalPod do ...@@ -25,20 +25,20 @@ describe Pod::LocalPod do
Pathname(@pod.root + "foo").should.exist Pathname(@pod.root + "foo").should.exist
end end
it 'can delete itself' do it "can delete itself" do
@pod.create @pod.create
@pod.implode @pod.implode
@pod.root.should.not.exist @pod.root.should.not.exist
end end
it 'returns an expanded list of source files, relative to the sandbox root' do it "returns an expanded list of source files, relative to the sandbox root" do
@pod.relative_source_files.sort.should == [ @pod.relative_source_files.sort.should == [
Pathname.new("BananaLib/Classes/Banana.m"), Pathname.new("BananaLib/Classes/Banana.m"),
Pathname.new("BananaLib/Classes/Banana.h") Pathname.new("BananaLib/Classes/Banana.h")
].sort ].sort
end end
it 'returns the source files groupped by specification' do it "returns the source files groupped by specification" do
files = @pod.source_files_by_spec[@pod.specifications.first].sort files = @pod.source_files_by_spec[@pod.specifications.first].sort
files.should == [ files.should == [
@pod.root + "Classes/Banana.m", @pod.root + "Classes/Banana.m",
...@@ -46,16 +46,16 @@ describe Pod::LocalPod do ...@@ -46,16 +46,16 @@ describe Pod::LocalPod do
].sort ].sort
end end
it 'returns a list of header files' do it "returns a list of header files" do
@pod.relative_header_files.should == [Pathname.new("BananaLib/Classes/Banana.h")] @pod.relative_header_files.should == [Pathname.new("BananaLib/Classes/Banana.h")]
end end
it 'returns a list of header files by specification' do it "returns a list of header files by specification" do
files = @pod.header_files_by_spec[@pod.specifications.first].sort files = @pod.header_files_by_spec[@pod.specifications.first].sort
files.should == [ @pod.root + "Classes/Banana.h" ] files.should == [ @pod.root + "Classes/Banana.h" ]
end end
it 'returns an expanded list the files to clean' do it "returns an expanded list the files to clean" do
clean_paths = @pod.clean_paths.map { |p| p.to_s.gsub(/.*Pods\/BananaLib/,'') } clean_paths = @pod.clean_paths.map { |p| p.to_s.gsub(/.*Pods\/BananaLib/,'') }
clean_paths.should.include "/.git/config" clean_paths.should.include "/.git/config"
# * There are some hidden files on Travis # * There are some hidden files on Travis
...@@ -64,7 +64,7 @@ describe Pod::LocalPod do ...@@ -64,7 +64,7 @@ describe Pod::LocalPod do
clean_files_without_hidden.should == %W[ /sub-dir /sub-dir/sub-dir-2 /sub-dir/sub-dir-2/somefile.txt ] clean_files_without_hidden.should == %W[ /sub-dir /sub-dir/sub-dir-2 /sub-dir/sub-dir-2/somefile.txt ]
end end
it 'returns an expanded list of resources, relative to the sandbox root' do it "returns an expanded list of resources, relative to the sandbox root" do
@pod.relative_resource_files.should == [Pathname.new("BananaLib/Resources/logo-sidebar.png")] @pod.relative_resource_files.should == [Pathname.new("BananaLib/Resources/logo-sidebar.png")]
end end
...@@ -244,12 +244,19 @@ describe Pod::LocalPod do ...@@ -244,12 +244,19 @@ describe Pod::LocalPod do
assert_array_equals(expected, computed) assert_array_equals(expected, computed)
end end
it "resolves the header files of **every** subspec" do it "resolves the documentation header files including not activated subspecs" do
computed = @pod.all_specs_public_header_files.map { |p| p.relative_path_from(@pod.root).to_s } subspecs = fixture_spec('chameleon/Chameleon.podspec').subspecs
spec = subspecs[0]
spec.stubs(:public_header_files).returns("UIKit/Classes/*Kit.h")
@pod = Pod::LocalPod.new(spec, @sandbox, Pod::Platform.new(:osx))
# Note we only activated UIKit but all the specs need to be resolved
computed = @pod.documentation_headers.map { |p| p.relative_path_from(@pod.root).to_s }
# The Following headers are private:
# UIKit/Classes/UIView.h
# UIKit/Classes/UIWindow.h
expected = %w[ expected = %w[
UIKit/Classes/UIKit.h UIKit/Classes/UIKit.h
UIKit/Classes/UIView.h
UIKit/Classes/UIWindow.h
StoreKit/Classes/SKPayment.h StoreKit/Classes/SKPayment.h
StoreKit/Classes/StoreKit.h StoreKit/Classes/StoreKit.h
MessageUI/Classes/MessageUI.h MessageUI/Classes/MessageUI.h
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment