diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 122f04d82f9006..b4e94426e5c455 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -810,7 +810,7 @@ def doc # No `make install` available? # # ```ruby - # include.install "example.h" + # include.install "example.h" # ``` # # @api public @@ -855,9 +855,10 @@ def lib # # ### Example # - #
libexec.install "foo.jar" + # ```ruby + # libexec.install "foo.jar" # bin.write_jar_script libexec/"foo.jar", "foo" - #+ # ``` # # @api public sig { returns(Pathname) } @@ -885,7 +886,9 @@ def man # # No `make install` available? # - #
man1.install "example.1"+ # ```ruby + # man1.install "example.1" + # ``` # # @api public sig { returns(Pathname) } @@ -911,7 +914,9 @@ def man2 # # No `make install` available? # - #
man3.install "man.3"+ # ```ruby + # man3.install "man.3" + # ``` # # @api public sig { returns(Pathname) } @@ -988,19 +993,27 @@ def sbin # # Need a custom directory? # - #
(share/"concept").mkpath+ # ```ruby + # (share/"concept").mkpath + # ``` # # Installing something into another custom directory? # - #
(share/"concept2").install "ducks.txt"+ # ```ruby + # (share/"concept2").install "ducks.txt" + # ``` # # Install `./example_code/simple/ones` to `share/demos`: # - #
(share/"demos").install "example_code/simple/ones"+ # ```ruby + # (share/"demos").install "example_code/simple/ones" + # ``` # # Install `./example_code/simple/ones` to `share/demos/examples`: # - #
(share/"demos").install "example_code/simple/ones" => "examples"+ # ```ruby + # (share/"demos").install "example_code/simple/ones" => "examples" + # ``` # # @api public sig { returns(Pathname) } @@ -1017,7 +1030,9 @@ def share # # No `make install` available? # - #
pkgshare.install "examples"+ # ```ruby + # pkgshare.install "examples" + # ``` # # @api public sig { returns(Pathname) } @@ -1032,7 +1047,9 @@ def pkgshare # # To install an Emacs mode included with a software package: # - #
elisp.install "contrib/emacs/example-mode.el"+ # ```ruby + # elisp.install "contrib/emacs/example-mode.el" + # ``` # # @api public sig { returns(Pathname) } @@ -1187,7 +1204,8 @@ def with_logging(log_type) # # ### Example # - #
def plist; <<~EOS + # ```ruby + # def plist; <<~EOS # # #+ # end + # ``` # # @see https://www.unix.com/man-page/all/5/plist/@@ -1210,7 +1228,8 @@ def with_logging(log_type) # # # EOS - # end
plist(5)
man page
def plist
@@ -1263,7 +1282,9 @@ def service
#
# ### Example
#
- # args << "--with-readline=#{Formula["readline"].opt_prefix}" if build.with? "readline"+ # ```ruby + # args << "--with-readline=#{Formula["readline"].opt_prefix}" if build.with? "readline" + # ``` # # @api public sig { returns(Pathname) } @@ -1412,14 +1433,16 @@ def run_post_install # # ### Example # - #
def caveats + # ```ruby + # def caveats # <<~EOS # Are optional. Something the user must be warned about? # EOS - # end- # + # end + # ``` # - #
def caveats + # ```ruby + # def caveats # s = <<~EOS # Print some important notice to the user when `brew info [formula]` is # called or when brewing a formula. @@ -1427,7 +1450,8 @@ def run_post_install # EOS # s += "Some issue only on older systems" if MacOS.version < :el_capitan # s - # end+ # end + # ``` sig { overridable.returns(T.nilable(String)) } def caveats nil @@ -1853,11 +1877,12 @@ def std_pip_args(prefix: self.prefix, build_isolation: false) # # ### Example # - #
shared_library("foo") #=> foo.dylib + # ```ruby + # shared_library("foo") #=> foo.dylib # shared_library("foo", 1) #=> foo.1.dylib # shared_library("foo", "*") #=> foo.2.dylib, foo.1.dylib, foo.dylib # shared_library("*") #=> foo.dylib, bar.dylib - #+ # ``` sig { params(name: String, version: T.nilable(T.any(String, Integer))).returns(String) } def shared_library(name, version = nil) return "*.dylib" if name == "*" && (version.blank? || version == "*") @@ -1877,10 +1902,11 @@ def shared_library(name, version = nil) # # ### Example # - #
rpath #=> "@loader_path/../lib" + # ```ruby + # rpath #=> "@loader_path/../lib" # rpath(target: frameworks) #=> "@loader_path/../Frameworks" # rpath(source: libexec/"bin") #=> "@loader_path/../../lib" - #+ # ``` sig { params(source: Pathname, target: Pathname).returns(String) } def rpath(source: bin, target: lib) unless target.to_s.start_with?(HOMEBREW_PREFIX) @@ -2772,10 +2798,12 @@ def test_fixtures(file) # # ### Example # - #
def install + # ```ruby + # def install # system "./configure", "--prefix=#{prefix}" # system "make", "install" - # end+ # end + # ``` def install; end # Sometimes we have to change a bit before we install. Mostly we @@ -2785,18 +2813,21 @@ def install; end # defined by the formula, as only `HOMEBREW_PREFIX` is available # in the {DATAPatch embedded patch}. # - # ### Example + # ### Examples # # `inreplace` supports regular expressions: # - #
inreplace "somefile.cfg", /look[for]what?/, "replace by #{bin}/tool"+ # ```ruby + # inreplace "somefile.cfg", /look[for]what?/, "replace by #{bin}/tool" + # ``` # # `inreplace` supports blocks: # - #
inreplace "Makefile" do |s| + # ```ruby + # inreplace "Makefile" do |s| # s.gsub! "/usr/local", HOMEBREW_PREFIX.to_s # end - #+ # ``` # # @see Utils::Inreplace.inreplace # @api public @@ -2859,28 +2890,40 @@ def undeclared_runtime_dependencies # # ### Examples # - #
system "./bootstrap.sh", "--arg1", "--prefix=#{prefix}"+ # ```ruby + # system "./bootstrap.sh", "--arg1", "--prefix=#{prefix}" + # ``` # # For CMake and other build systems we have some necessary defaults in e.g. # {#std_cmake_args}: # - #
system "cmake", ".", *std_cmake_args+ # ```ruby + # system "cmake", ".", *std_cmake_args + # ``` # # If the arguments given to `configure` (or `make` or `cmake`) are depending # on options defined above, we usually make a list first and then # use the `args << if
args = ["--with-option1", "--with-option2"] + # ```ruby + # args = ["--with-option1", "--with-option2"] # args << "--without-gcc" if ENV.compiler == :clang + # ``` + # + # Most software still uses `configure` and `make`. + # Check with `./configure --help` for what our options are. # - # # Most software still uses `configure` and `make`. - # # Check with `./configure --help` for what our options are. + # ```ruby # system "./configure", "--disable-debug", "--disable-dependency-tracking", # "--disable-silent-rules", "--prefix=#{prefix}", # *args # our custom arg list (needs `*` to unpack) + # ``` # - # # If there is a "make install" available, please use it! - # system "make", "install"+ # If there is a "make install" available, please use it! + # + # ```ruby + # system "make", "install" + # ``` sig { params(cmd: T.any(String, Pathname), args: T.any(String, Integer, Pathname, Symbol)).void } def system(cmd, *args) verbose_using_dots = Homebrew::EnvConfig.verbose_using_dots? @@ -3486,7 +3529,9 @@ def url(val, specs = {}) # # ### Example # - #
version "1.2-final"+ # ```ruby + # version "1.2-final" + # ``` # # @api public def version(val = nil) @@ -3502,8 +3547,10 @@ def version(val = nil) # # ### Example # - #
mirror "https://in.case.the.host.is.down.example.com" - # mirror "https://in.case.the.mirror.is.down.example.com+ # ```ruby + # mirror "https://in.case.the.host.is.down.example.com" + # mirror "https://in.case.the.mirror.is.down.example.com + # ``` # # @api public def mirror(val) @@ -3519,7 +3566,9 @@ def mirror(val) # # ### Example # - #
sha256 "2a2ba417eebaadcb4418ee7b12fe2998f26d6e6f7fda7983412ff66a741ab6f7"+ # ```ruby + # sha256 "2a2ba417eebaadcb4418ee7b12fe2998f26d6e6f7fda7983412ff66a741ab6f7" + # ``` # # @api public def sha256(val) @@ -3575,13 +3624,15 @@ def build_flags # # ### Example # - #
stable do + # ```ruby + # stable do # url "https://example.com/foo-1.0.tar.gz" # sha256 "2a2ba417eebaadcb4418ee7b12fe2998f26d6e6f7fda7983412ff66a741ab6f7" # # depends_on "libxml2" # depends_on "libffi" - # end+ # end + # ``` # # @api public def stable(&block) @@ -3601,10 +3652,19 @@ def stable(&block) # # ### Example # - #
head "https://we.prefer.https.over.git.example.com/.git"- #
head "https://example.com/.git", branch: "name_of_branch"+ # ```ruby + # head "https://we.prefer.https.over.git.example.com/.git" + # ``` + # + # ```ruby + # head "https://example.com/.git", branch: "name_of_branch" + # ``` + # # or (if autodetect fails): - #
head "https://hg.is.awesome.but.git.has.won.example.com/", using: :hg+ # + # ```ruby + # head "https://hg.is.awesome.but.git.has.won.example.com/", using: :hg + # ``` def head(val = nil, specs = {}, &block) if block @head.instance_eval(&block) @@ -3652,36 +3712,58 @@ def go_resource(name, &block) # # `:build` means this dependency is only needed during build. # - #
depends_on "cmake" => :build+ # ```ruby + # depends_on "cmake" => :build + # ``` # # `:test` means this dependency is only needed during testing. - #
depends_on "node" => :test+ # + # ```ruby + # depends_on "node" => :test + # ``` # # `:recommended` dependencies are built by default. # But a `--without-...` option is generated to opt-out. - #
depends_on "readline" => :recommended+ # + # ```ruby + # depends_on "readline" => :recommended + # ``` # # `:optional` dependencies are NOT built by default unless the # auto-generated `--with-...` option is passed. - #
depends_on "glib" => :optional+ # + # ```ruby + # depends_on "glib" => :optional + # ``` # # If you need to specify that another formula has to be built with/out # certain options (note, no `--` needed before the option): - #
depends_on "zeromq" => "with-pgm" - # depends_on "qt" => ["with-qtdbus", "developer"] # Multiple options.+ # + # ```ruby + # depends_on "zeromq" => "with-pgm" + # depends_on "qt" => ["with-qtdbus", "developer"] # Multiple options. + # ``` # # Optional and enforce that "boost" is built using `--with-c++11`. - #
depends_on "boost" => [:optional, "with-c++11"]+ # + # ```ruby + # depends_on "boost" => [:optional, "with-c++11"] + # ``` # # If a dependency is only needed in certain cases: - #
depends_on "sqlite" if MacOS.version >= :catalina + # + # ```ruby + # depends_on "sqlite" if MacOS.version >= :catalina # depends_on xcode: :build # If the formula really needs full Xcode to compile. # depends_on macos: :mojave # Needs at least macOS Mojave (10.14) to run. - #+ # ``` # # It is possible to only depend on something if # `build.with?` or `build.without? "another_formula"`: - #
depends_on "postgresql" if build.without? "sqlite"+ # + # ```ruby + # depends_on "postgresql" if build.without? "sqlite" + # ``` # # @api public def depends_on(dep) @@ -3718,9 +3800,17 @@ def uses_from_macos(dep, bounds = {}) # # ### Examples # - #
option "with-spam", "The description goes here without a dot at the end"- #
option "with-qt", "Text here overwrites what's autogenerated by 'depends_on "qt" => :optional'"- #
option :universal+ # ```ruby + # option "with-spam", "The description goes here without a dot at the end" + # ``` + # + # ```ruby + # option "with-qt", "Text here overwrites what's autogenerated by 'depends_on "qt" => :optional'" + # ``` + # + # ```ruby + # option :universal + # ``` # # @api public def option(name, description = "") @@ -3734,7 +3824,9 @@ def option(name, description = "") # # ### Example # - #
deprecated_option "enable-debug" => "with-debug"+ # ```ruby + # deprecated_option "enable-debug" => "with-debug" + # ``` # # @api public def deprecated_option(hash) @@ -3745,35 +3837,49 @@ def deprecated_option(hash) # # ### Examples # - #
patch do + # ```ruby + # patch do # url "https://example.com/example_patch.diff" # sha256 "c6bc3f48ce8e797854c4b865f6a8ff969867bbcaebd648ae6fd825683e59fef2" - # end+ # end + # ``` # # A strip level of `-p1` is assumed. It can be overridden using a symbol # argument: - #
patch :p0 do + # + # ```ruby + # patch :p0 do # url "https://example.com/example_patch.diff" # sha256 "c6bc3f48ce8e797854c4b865f6a8ff969867bbcaebd648ae6fd825683e59fef2" - # end+ # end + # ``` # # Patches can be declared in stable and head blocks. This form is # preferred over using conditionals. - #
stable do + # + # ```ruby + # stable do # patch do # url "https://example.com/example_patch.diff" # sha256 "c6bc3f48ce8e797854c4b865f6a8ff969867bbcaebd648ae6fd825683e59fef2" # end - # end+ # end + # ``` # # Embedded (`__END__`) patches are declared like so: - #
patch :DATA - # patch :p0, :DATA+ # + # ```ruby + # patch :DATA + # patch :p0, :DATA + # ``` # # Patches can also be embedded by passing a string. This makes it possible # to provide multiple embedded patches while making only some of them # conditional. - #
patch :p0, "..."+ # + # ```ruby + # patch :p0, "..." + # ``` # # @see https://docs.brew.sh/Formula-Cookbook#patches Patches # @api public @@ -3785,7 +3891,9 @@ def patch(strip = :p1, src = nil, &block) # # ### Example # - #
conflicts_with "imagemagick", because: "both install `convert` binaries"+ # ```ruby + # conflicts_with "imagemagick", because: "both install `convert` binaries" + # ``` # # @api public def conflicts_with(*names) @@ -3858,10 +3966,13 @@ def cxxstdlib_check(check_type) # ### Examples # # For Apple compilers, this should be in the format: - #
fails_with :clang do + # + # ```ruby + # fails_with :clang do # build 600 # cause "multiple configure and compile errors" - # end+ # end + # ``` # # The block may be omitted and if present, the build may be omitted; # if so, then the compiler will not be allowed for *all* versions. @@ -3874,9 +3985,11 @@ def cxxstdlib_check(check_type) # For example, if a bug is only triggered on GCC 7.1 but is not # encountered on 7.2: # - #
fails_with :gcc => '7' do + # ```ruby + # fails_with :gcc => '7' do # version '7.1' - # end+ # end + # ``` # # @api public def fails_with(compiler, &block) @@ -3910,19 +4023,23 @@ def needs(*standards) # # ### Examples # - #
(testpath/"test.file").write <<~EOS + # ```ruby + # (testpath/"test.file").write <<~EOS # writing some test file, if you need to # EOS - # assert_equal "OK", shell_output("test_command test.file").strip+ # assert_equal "OK", shell_output("test_command test.file").strip + # ``` # # Need complete control over stdin, stdout? # - #
require "open3" + # ```ruby + # require "open3" # Open3.popen3("#{bin}/example", "argument") do |stdin, stdout, _| # stdin.write("some text") # stdin.close # assert_equal "result", stdout.read - # end+ # end + # ``` # # The test will fail if it returns false, or if an exception is raised. # Failed assertions and failed `system` commands will raise exceptions. @@ -4047,8 +4164,13 @@ def pour_bottle?(only_if: nil, &block) # # ### Examples # - #
deprecate! date: "2020-08-27", because: :unmaintained- #
deprecate! date: "2020-08-27", because: "has been replaced by foo"+ # ```ruby + # deprecate! date: "2020-08-27", because: :unmaintained + # ``` + # + # ```ruby + # deprecate! date: "2020-08-27", because: "has been replaced by foo" + # ``` # # @see https://docs.brew.sh/Deprecating-Disabling-and-Removing-Formulae # @see DeprecateDisable::FORMULA_DEPRECATE_DISABLE_REASONS