Update docs with interactive stuff

This commit is contained in:
Chris de Graaf 2019-09-28 11:21:45 +07:00
parent aa3e7769ed
commit 441eee3219
No known key found for this signature in database
GPG Key ID: 150FFDD9B0073C7B
2 changed files with 19 additions and 12 deletions

View File

@ -76,23 +76,23 @@ To understand how they're implemented, let's look at simplified versions of two
### Example: `Documenter`
```julia
@with_kw_noshow struct Documenter <: Plugin
make_jl::String = default_file("make.jl")
index_md::String = default_file("index.md")
@with_defaults struct Documenter <: Plugin
make_jl::String = default_file("docs", "make.jl") <- "Path to make.jl template"
index_md::String = default_file("docs", "src", "index.md") <- "Path to index.md template"
end
gitignore(::Documenter) = ["/docs/build/", "/docs/site/"]
gitignore(::Documenter) = ["/docs/build/"]
badges(::Documenter) = [
Badge(
"Stable",
"https://img.shields.io/badge/docs-stable-blue.svg",
"https://{{USER}}.github.io/{{PKG}}.jl/stable",
"https://{{{USER}}}.github.io/{{{PKG}}}.jl/stable",
),
Badge(
"Dev",
"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
```
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 default values for our type are using [`default_file`](@ref) to point to files in this repository.
The first thing you'll notice is the strange struct definition with [`@with_defaults`](@ref).
```@docs
@with_defaults
interactive
```
Inside of our struct definition we're using [`default_file`](@ref) to refer to files in this repository.
```@docs
default_file

View File

@ -4,15 +4,16 @@ const DEFAULT_PRIORITY = 1000
"""
@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
```julia
struct Foo <: Plugin
file::String = "/dev/null" <- "Path to the file to use"
n::Int <- "This one has no default, but this is the interactive prompt"
xyz::String = "Without a prompt, defaultkw is not implemented for this field"
file::String = "/the/default/value" <- "This is the interactive prompt"
n::Int <- "This one has no default, so it's a required keyword"
abc::String = "No prompt, so the default is always taken in interactive mode"
xyz::String # Required keyword, with a generic interactive prompt.
end
```
"""