Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added doc on Makie package extension #3646

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions docs/explanations/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,57 @@ GLMakie.activate!() # hide
```

\video{stockchart_animation}

## Makie Package Extension

For a simple example of a package extension for Makie,
see <https://github.com/jkrumbiegel/MakiePkgExtTest>.
The following documentation explains the basics of the implementation
in the linked example.

Set up your [package extension](https://pkgdocs.julialang.org/v1/creating-packages/#Conditional-loading-of-code-in-packages-(Extensions))
to have `Makie` as a dependency, not `MakieCore` or any of the Makie backends.

You'll have to define and export your full recipe functions in your main package,
for example:

```julia
module SomePackage

export someplot
export someplot!

# functions with no methods
function someplot end
function someplot! end

end # module
```

and then your Makie extension package will add methods to `someplot!`.

```julia
module MakieExtension

using SomePackage
import SomePackage: someplot, someplot!

Makie.convert_single_argument(v::SomeVector) = v.v

@recipe(SomePlot) do scene
Theme()
end

function Makie.plot!(p::SomePlot)
lines!(p, p[1])
scatter!(p, p[1])
return p
end

end # module
```

See the linked example above for more functionalities
such as accommodating for both extensions and `Requires.jl`,
or providing error hints for plotting functions that don't yet have methods,
or setting up your `Project.toml`.
Loading