You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# extension dependencies required to load the extension to the right
418
418
# use a list for multiple extension dependencies
419
-
PlottingContourExt = "Contour"
419
+
ContourExt = "Contour"
420
420
421
421
[compat]
422
422
Contour = "0.6.2"
@@ -433,9 +433,9 @@ end
433
433
end# module
434
434
```
435
435
436
-
`ext/PlottingContourExt.jl` (can also be in `ext/PlottingContourExt/PlottingContourExt.jl`):
436
+
`ext/ContourExt.jl` (can also be in `ext/ContourExt/ContourExt.jl`):
437
437
```julia
438
-
modulePlottingContourExt# Should be same name as the file (just like a normal package)
438
+
moduleContourExt# Should be same name as the file (just like a normal package)
439
439
440
440
using Plotting, Contour
441
441
@@ -446,8 +446,8 @@ end
446
446
end# module
447
447
```
448
448
449
-
Extensions can have any arbitrary name (here `PlottingContourExt`), but using something similar to the format of
450
-
this example that makes the extended functionality and dependency of the extension clear is likely a good idea.
449
+
Extensions can have arbitrary names (here `ContourExt`), following the format of this example is likely a good idea for extensions with a single dependency.
450
+
In `Pkg` output, extension names are always shown together with their parent package name.
451
451
452
452
!!! compat
453
453
Often you will put the extension dependencies into the `test` target so they are loaded when running e.g. `Pkg.test()`. On earlier Julia versions
@@ -461,8 +461,8 @@ this example that makes the extended functionality and dependency of the extensi
461
461
462
462
### Behavior of extensions
463
463
464
-
A user that depends only on `Plotting` will not pay the cost of the "extension" inside the `PlottingContourExt` module.
465
-
It is only when the `Contour` package actually gets loaded that the `PlottingContourExt` extension is loaded too
464
+
A user that depends only on `Plotting` will not pay the cost of the "extension" inside the `ContourExt` module.
465
+
It is only when the `Contour` package actually gets loaded that the `ContourExt` extension is loaded too
466
466
and provides the new functionality.
467
467
468
468
In our example, the new functionality is an additional _method_, which we add to an existing _function_ from the parent package `Plotting`.
@@ -474,17 +474,17 @@ function plot end
474
474
```
475
475
476
476
!!! note
477
-
If one considers `PlottingContourExt` as a completely separate package, it could be argued that defining `Plotting.plot(c::Contour.ContourCollection)` is
478
-
[type piracy](https://docs.julialang.org/en/v1/manual/style-guide/#Avoid-type-piracy) since `PlottingContourExt`_owns_ neither the function `Plotting.plot` nor the type `Contour.ContourCollection`.
477
+
If one considers `ContourExt` as a completely separate package, it could be argued that defining `Plotting.plot(c::Contour.ContourCollection)` is
478
+
[type piracy](https://docs.julialang.org/en/v1/manual/style-guide/#Avoid-type-piracy) since `ContourExt`_owns_ neither the function `Plotting.plot` nor the type `Contour.ContourCollection`.
479
479
However, for extensions, it is ok to assume that the extension owns the functions in its parent package.
480
480
481
481
In other situations, one may need to define new symbols in the extension (types, structs, functions, etc.) instead of reusing those from the parent package.
482
-
Such symbols are created in a separate module corresponding to the extension, namely `PlottingContourExt`, and thus not in `Plotting` itself.
482
+
Such symbols are created in a separate module corresponding to the extension, namely `ContourExt`, and thus not in `Plotting` itself.
483
483
If extension symbols are needed in the parent package, one must call `Base.get_extension` to retrieve them.
484
-
Here is an example showing how a custom type defined in `PlottingContourExt` can be accessed in `Plotting`:
484
+
Here is an example showing how a custom type defined in `ContourExt` can be accessed in `Plotting`:
0 commit comments