Skip to content

Commit

Permalink
Add Base.get_extension to docs/API (#50860)
Browse files Browse the repository at this point in the history
The documentation of `Pkg.jl` is instructing
developers to rely on the existence of this function, and there doesn't
seem to be any alternative which is a part of the API that developers
can use instead on to guarantee forward compatibility for the same
behavior.

`Base.get_extension` is [referred to
explicitly](https://pkgdocs.julialang.org/v1.9/creating-packages/#Backwards-compatibility)
in the `Pkg.jl` docs to conditionally use package extensions vs
`Requires.jl`.

The `Pkg.jl` docs suggest
```julia
if !isdefined(Base, :get_extension)
  include("../ext/PlottingContourExt.jl")
end
```
to transition from "normal dependency to extension," which will break
and automatically load the extension in future versions should
`Base.get_extension` go away.

`Base.get_extension` is the only way (that I know of) to directly access
the module associated with a package extension, which can be a useful
utility as well.

(cherry picked from commit d1759bc)
  • Loading branch information
SBuercklin authored and KristofferC committed Aug 10, 2023
1 parent 3e133c9 commit 27bc777
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions doc/src/base/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ Base.locate_package
Base.require
Base.compilecache
Base.isprecompiled
Base.get_extension
```

## Internals
Expand Down

0 comments on commit 27bc777

Please sign in to comment.