2024-03-06 01:00:39 +01:00
|
|
|
# typed: strict
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require "abstract_command"
|
|
|
|
|
|
|
|
module Homebrew
|
|
|
|
module DevCmd
|
|
|
|
class Rubydoc < AbstractCommand
|
|
|
|
cmd_args do
|
|
|
|
description <<~EOS
|
|
|
|
Generate Homebrew's RubyDoc documentation.
|
|
|
|
EOS
|
|
|
|
switch "--only-public",
|
|
|
|
description: "Only generate public API documentation."
|
|
|
|
switch "--open",
|
|
|
|
description: "Open generated documentation in a browser."
|
|
|
|
end
|
|
|
|
|
|
|
|
sig { override.void }
|
|
|
|
def run
|
|
|
|
Homebrew.install_bundler_gems!(groups: ["doc"])
|
|
|
|
|
2024-04-26 20:55:51 +02:00
|
|
|
HOMEBREW_LIBRARY_PATH.cd do |dir|
|
2024-03-06 01:00:39 +01:00
|
|
|
no_api_args = if args.only_public?
|
|
|
|
["--hide-api", "private", "--hide-api", "internal"]
|
|
|
|
else
|
|
|
|
[]
|
|
|
|
end
|
|
|
|
|
2024-04-26 20:55:51 +02:00
|
|
|
output_dir = dir/"doc"
|
2024-03-06 01:00:39 +01:00
|
|
|
|
2024-04-26 20:55:51 +02:00
|
|
|
safe_system "bundle", "exec", "yard", "doc", "--fail-on-warning", *no_api_args, "--output", output_dir
|
|
|
|
|
|
|
|
exec_browser "file://#{output_dir}/index.html" if args.open?
|
2024-03-06 01:00:39 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|