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
end
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
def index_file
......
......@@ -316,27 +316,35 @@ module Pod
end
# 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}.
#
# @raise [Informative] If the pod was cleaned.
#
# @todo Merge with #221
#
# @return [Array<Pathname>] The path of all the public headers of the pod.
#
def all_specs_public_header_files
def documentation_headers
if @cleaned
raise Informative, "The pod is cleaned and cannot compute the " \
"header files, as some might have been deleted."
end
all_specs = [ top_specification ] + top_specification.subspecs
options = {:glob => '*.{h}'}
files = paths_by_spec(:source_files, options, all_specs).values.flatten
headers = files.select { |f| f.extname == '.h' }
headers
specs = [top_specification] + top_specification.recursive_subspecs
source_files = paths_by_spec(:source_files, { :glob => '*.{h}'}, specs)
public_headers = paths_by_spec(:public_header_files,{ :glob => '*.{h}'}, specs)
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
# @!group Target integration
......
......@@ -35,8 +35,6 @@ describe Pod::Generator::Documentation do
'--keep-intermediate-files',
'--exit-threshold', '2',
'--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',
'--company-id', 'com.banana'
]
......
......@@ -11,7 +11,7 @@ describe Pod::LocalPod do
copy_fixture_to_pod('banana-lib', @pod)
end
it 'returns the Pod root directory path' do
it "returns the Pod root directory path" do
@pod.root.should == @sandbox.root + 'BananaLib'
end
......@@ -25,20 +25,20 @@ describe Pod::LocalPod do
Pathname(@pod.root + "foo").should.exist
end
it 'can delete itself' do
it "can delete itself" do
@pod.create
@pod.implode
@pod.root.should.not.exist
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 == [
Pathname.new("BananaLib/Classes/Banana.m"),
Pathname.new("BananaLib/Classes/Banana.h")
].sort
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.should == [
@pod.root + "Classes/Banana.m",
......@@ -46,16 +46,16 @@ describe Pod::LocalPod do
].sort
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")]
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.should == [ @pod.root + "Classes/Banana.h" ]
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.should.include "/.git/config"
# * There are some hidden files on Travis
......@@ -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 ]
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")]
end
......@@ -244,12 +244,19 @@ describe Pod::LocalPod do
assert_array_equals(expected, computed)
end
it "resolves the header files of **every** subspec" do
computed = @pod.all_specs_public_header_files.map { |p| p.relative_path_from(@pod.root).to_s }
it "resolves the documentation header files including not activated subspecs" do
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[
UIKit/Classes/UIKit.h
UIKit/Classes/UIView.h
UIKit/Classes/UIWindow.h
StoreKit/Classes/SKPayment.h
StoreKit/Classes/StoreKit.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