PkgTemplates.interactive
— Functioninteractive(T::Type{<:Plugin}) -> T
Interactively create a plugin of type T
. Implement this method and ignore other related functions only if you want completely custom behaviour.
diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index ebf8d1f0..edebe051 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.11.3","generation_timestamp":"2025-01-24T02:24:50","documenter_version":"1.8.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.11.3","generation_timestamp":"2025-01-25T02:20:44","documenter_version":"1.8.0"}} \ No newline at end of file diff --git a/dev/developer/index.html b/dev/developer/index.html index ca114488..550088c7 100644 --- a/dev/developer/index.html +++ b/dev/developer/index.html @@ -133,4 +133,4 @@ # Do some other work. add_test_dependency() end
There is also a default validate
implementation for FilePlugin
s, which checks that the plugin's source
file exists, and throws an ArgumentError
otherwise. If you want to extend the validation but keep the file existence check, use the invoke
method as described above.
For more examples, see the plugins in the Continuous Integration (CI) and Code Coverage sections.
When it comes to supporting interactive mode for your custom plugins, you have two options: write your own interactive
method, or use the default one. If you choose the first option, then you are free to implement the method however you want. If you want to use the default implementation, then there are a few functions that you should be aware of, although in many cases you will not need to add any new methods.
PkgTemplates.interactive
— Functioninteractive(T::Type{<:Plugin}) -> T
Interactively create a plugin of type T
. Implement this method and ignore other related functions only if you want completely custom behaviour.
PkgTemplates.prompt
— Functionprompt(::Type{P}, ::Type{T}, ::Val{name::Symbol}) -> Any
Prompts for an input of type T
for field name
of plugin type P
. Implement this method to customize particular fields of particular types.
PkgTemplates.customizable
— Functioncustomizable(::Type{<:Plugin}) -> Vector{Pair{Symbol, DataType}}
Return a list of keyword arguments that the given plugin type accepts, which are not fields of the type, and should be customizable in interactive mode. For example, for a constructor Foo(; x::Bool)
, provide [x => Bool]
. If T
has fields which should not be customizable, use NotCustomizable
as the type.
PkgTemplates.input_tips
— Functioninput_tips(::Type{T}) -> Vector{String}
Provide some extra tips to users on how to structure their input for the type T
, for example if multiple delimited values are expected.
PkgTemplates.convert_input
— Functionconvert_input(::Type{P}, ::Type{T}, s::AbstractString) -> T
Convert the user input s
into an instance of T
for plugin of type P
. A default implementation of T(s)
exists.
For an overview of writing template files for Mustache.jl, see Custom Template Files in the user guide.
There are a few predicate functions for plugins that are occasionally used to answer questions like "does this Template
have any code coverage plugins?". If you're implementing a plugin that fits into one of the following categories, it would be wise to implement the corresponding predicate function to return true
for instances of your type.
PkgTemplates.needs_username
— Functionneeds_username(::Plugin) -> Bool
Determine whether or not a plugin needs a Git hosting service username to function correctly. If you are implementing a plugin that uses the user
field of a Template
, you should implement this function and return true
.
PkgTemplates.is_ci
— Functionis_ci(::Plugin) -> Bool
Determine whether or not a plugin is a CI plugin. If you are adding a CI plugin, you should implement this function and return true
.
PkgTemplates.is_coverage
— Functionis_coverage(::Plugin) -> Bool
Determine whether or not a plugin is a coverage plugin. If you are adding a coverage plugin, you should implement this function and return true
.
When writing configuration files for CI services, working with version numbers is often needed. There are a few convenience functions that can be used to make this a little bit easier.
PkgTemplates.compat_version
— Functioncompat_version(v::VersionNumber) -> String
Format a VersionNumber
to exclude trailing zero components.
PkgTemplates.format_version
— Functionformat_version(v::Union{VersionNumber, AbstractString}) -> String
Strip everything but the major and minor release from a VersionNumber
. Strings are left in their original form.
PkgTemplates.collect_versions
— Functioncollect_versions(t::Template, versions::Vector) -> Vector{String}
Combine t
's Julia version with versions
, and format them as major.minor
. This is useful for creating lists of versions to be included in CI configurations.
If you write a cool new plugin that could be useful to other people, or find and fix a bug, you're encouraged to open a pull request with your changes. Here are some testing tips to ensure that your PR goes through as smoothly as possible.
If you've added or modified plugins, you should update the reference tests and the associated test fixtures. In test/reference.jl
, you'll find a "Reference tests" test set that basically generates a bunch of packages, and then checks each file against a reference file, which is stored somewhere in test/fixtures
. Note the reference tests only run on one specific version of Julia; check test/runtests.jl
to see the current version used.
For new plugins, you should add an instance of your plugin to the "All plugins" and "Wacky options" test sets, then run the tests with Pkg.test
. They should pass, and there will be new files in test/fixtures
. Check them to make sure that they contain exactly what you would expect!
For changes to existing plugins, update the plugin options appropriately in the "Wacky options" test set. Failing tests will give you the option to review and accept changes to the fixtures, updating the files automatically for you.
In the file test/runtests.jl
, there is a variable called REFERENCE_JULIA_VERSION
, currently set to v"1.7.2"
. If you use any other Julia version (even the latest stable one) to launch the test suite, the reference tests mentioned above will not run, and you will miss a crucial correctness check for your code. Therefore, we strongly suggest you test PkgTemplates locally against Julia 1.7.2. This version can be easily installed and started with juliaup:
juliaup add 1.7.2
-julia +1.7.2
Depending on what you've changed, the tests in test/show.jl
might fail. To fix those, you'll need to update the expected
value to match what is actually displayed in a Julia REPL (assuming that the new value is correct).
Settings
This document was generated with Documenter.jl version 1.8.0 on Friday 24 January 2025. Using Julia version 1.11.3.