diff --git a/docs/Cask-Cookbook.md b/docs/Cask-Cookbook.md index 6b9d230528..48660d7bbd 100644 --- a/docs/Cask-Cookbook.md +++ b/docs/Cask-Cookbook.md @@ -29,13 +29,7 @@ Exception: `do` blocks such as `postflight` may enclose a block of pure Ruby cod ## Header line details -The first non-comment line in a cask follows the form: - -```ruby -cask "" do -``` - -[``](#token-reference) should match the cask filename, without the `.rb` extension, enclosed in double quotes. +The Cask name ([``](#token-reference)) on the header line `cask do` should match the cask filename, without the `.rb` extension, enclosed in double quotes. There are currently some arbitrary limitations on cask tokens which are in the process of being removed. GitHub Actions will catch any errors during the transition. @@ -1197,6 +1191,7 @@ cask "libreoffice" do url "https://download.documentfoundation.org/libreoffice/stable/#{version}/mac/#{folder}/LibreOffice_#{version}_MacOS_#{arch}.dmg", verified: "download.documentfoundation.org/libreoffice/stable/" +end ``` If the version number is different for each architecture, locate the unique `version` and (if checked) `sha256` stanzas within `on_arm` and `on_intel` blocks. Example (from [inkscape.rb](https://github.com/Homebrew/homebrew-cask/blob/11f6966bf17628b98895d64a61a4fb0bc1bb31bf/Casks/i/inkscape.rb#L1-L13)): @@ -1215,6 +1210,7 @@ cask "inkscape" do end url "https://inkscape.org/gallery/item/#{version.csv.second}/Inkscape-#{version.csv.first}_#{arch}.dmg" +end ``` To adjust the installed version depending on the current macOS release, use a series of `on_` blocks that cover the range of supported releases. Each block can contain stanzas that set which version to download and customize installation/uninstallation and livecheck behaviour for one or more releases. Example (from [calibre.rb](https://github.com/Homebrew/homebrew-cask/blob/482c34e950da8d649705f4aaea7b760dcb4b5402/Casks/c/calibre.rb#L1-L34)): @@ -1244,6 +1240,7 @@ cask "calibre" do strategy :github_latest end end +end ``` Such `on_` blocks can be nested and contain other stanzas not listed here. Examples: [calhash.rb](https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/c/calhash.rb), [openzfs.rb](https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/o/openzfs.rb), [r.rb](https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/r/r.rb), [wireshark.rb](https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/w/wireshark.rb) @@ -1260,7 +1257,7 @@ In the exceptional case that the cask DSL is insufficient, it is possible to def cask "myapp" do module Utils def self.arbitrary_method - ... + # ... end end @@ -1270,7 +1267,7 @@ cask "myapp" do url "https://#{Utils.arbitrary_method}" homepage "https://www.example.com/" - ... + # ... end ``` diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md index 1e33b009cb..90cdecdf3c 100644 --- a/docs/Formula-Cookbook.md +++ b/docs/Formula-Cookbook.md @@ -546,7 +546,7 @@ end ```ruby stable do - # some other things... + # ... patch do url "https://example.com/example_patch.diff" @@ -700,6 +700,7 @@ class Nginx < Formula url "https://nginx.org/download/nginx-1.23.2.tar.gz", using: :homebrew_curl sha256 "a80cc272d3d72aaee70aa8b517b4862a635c0256790434dbfc4d618a999b0b46" head "https://hg.nginx.org/nginx/", using: :hg +end ``` Homebrew offers these anonymous download strategies. @@ -890,13 +891,14 @@ If you want to add an [`option`](https://rubydoc.brew.sh/Formula#option-class_me ```ruby class Yourformula < Formula - ... + # ... option "with-ham", "Description of the option" option "without-spam", "Another description" depends_on "foo" => :optional # automatically adds a with-foo option depends_on "bar" => :recommended # automatically adds a without-bar option - ... + # ... +end ``` And then to define the effects the [`option`](https://rubydoc.brew.sh/Formula#option-class_method)s have: