language: add detected_<language>_shebang to public API#21984
language: add detected_<language>_shebang to public API#21984
detected_<language>_shebang to public API#21984Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates Homebrew’s Language::*::Shebang helpers so that the detected_<language>_shebang methods are marked as public API in generated YARD documentation (for use by external formulae like those in Homebrew/core).
Changes:
- Mark
detected_python_shebangas@api publicinLanguage::Python::Shebang. - Mark
detected_php_shebangas@api publicinLanguage::PHP::Shebang. - Mark
detected_perl_shebangas@api publicinLanguage::Perl::Shebang.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Library/Homebrew/language/python.rb | Adds # @api public to document detected_python_shebang as public API. |
| Library/Homebrew/language/php.rb | Adds # @api public to document detected_php_shebang as public API. |
| Library/Homebrew/language/perl.rb | Adds # @api public to document detected_perl_shebang as public API. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Should this be @api internal or is it already used widely outside the Homebrew organisation?
| ) | ||
| end | ||
|
|
||
| # @api public |
There was a problem hiding this comment.
If this should be public API, should it also have a documenting comment? Something like:
| # @api public | |
| # Returns a {Utils::Shebang::RewriteInfo} object that contains necessary information for | |
| # rewriting a Python shebang to use the formula's Python dependency, or the `python3` | |
| # executable from `PATH` if `use_python_from_path` is `true`. | |
| # | |
| # To be used with {Utils::Shebang.rewrite_shebang}. | |
| # | |
| # @api public |
Same for the other methods.
For formulae usage, we've usually erred on Python methods are going to be the most commonly used externally. It's used in places like
We aren't likely to remove these, but in case we do then want to provide an |
Cool, public seems fine then (provided there's docs).
We should definitely not do that. Public APIs are a massive pain for us to deprecate. We should default to |
For Homebrew/core, the problem is how easy it propagates outside of Homebrew org once we use it in a formula. Personally would want to audit formulae so they can never use In rare cases, where we have no choice, would be nice to make |
Most formulae are not being
This defeats the point of having an internal API, no? |
Pre-repo merge, I would have considered internal API stuff we used in test-bot, bundle, extra commands, etc. Now is a bit more vague as most code is within Homebrew/brew. At least would cover "cmds" included in Homebrew/core and Homebrew/cask. Worth discussing what extent each scope should now cover. Cask is a bit simpler as we have DSL layer so that should be public API. Flight blocks are the only problem as they can run arbitrary Ruby. I would consider stuff like Formulae is trickier as we are directly using Ruby subclass so very easy to bleed |
Those are indeed supposed to be public - they're listed in the cookbook. It's probaly worth doing a pass through the annotations as a bunch of them don't seem to be accurate. The cookbook is probably a good start for a list of things that are definitely public. Realistically very few people read rubydoc.brew.sh but many do read the cookbook as well as Homebrew/core formulae for examples (as the cookbook recommends in places - including as far as recommending |
|
Might be good to at some point have a |
|
brew lgtm(style, typechecking and tests) with your changes locally?These are used in Homebrew/core formulae, particularly Python method. Perl has a couple. PHP was added specifically to use in formulae.
I had thought these were transitively public API via module, e.g.
brew/Library/Homebrew/language/perl.rb
Lines 7 to 8 in 3aae2a3
However, YARD output shows it as private