Fix RuboCop FormulaAudit/ group offenses for docs code examples

This commit is contained in:
Issy Long 2024-01-23 23:04:30 +00:00
parent 9b6903f50b
commit e5ae67f906
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4
5 changed files with 61 additions and 32 deletions

View File

@ -1261,11 +1261,11 @@ cask "myapp" do
end
end
name "MyApp"
version "1.0"
sha256 "a32565cdb1673f4071593d4cc9e1c26bc884218b62fef8abc450daa47ba8fa92"
url "https://#{Utils.arbitrary_method}"
name "MyApp"
homepage "https://www.example.com/"
# ...
end

View File

@ -145,14 +145,14 @@ Special exceptions are OpenSSL and LibreSSL. Things that use either *should* be
```ruby
class Foo < Formula
depends_on "pkg-config"
depends_on "jpeg"
depends_on "gtk+" => :optional
depends_on "readline" => :recommended
depends_on "httpd" => [:build, :test]
depends_on arch: :x86_64
depends_on macos: :high_sierra
depends_on xcode: ["9.3", :build]
depends_on arch: :x86_64
depends_on "jpeg"
depends_on macos: :high_sierra
depends_on "pkg-config"
depends_on "readline" => :recommended
depends_on "gtk+" => :optional
end
```
@ -495,7 +495,7 @@ inreplace "path", before, after
```ruby
inreplace "path" do |s|
s.gsub!(/foo/, "bar")
s.gsub!("foo", "bar")
s.gsub! "123", "456"
end
```
@ -686,6 +686,7 @@ When parsing a download URL, Homebrew auto-detects the resource type it points t
```ruby
class Foo < Formula
homepage "https://github.com/some/package"
description "Some package"
url "https://github.com/some/package.git",
tag: "v1.6.2",
revision: "344cd2ee3463abab4c16ac0f9529a846314932a2"
@ -697,6 +698,7 @@ If not inferable, specify which of Homebrews built-in download strategies to
```ruby
class Nginx < Formula
homepage "https://nginx.org/"
description "Some package"
url "https://nginx.org/download/nginx-1.23.2.tar.gz", using: :homebrew_curl
sha256 "a80cc272d3d72aaee70aa8b517b4862a635c0256790434dbfc4d618a999b0b46"
head "https://hg.nginx.org/nginx/", using: :hg
@ -731,6 +733,7 @@ end
class Foo < Formula
url "something", using: MyDownloadStrategy
description "Some package"
end
```
@ -895,8 +898,8 @@ 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
depends_on "bar" => :recommended
depends_on "foo" => :optional # automatically adds a with-foo option # automatically adds a without-bar option
# ...
end
```

View File

@ -1179,7 +1179,7 @@ Display the path to the file being used when invoking `brew` *`cmd`*.
Summarise contributions to Homebrew repositories.
* `--repositories`:
Specify a comma-separated list of repositories to search. Supported repositories: `brew`, `core`, `cask`, `aliases`, `autoupdate`, `bundle`, `command-not-found`, `test-bot`, `services`, `cask-fonts` and `cask-versions`. Omitting this flag, or specifying `--repositories=primary`, searches only the main repositories: brew,core,cask. Specifying `--repositories=all`, searches all repositories.
Specify a comma-separated list of repositories to search. Supported repositories: `brew`, `core`, `cask`, `aliases`, `autoupdate`, `bundle`, `command-not-found`, `test-bot`, `services`, `cask-fonts` and `cask-versions`. Omitting this flag, or specifying `--repositories=primary`, searches only the main repositories: brew,core,cask. Specifying `--repositories=all`, searches all repositories.
* `--from`:
Date (ISO-8601 format) to start searching contributions. Omitting this flag searches the last year.
* `--to`:

View File

@ -91,10 +91,10 @@ Installing a standard Node module based formula would look like this:
require "language/node"
class Foo < Formula
desc "..."
desc "Description"
homepage "..."
url "https://registry.npmjs.org/foo/-/foo-1.4.2.tgz"
sha256 "..."
sha256 "abc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1"
depends_on "node"
# uncomment if there is a native addon inside the dependency tree

View File

@ -50,26 +50,46 @@ Homebrew provides helper methods for instantiating and populating virtualenvs. Y
For most applications, all you will need to write is:
```ruby
def install
virtualenv_install_with_resources
class Foo < Formula
include Language::Python::Virtualenv
name "foo"
desc "Bar"
homepage "https://example.com"
url "..."
sha256 "abc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1"
def install
virtualenv_install_with_resources
end
end
```
This is exactly the same as writing:
```ruby
def install
# Create a virtualenv in `libexec`. If your app needs Python 3, make sure that
# `depends_on "python"` is declared, and use `virtualenv_create(libexec, "python3")`.
venv = virtualenv_create(libexec)
# Install all of the resources declared on the formula into the virtualenv.
venv.pip_install resources
# `pip_install_and_link` takes a look at the virtualenv's bin directory
# before and after installing its argument. New scripts will be symlinked
# into `bin`. `pip_install_and_link buildpath` will install the package
# that the formula points to, because buildpath is the location where the
# formula's tarball was unpacked.
venv.pip_install_and_link buildpath
class Foo < Formula
include Language::Python::Virtualenv
name "foo"
desc "Bar"
homepage "https://example.com"
url "..."
sha256 "abc123"
def install
# Create a virtualenv in `libexec`. If your app needs Python 3, make sure that
# `depends_on "python"` is declared, and use `virtualenv_create(libexec, "python3")`.
venv = virtualenv_create(libexec)
# Install all of the resources declared on the formula into the virtualenv.
venv.pip_install resources
# `pip_install_and_link` takes a look at the virtualenv's bin directory
# before and after installing its argument. New scripts will be symlinked
# into `bin`. `pip_install_and_link buildpath` will install the package
# that the formula points to, because buildpath is the location where the
# formula's tarball was unpacked.
venv.pip_install_and_link buildpath
end
end
```
@ -102,12 +122,18 @@ end
You can also use the more verbose form and request that specific resources be installed:
```ruby
def install
venv = virtualenv_create(libexec)
%w[six parsedatetime].each do |r|
venv.pip_install resource(r)
class Foo < Formula
include Language::Python::Virtualenv
url "..."
def install
venv = virtualenv_create(libexec)
%w[six parsedatetime].each do |r|
venv.pip_install resource(r)
end
venv.pip_install_and_link buildpath
end
venv.pip_install_and_link buildpath
end
```