From e5ae67f90627a0769c33ab81f2ad4f557c3aa9b3 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Tue, 23 Jan 2024 23:04:30 +0000 Subject: [PATCH] Fix RuboCop `FormulaAudit/` group offenses for docs code examples --- docs/Cask-Cookbook.md | 2 +- docs/Formula-Cookbook.md | 21 +++++----- docs/Manpage.md | 2 +- docs/Node-for-Formula-Authors.md | 4 +- docs/Python-for-Formula-Authors.md | 64 +++++++++++++++++++++--------- 5 files changed, 61 insertions(+), 32 deletions(-) diff --git a/docs/Cask-Cookbook.md b/docs/Cask-Cookbook.md index 694abf8c7f..d82d4bb4a2 100644 --- a/docs/Cask-Cookbook.md +++ b/docs/Cask-Cookbook.md @@ -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 diff --git a/docs/Formula-Cookbook.md b/docs/Formula-Cookbook.md index ecbe007392..a37defc1bc 100644 --- a/docs/Formula-Cookbook.md +++ b/docs/Formula-Cookbook.md @@ -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 Homebrew’s 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 ``` diff --git a/docs/Manpage.md b/docs/Manpage.md index d4c040ca9a..371787b6e7 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -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`: diff --git a/docs/Node-for-Formula-Authors.md b/docs/Node-for-Formula-Authors.md index 65e9584e22..7f1c4cd9ee 100644 --- a/docs/Node-for-Formula-Authors.md +++ b/docs/Node-for-Formula-Authors.md @@ -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 diff --git a/docs/Python-for-Formula-Authors.md b/docs/Python-for-Formula-Authors.md index d74b5b4502..213cbf0170 100644 --- a/docs/Python-for-Formula-Authors.md +++ b/docs/Python-for-Formula-Authors.md @@ -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 ```