Method: Licensed::Sources::Cabal#package_docs_dirs

Defined in:
lib/licensed/sources/cabal.rb

#package_docs_dirs(package) ⇒ Object

Returns the packages document directory and search root directory as an array



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/licensed/sources/cabal.rb', line 50

def package_docs_dirs(package)
  return [nil, nil] if package.nil? || package.empty?

  unless package["haddock-html"]
    # default to a local vendor directory if haddock-html property
    # isn't available
    return [File.join(config.pwd, "vendor", package["name"]), nil]
  end

  html_dir = package["haddock-html"]
  data_dir = package["data-dir"]
  return [html_dir, nil] unless data_dir

  # only allow data directories that are ancestors of the html directory
  unless Pathname.new(html_dir).fnmatch?(File.join(data_dir, "**"))
    data_dir = nil
  end

  [html_dir, data_dir]
end