Update docs with interactive stuff
This commit is contained in:
parent
aa3e7769ed
commit
441eee3219
@ -76,23 +76,23 @@ To understand how they're implemented, let's look at simplified versions of two
|
|||||||
### Example: `Documenter`
|
### Example: `Documenter`
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
@with_kw_noshow struct Documenter <: Plugin
|
@with_defaults struct Documenter <: Plugin
|
||||||
make_jl::String = default_file("make.jl")
|
make_jl::String = default_file("docs", "make.jl") <- "Path to make.jl template"
|
||||||
index_md::String = default_file("index.md")
|
index_md::String = default_file("docs", "src", "index.md") <- "Path to index.md template"
|
||||||
end
|
end
|
||||||
|
|
||||||
gitignore(::Documenter) = ["/docs/build/", "/docs/site/"]
|
gitignore(::Documenter) = ["/docs/build/"]
|
||||||
|
|
||||||
badges(::Documenter) = [
|
badges(::Documenter) = [
|
||||||
Badge(
|
Badge(
|
||||||
"Stable",
|
"Stable",
|
||||||
"https://img.shields.io/badge/docs-stable-blue.svg",
|
"https://img.shields.io/badge/docs-stable-blue.svg",
|
||||||
"https://{{USER}}.github.io/{{PKG}}.jl/stable",
|
"https://{{{USER}}}.github.io/{{{PKG}}}.jl/stable",
|
||||||
),
|
),
|
||||||
Badge(
|
Badge(
|
||||||
"Dev",
|
"Dev",
|
||||||
"https://img.shields.io/badge/docs-dev-blue.svg",
|
"https://img.shields.io/badge/docs-dev-blue.svg",
|
||||||
"https://{{USER}}.github.io/{{PKG}}.jl/dev",
|
"https://{{{}USER}}.github.io/{{{PKG}}}.jl/dev",
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -118,8 +118,14 @@ function hook(p::Documenter, t::Template, pkg_dir::AbstractString)
|
|||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
First of all, `@with_kw_noshow` comes from [Parameters.jl](https://github.com/mauro3/Parameters.jl), and it just defines a nice keyword constructor for us.
|
The first thing you'll notice is the strange struct definition with [`@with_defaults`](@ref).
|
||||||
The default values for our type are using [`default_file`](@ref) to point to files in this repository.
|
|
||||||
|
```@docs
|
||||||
|
@with_defaults
|
||||||
|
interactive
|
||||||
|
```
|
||||||
|
|
||||||
|
Inside of our struct definition we're using [`default_file`](@ref) to refer to files in this repository.
|
||||||
|
|
||||||
```@docs
|
```@docs
|
||||||
default_file
|
default_file
|
||||||
|
@ -4,15 +4,16 @@ const DEFAULT_PRIORITY = 1000
|
|||||||
"""
|
"""
|
||||||
@with_defaults struct T #= ... =# end
|
@with_defaults struct T #= ... =# end
|
||||||
|
|
||||||
Wraps Parameters.jl's [`@with_kw_noshow`](https://mauro3.github.io/Parameters.jl/stable/api/#Parameters.@with_kw_noshow-Tuple{Any}) to generate keyword constructors,
|
Creates keyword constructors and generates methods needed to interactively create instances with [`interactive`](@ref).
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
```julia
|
```julia
|
||||||
struct Foo <: Plugin
|
struct Foo <: Plugin
|
||||||
file::String = "/dev/null" <- "Path to the file to use"
|
file::String = "/the/default/value" <- "This is the interactive prompt"
|
||||||
n::Int <- "This one has no default, but this is the interactive prompt"
|
n::Int <- "This one has no default, so it's a required keyword"
|
||||||
xyz::String = "Without a prompt, defaultkw is not implemented for this field"
|
abc::String = "No prompt, so the default is always taken in interactive mode"
|
||||||
|
xyz::String # Required keyword, with a generic interactive prompt.
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user