Class: Fastlane::Actions::AppledocAction

Inherits:
Fastlane::Action show all
Defined in:
lib/fastlane/actions/appledoc.rb

Constant Summary collapse

ARGS_MAP =
{
  input: "",
  output: "--output",
  templates: "--templates",
  docset_install_path: "--docset-install-path",
  include: "--include",
  ignore: "--ignore",
  exclude_output: "--exclude-output",
  index_desc: "--index-desc",
  project_name: "--project-name",
  project_version: "--project-version",
  project_company: "--project-company",
  company_id: "--company-id",
  create_html: "--create-html",
  create_docset: "--create-docset",
  install_docset: "--install-docset",
  publish_docset: "--publish-docset",
  html_anchors: "--html-anchors",
  clean_output: "--clean-output",
  docset_bundle_id: "--docset-bundle-id",
  docset_bundle_name: "--docset-bundle-name",
  docset_desc: "--docset-desc",
  docset_copyright: "--docset-copyright",
  docset_feed_name: "--docset-feed-name",
  docset_feed_url: "--docset-feed-url",
  docset_feed_formats: "--docset-feed-formats",
  docset_package_url: "--docset-package-url",
  docset_fallback_url: "--docset-fallback-url",
  docset_publisher_id: "--docset-publisher-id",
  docset_publisher_name: "--docset-publisher-name",
  docset_min_xcode_version: "--docset-min-xcode-version",
  docset_platform_family: "--docset-platform-family",
  docset_cert_issuer: "--docset-cert-issuer",
  docset_cert_signer: "--docset-cert-signer",
  docset_bundle_filename: "--docset-bundle-filename",
  docset_atom_filename: "--docset-atom-filename",
  docset_xml_filename: "--docset-xml-filename",
  docset_package_filename: "--docset-package-filename",
  options: "",
  crossref_format: "--crossref-format",
  exit_threshold: "--exit-threshold",
  docs_section_title: "--docs-section-title",
  warnings: "",
  logformat: "--logformat",
  verbose: "--verbose"
}

Class Method Summary collapse

Methods inherited from Fastlane::Action

action_name, author, details, method_missing, other_action, return_value, sh, step_text

Class Method Details

.authorsObject



187
188
189
# File 'lib/fastlane/actions/appledoc.rb', line 187

def self.authors
  ["alexmx"]
end

.available_optionsObject



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/fastlane/actions/appledoc.rb', line 119

def self.available_options
  [
    # PATHS
    FastlaneCore::ConfigItem.new(key: :input, env_name: "FL_APPLEDOC_INPUT", description: "Path to source files", is_string: true),
    FastlaneCore::ConfigItem.new(key: :output, env_name: "FL_APPLEDOC_OUTPUT", description: "Output path", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :templates, env_name: "FL_APPLEDOC_TEMPLATES", description: "Template files path", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :docset_install_path, env_name: "FL_APPLEDOC_DOCSET_INSTALL_PATH", description: "DocSet installation path", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :include, env_name: "FL_APPLEDOC_INCLUDE", description: "Include static doc(s) at path", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :ignore, env_name: "FL_APPLEDOC_IGNORE", description: "Ignore given path", is_string: false, optional: true),
    FastlaneCore::ConfigItem.new(key: :exclude_output, env_name: "FL_APPLEDOC_EXCLUDE_OUTPUT", description: "Exclude given path from output", is_string: false, optional: true),
    FastlaneCore::ConfigItem.new(key: :index_desc, env_name: "FL_APPLEDOC_INDEX_DESC", description: "File including main index description", is_string: true, optional: true),

    # PROJECT INFO
    FastlaneCore::ConfigItem.new(key: :project_name, env_name: "FL_APPLEDOC_PROJECT_NAME", description: "Project name", is_string: true),
    FastlaneCore::ConfigItem.new(key: :project_version, env_name: "FL_APPLEDOC_PROJECT_VERSION", description: "Project version", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :project_company, env_name: "FL_APPLEDOC_PROJECT_COMPANY", description: "Project company", is_string: true),
    FastlaneCore::ConfigItem.new(key: :company_id, env_name: "FL_APPLEDOC_COMPANY_ID", description: "Company UTI (i.e. reverse DNS name)", is_string: true, optional: true),

    # OUTPUT GENERATION
    FastlaneCore::ConfigItem.new(key: :create_html, env_name: "FL_APPLEDOC_CREATE_HTML", description: "Create HTML", is_string: false, default_value: false),
    FastlaneCore::ConfigItem.new(key: :create_docset, env_name: "FL_APPLEDOC_CREATE_DOCSET", description: "Create documentation set", is_string: false, default_value: false),
    FastlaneCore::ConfigItem.new(key: :install_docset, env_name: "FL_APPLEDOC_INSTALL_DOCSET", description: "Install documentation set to Xcode", is_string: false, default_value: false),
    FastlaneCore::ConfigItem.new(key: :publish_docset, env_name: "FL_APPLEDOC_PUBLISH_DOCSET", description: "Prepare DocSet for publishing", is_string: false, default_value: false),
    FastlaneCore::ConfigItem.new(key: :html_anchors, env_name: "FL_APPLEDOC_HTML_ANCHORS", description: "The html anchor format to use in DocSet HTML", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :clean_output, env_name: "FL_APPLEDOC_CLEAN_OUTPUT", description: "Remove contents of output path before starting", is_string: false, default_value: false),

    # DOCUMENTATION SET INFO
    FastlaneCore::ConfigItem.new(key: :docset_bundle_id, env_name: "FL_APPLEDOC_DOCSET_BUNDLE_ID", description: "DocSet bundle identifier", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :docset_bundle_name, env_name: "FL_APPLEDOC_DOCSET_BUNDLE_NAME", description: "DocSet bundle name", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :docset_desc, env_name: "FL_APPLEDOC_DOCSET_DESC", description: "DocSet description", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :docset_copyright, env_name: "FL_APPLEDOC_DOCSET_COPYRIGHT", description: "DocSet copyright message", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :docset_feed_name, env_name: "FL_APPLEDOC_DOCSET_FEED_NAME", description: "DocSet feed name", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :docset_feed_url, env_name: "FL_APPLEDOC_DOCSET_FEED_URL", description: "DocSet feed URL", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :docset_feed_formats, env_name: "FL_APPLEDOC_DOCSET_FEED_FORMATS", description: "DocSet feed formats. Separated by a comma [atom,xml]", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :docset_package_url, env_name: "FL_APPLEDOC_DOCSET_PACKAGE_URL", description: "DocSet package (.xar) URL", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :docset_fallback_url, env_name: "FL_APPLEDOC_DOCSET_FALLBACK_URL", description: "DocSet fallback URL", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :docset_publisher_id, env_name: "FL_APPLEDOC_DOCSET_PUBLISHER_ID", description: "DocSet publisher identifier", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :docset_publisher_name, env_name: "FL_APPLEDOC_DOCSET_PUBLISHER_NAME", description: "DocSet publisher name", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :docset_min_xcode_version, env_name: "FL_APPLEDOC_DOCSET_MIN_XCODE_VERSION", description: "DocSet min. Xcode version", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :docset_platform_family, env_name: "FL_APPLEDOC_DOCSET_PLATFORM_FAMILY", description: "DocSet platform familiy", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :docset_cert_issuer, env_name: "FL_APPLEDOC_DOCSET_CERT_ISSUER", description: "DocSet certificate issuer", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :docset_cert_signer, env_name: "FL_APPLEDOC_DOCSET_CERT_SIGNER", description: "DocSet certificate signer", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :docset_bundle_filename, env_name: "FL_APPLEDOC_DOCSET_BUNDLE_FILENAME", description: "DocSet bundle filename", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :docset_atom_filename, env_name: "FL_APPLEDOC_DOCSET_ATOM_FILENAME", description: "DocSet atom feed filename", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :docset_xml_filename, env_name: "FL_APPLEDOC_DOCSET_XML_FILENAME", description: "DocSet xml feed filename", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :docset_package_filename, env_name: "FL_APPLEDOC_DOCSET_PACKAGE_FILENAME", description: "DocSet package (.xar,.tgz) filename", is_string: true, optional: true),

    # OPTIONS
    FastlaneCore::ConfigItem.new(key: :options, env_name: "FL_APPLEDOC_OPTIONS", description: "Documentation generation options", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :crossref_format, env_name: "FL_APPLEDOC_OPTIONS_CROSSREF_FORMAT", description: "Cross reference template regex", is_string: true, optional: true),
    FastlaneCore::ConfigItem.new(key: :exit_threshold, env_name: "FL_APPLEDOC_OPTIONS_EXIT_THRESHOLD", description: "Exit code threshold below which 0 is returned", is_string: false, default_value: 2, optional: true),
    FastlaneCore::ConfigItem.new(key: :docs_section_title, env_name: "FL_APPLEDOC_OPTIONS_DOCS_SECTION_TITLE", description: "Title of the documentation section (defaults to \"Programming Guides\"", is_string: true, optional: true),

    # WARNINGS
    FastlaneCore::ConfigItem.new(key: :warnings, env_name: "FL_APPLEDOC_WARNINGS", description: "Documentation generation warnings", is_string: true, optional: true),

    # MISCELLANEOUS
    FastlaneCore::ConfigItem.new(key: :logformat, env_name: "FL_APPLEDOC_LOGFORMAT", description: "Log format [0-3]", is_string: false, optional: true),
    FastlaneCore::ConfigItem.new(key: :verbose, env_name: "FL_APPLEDOC_VERBOSE", description: "Log verbosity level [0-6,xcode]", is_string: false, optional: true)
  ]
end

.cli_param(k, v) ⇒ Object



101
102
103
104
# File 'lib/fastlane/actions/appledoc.rb', line 101

def self.cli_param(k, v)
  value = (v != true && v.to_s.length > 0 ? "\"#{v}\"" : "")
  "#{k} #{value}".strip
end

.create_output_dir_if_not_exists(output_path) ⇒ Object



106
107
108
109
110
111
112
113
# File 'lib/fastlane/actions/appledoc.rb', line 106

def self.create_output_dir_if_not_exists(output_path)
  output_dir = File.dirname(output_path)

  # If the output directory doesn't exist, create it
  unless Dir.exist? output_dir
    FileUtils.mkpath output_dir
  end
end

.descriptionObject



115
116
117
# File 'lib/fastlane/actions/appledoc.rb', line 115

def self.description
  "Runs `appledoc [OPTIONS] <paths to source dirs or files>` for the project"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


191
192
193
# File 'lib/fastlane/actions/appledoc.rb', line 191

def self.is_supported?(platform)
  [:ios, :mac].include?(platform)
end

.outputObject



181
182
183
184
185
# File 'lib/fastlane/actions/appledoc.rb', line 181

def self.output
  [
    ['APPLEDOC_DOCUMENTATION_OUTPUT', 'Documentation set output path']
  ]
end

.params_hash_to_cli_args(params) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/fastlane/actions/appledoc.rb', line 78

def self.params_hash_to_cli_args(params)
  # Remove nil and false value params
  params = params.delete_if { |_, v| v.nil? || v == false}

  cli_args = []
  params.each do |key, value|
    args = ARGS_MAP[key]
    if args.empty?
      if key != :input
        cli_args << value
      end
    elsif value.kind_of?(Array)
      value.each do |v|
        cli_args << cli_param(args, v)
      end
    else
      cli_args << cli_param(args, value)
    end
  end

  return cli_args
end

.run(params) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/fastlane/actions/appledoc.rb', line 55

def self.run(params)
  unless Helper.test?
    UI.message("Install using `brew install homebrew/boneyard/appledoc`")
    UI.user_error!("appledoc not installed") if `which appledoc`.length == 0
  end

  params_hash = params.values

  # Check if an output path was given
  if params_hash[:output]
    Actions.lane_context[SharedValues::APPLEDOC_DOCUMENTATION_OUTPUT] = File.expand_path(params_hash[:output])
    create_output_dir_if_not_exists(params_hash[:output])
  end

  # Maps parameter hash to CLI args
  appledoc_args = params_hash_to_cli_args(params_hash)
  UI.success("Generating documentation.")
  cli_args = appledoc_args.join(' ')
  command = "appledoc #{cli_args}".strip + " \"#{params_hash[:input]}\""
  UI.verbose(command)
  Actions.sh command
end