Update docs example
This commit is contained in:
parent
9c6a160bc2
commit
0fd34f5847
@ -87,7 +87,8 @@ end
|
|||||||
"""
|
"""
|
||||||
Custom plugins are plugins whose behaviour does not follow the [`GenericPlugin`](@ref)
|
Custom plugins are plugins whose behaviour does not follow the [`GenericPlugin`](@ref)
|
||||||
pattern. They can implement [`gen_plugin`](@ref), [`badges`](@ref), and
|
pattern. They can implement [`gen_plugin`](@ref), [`badges`](@ref), and
|
||||||
[`interactive`](@ref) in any way they choose.
|
[`interactive`](@ref) in any way they choose, as long as they conform to the usual type
|
||||||
|
signature.
|
||||||
|
|
||||||
# Attributes
|
# Attributes
|
||||||
* `gitignore::Vector{AbstractString}`: Array of patterns to be added to the `.gitignore` of
|
* `gitignore::Vector{AbstractString}`: Array of patterns to be added to the `.gitignore` of
|
||||||
@ -102,24 +103,19 @@ pattern. They can implement [`gen_plugin`](@ref), [`badges`](@ref), and
|
|||||||
MyPlugin() = new([], rand() > 0.8)
|
MyPlugin() = new([], rand() > 0.8)
|
||||||
|
|
||||||
function gen_plugin(p::MyPlugin, t::Template, pkg_name::AbstractString)
|
function gen_plugin(p::MyPlugin, t::Template, pkg_name::AbstractString)
|
||||||
if plugin.lucky
|
return if p.lucky
|
||||||
text = substitute(
|
text = substitute("You got lucky with {{PKGNAME}}, {{USER}}!", t)
|
||||||
"You got lucky with {{PKGNAME}}, {{USER}}!",
|
gen_file(joinpath(t.dir, pkg_name, ".myplugin.yml"), text)
|
||||||
template,
|
[".myplugin.yml"]
|
||||||
)
|
|
||||||
gen_file(joinpath(dir, pkg_name, ".myplugin.yml"), text)
|
|
||||||
else
|
else
|
||||||
println("Maybe next time.")
|
println("Maybe next time.")
|
||||||
|
String[]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function badges(
|
function badges(p::MyPlugin, user::AbstractString, pkg_name::AbstractString)
|
||||||
plugin::MyPlugin,
|
return if p.lucky
|
||||||
user::AbstractString,
|
[
|
||||||
pkg_name::AbstractString,
|
|
||||||
)
|
|
||||||
if plugin.lucky
|
|
||||||
return [
|
|
||||||
format(Badge(
|
format(Badge(
|
||||||
"You got lucky!",
|
"You got lucky!",
|
||||||
"https://myplugin.com/badge.png",
|
"https://myplugin.com/badge.png",
|
||||||
@ -127,12 +123,12 @@ pattern. They can implement [`gen_plugin`](@ref), [`badges`](@ref), and
|
|||||||
)),
|
)),
|
||||||
]
|
]
|
||||||
else
|
else
|
||||||
return String[]
|
String[]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
interactive(t:Type{MyPlugin}) = MyPlugin()
|
interactive(:Type{MyPlugin}) = MyPlugin()
|
||||||
```
|
```
|
||||||
|
|
||||||
This plugin doesn't do much, but it demonstrates how [`gen_plugin`](@ref), [`badges`](@ref)
|
This plugin doesn't do much, but it demonstrates how [`gen_plugin`](@ref), [`badges`](@ref)
|
||||||
|
Loading…
Reference in New Issue
Block a user