Update documentation
This commit is contained in:
parent
d203ee39cd
commit
254b5e7e2f
@ -9,7 +9,7 @@ makedocs(
|
||||
"Plugins" => "pages/plugins.md",
|
||||
"Plugin Development" => "pages/plugin_development.md",
|
||||
"Licenses" => "pages/licenses.md",
|
||||
"Index" => "pages/index.md"
|
||||
"Index" => "pages/index.md",
|
||||
],
|
||||
repo="https://github.com/christopher-dG/PkgTemplates.jl/blob/{commit}{path}#L{line}",
|
||||
sitename="PkgTemplates.jl",
|
||||
|
@ -44,8 +44,8 @@ MyPkg.jl
|
||||
/home/degraafc/.julia/v0.6/MyPkg/test:
|
||||
runtests.jl
|
||||
```
|
||||
However, we can also configure a number of keyword arguments to `Template` and
|
||||
`generate`:
|
||||
However, we can also configure a number of keyword arguments to [`Template`](@ref) and
|
||||
[`generate`](@ref):
|
||||
|
||||
```julia-repl
|
||||
julia> t = Template(;
|
||||
|
@ -8,8 +8,16 @@ CurrentModule = PkgTemplates
|
||||
are available for use with `PkgTemplates`, but if you see that one is missing,
|
||||
don't hesitate to open an issue or PR.
|
||||
|
||||
## show_license
|
||||
## `show_license`
|
||||
|
||||
```@docs
|
||||
show_license
|
||||
```
|
||||
|
||||
## Helper Functions
|
||||
|
||||
#### `read_license`
|
||||
|
||||
````@docs
|
||||
read_license
|
||||
```
|
||||
|
@ -7,14 +7,51 @@ CurrentModule = PkgTemplates
|
||||
Creating new packages with `PkgTemplates` revolves around creating a new
|
||||
[`Template`](@ref), then calling [`generate`](@ref) on it.
|
||||
|
||||
## Template
|
||||
## `Template`
|
||||
|
||||
```@docs
|
||||
Template
|
||||
```
|
||||
|
||||
## generate
|
||||
## `generate`
|
||||
|
||||
```@docs
|
||||
generate
|
||||
```
|
||||
|
||||
## Helper Functions
|
||||
|
||||
#### `gen_entrypoint`
|
||||
|
||||
```@docs
|
||||
gen_entrypoint
|
||||
```
|
||||
|
||||
#### `gen_tests`
|
||||
|
||||
```@docs
|
||||
gen_tests
|
||||
```
|
||||
|
||||
#### `gen_require`
|
||||
|
||||
```@docs
|
||||
gen_require
|
||||
```
|
||||
|
||||
#### `gen_readme`
|
||||
|
||||
```@docs
|
||||
gen_readme
|
||||
```
|
||||
|
||||
#### gen_gitignore
|
||||
|
||||
```@docs
|
||||
gen_gitignore
|
||||
```
|
||||
|
||||
#### gen_license
|
||||
```@docs
|
||||
gen_license
|
||||
```
|
||||
|
@ -21,7 +21,7 @@ GenericPlugin
|
||||
CustomPlugin
|
||||
```
|
||||
|
||||
### CustomPlugin required methods
|
||||
### `CustomPlugin` required methods
|
||||
|
||||
#### `gen_plugin`
|
||||
|
||||
@ -35,27 +35,33 @@ gen_plugin
|
||||
badges
|
||||
```
|
||||
|
||||
## Helper Functions
|
||||
## Helper Types/Functions
|
||||
|
||||
#### gen_file
|
||||
#### `gen_file`
|
||||
|
||||
```@docs
|
||||
gen_file
|
||||
```
|
||||
|
||||
#### substitute
|
||||
#### `substitute`
|
||||
|
||||
```@docs
|
||||
substitute
|
||||
```
|
||||
|
||||
#### badge
|
||||
#### `Badge`
|
||||
|
||||
```@docs
|
||||
badge
|
||||
Badge
|
||||
```
|
||||
|
||||
#### version_floor
|
||||
#### `format`
|
||||
|
||||
```@docs
|
||||
format
|
||||
```
|
||||
|
||||
#### `version_floor`
|
||||
|
||||
```@docs
|
||||
version_floor
|
||||
|
@ -8,37 +8,37 @@ Plugins are the driver for `PkgTemplates`'s customization and extension. This pa
|
||||
describes plugins that already exist; for information on writing your own plugins, see the
|
||||
[plugin development guide](https://invenia.github.io/PkgTemplates.jl/stable/pages/plugin_development.html).
|
||||
|
||||
## TravisCI
|
||||
## `TravisCI`
|
||||
|
||||
```@docs
|
||||
TravisCI
|
||||
```
|
||||
|
||||
## AppVeyor
|
||||
## `AppVeyor`
|
||||
|
||||
```@docs
|
||||
AppVeyor
|
||||
```
|
||||
|
||||
## CodeCov
|
||||
## `CodeCov`
|
||||
|
||||
```@docs
|
||||
CodeCov
|
||||
```
|
||||
|
||||
## Coveralls
|
||||
## `Coveralls`
|
||||
|
||||
```@docs
|
||||
Coveralls
|
||||
```
|
||||
|
||||
## Documenter
|
||||
## `Documenter`
|
||||
|
||||
```@docs
|
||||
Documenter
|
||||
```
|
||||
|
||||
## GitHubPages
|
||||
## `GitHubPages`
|
||||
|
||||
```@docs
|
||||
GitHubPages
|
||||
|
150
src/generate.jl
150
src/generate.jl
@ -9,7 +9,7 @@
|
||||
Generate a package from a template.
|
||||
|
||||
# Arguments
|
||||
* `pkg_name::AbstractString`: Name of the package.
|
||||
* `pkg_name::AbstractString`: Name of the package (with or without trailing ".jl").
|
||||
* `t::Template`: The template from which to generate the package.
|
||||
|
||||
# Keyword Arguments
|
||||
@ -83,6 +83,72 @@ function generate(
|
||||
end
|
||||
end
|
||||
|
||||
"""
|
||||
gen_entrypoint(pkg_name::AbstractString, template::Template) -> Vector{String}
|
||||
|
||||
Create the module entrypoint in the temp package directory.
|
||||
|
||||
# Arguments
|
||||
* `pkg_name::AbstractString`: Name of the package.
|
||||
* `template::Template`: The template whose entrypoint we are generating.
|
||||
|
||||
Returns an array of generated file/directory names.
|
||||
"""
|
||||
function gen_entrypoint(pkg_name::AbstractString, template::Template)
|
||||
text = """
|
||||
module $pkg_name
|
||||
|
||||
# Package code goes here.
|
||||
|
||||
end
|
||||
"""
|
||||
|
||||
gen_file(joinpath(template.temp_dir, pkg_name, "src", "$pkg_name.jl"), text)
|
||||
return ["src/"]
|
||||
end
|
||||
|
||||
"""
|
||||
gen_tests(pkg_name::AbstractString, template::Template) -> Vector{String}
|
||||
|
||||
Create the test directory and entrypoint in the temp package directory.
|
||||
|
||||
# Arguments
|
||||
* `pkg_name::AbstractString`: Name of the package.
|
||||
* `template::Template`: The template whose tests we are generating.
|
||||
|
||||
Returns an array of generated file/directory names.
|
||||
"""
|
||||
function gen_tests(pkg_name::AbstractString, template::Template)
|
||||
text = """
|
||||
using $pkg_name
|
||||
using Base.Test
|
||||
|
||||
# Write your own tests here.
|
||||
@test 1 == 2
|
||||
"""
|
||||
|
||||
gen_file(joinpath(template.temp_dir, pkg_name, "test", "runtests.jl"), text)
|
||||
return ["test/"]
|
||||
end
|
||||
|
||||
"""
|
||||
gen_require(pkg_name::AbstractString, template::Template) -> Vector{String}
|
||||
|
||||
Create the `REQUIRE` file in the temp package directory.
|
||||
|
||||
# Arguments
|
||||
* `pkg_name::AbstractString`: Name of the package.
|
||||
* `template::Template`: The template whose REQUIRE we are generating.
|
||||
|
||||
Returns an array of generated file/directory names.
|
||||
"""
|
||||
function gen_require(pkg_name::AbstractString, template::Template)
|
||||
text = "julia $(version_floor(template.julia_version))\n"
|
||||
|
||||
gen_file(joinpath(template.temp_dir, pkg_name, "REQUIRE"), text)
|
||||
return ["REQUIRE"]
|
||||
end
|
||||
|
||||
"""
|
||||
gen_readme(pkg_name::AbstractString, template::Template) -> Vector{String}
|
||||
|
||||
@ -124,7 +190,7 @@ end
|
||||
"""
|
||||
gen_gitignore(pkg_name::AbstractString, template::Template) -> Vector{String}
|
||||
|
||||
Create a .gitignore in the temp package directory.
|
||||
Create a `.gitignore` in the temp package directory.
|
||||
|
||||
# Arguments
|
||||
* `pkg_name::AbstractString`: Name of the package.
|
||||
@ -150,7 +216,7 @@ end
|
||||
"""
|
||||
gen_license(pkg_name::AbstractString, template::Template) -> Vector{String}
|
||||
|
||||
Create a LICENSE in the temp package directory.
|
||||
Create a license in the temp package directory.
|
||||
|
||||
# Arguments
|
||||
* `pkg_name::AbstractString`: Name of the package.
|
||||
@ -170,72 +236,6 @@ function gen_license(pkg_name::AbstractString, template::Template)
|
||||
return ["LICENSE"]
|
||||
end
|
||||
|
||||
"""
|
||||
gen_entrypoint(pkg_name::AbstractString, template::Template) -> Vector{String}
|
||||
|
||||
Create the module entrypoint in the temp package directory.
|
||||
|
||||
# Arguments
|
||||
* `pkg_name::AbstractString`: Name of the package.
|
||||
* `template::Template`: The template whose entrypoint we are generating.
|
||||
|
||||
Returns an array of generated file/directory names.
|
||||
"""
|
||||
function gen_entrypoint(pkg_name::AbstractString, template::Template)
|
||||
text = """
|
||||
module $pkg_name
|
||||
|
||||
# Package code goes here.
|
||||
|
||||
end
|
||||
"""
|
||||
|
||||
gen_file(joinpath(template.temp_dir, pkg_name, "src", "$pkg_name.jl"), text)
|
||||
return ["src/"]
|
||||
end
|
||||
|
||||
"""
|
||||
gen_require(pkg_name::AbstractString, template::Template) -> Vector{String}
|
||||
|
||||
Create the REQUIRE file in the temp package directory.
|
||||
|
||||
# Arguments
|
||||
* `pkg_name::AbstractString`: Name of the package.
|
||||
* `template::Template`: The template whose REQUIRE we are generating.
|
||||
|
||||
Returns an array of generated file/directory names.
|
||||
"""
|
||||
function gen_require(pkg_name::AbstractString, template::Template)
|
||||
text = "julia $(version_floor(template.julia_version))\n"
|
||||
|
||||
gen_file(joinpath(template.temp_dir, pkg_name, "REQUIRE"), text)
|
||||
return ["REQUIRE"]
|
||||
end
|
||||
|
||||
"""
|
||||
gen_tests(pkg_name::AbstractString, template::Template) -> Vector{String}
|
||||
|
||||
Create the test directory and entrypoint in the temp package directory.
|
||||
|
||||
# Arguments
|
||||
* `pkg_name::AbstractString`: Name of the package.
|
||||
* `template::Template`: The template whose tests we are generating.
|
||||
|
||||
Returns an array of generated file/directory names.
|
||||
"""
|
||||
function gen_tests(pkg_name::AbstractString, template::Template)
|
||||
text = """
|
||||
using $pkg_name
|
||||
using Base.Test
|
||||
|
||||
# Write your own tests here.
|
||||
@test 1 == 2
|
||||
"""
|
||||
|
||||
gen_file(joinpath(template.temp_dir, pkg_name, "test", "runtests.jl"), text)
|
||||
return ["test/"]
|
||||
end
|
||||
|
||||
"""
|
||||
gen_file(file_path::AbstractString, text::AbstractString) -> Int
|
||||
|
||||
@ -279,13 +279,7 @@ end
|
||||
"""
|
||||
substitute(template::AbstractString, view::Dict{String, Any}) -> String
|
||||
|
||||
Replace placeholders in a template string. The input string is not modified.
|
||||
|
||||
# Arguments
|
||||
* `template::AbstracString`: Template string in which to make replacements.
|
||||
* `view::Dict{String, Any}`: (Placeholder => value) pairs.
|
||||
|
||||
Returns the template string with replacements applied.
|
||||
Replace placeholders in `template` with values in `view`. `template` is not modified.
|
||||
|
||||
# Notes
|
||||
Due to a bug in `Mustache`, conditionals often insert undesired newlines (more detail
|
||||
@ -321,8 +315,8 @@ substitute(template::AbstractString, view::Dict{String, Any}) = render(template,
|
||||
view::Dict{String, Any}=Dict{String, Any}(),
|
||||
) -> String
|
||||
|
||||
Replace placeholders in template string, using some default replacements based on the
|
||||
package template. The input string is not modified.
|
||||
Replace placeholders in `template`, using some default replacements based on the
|
||||
`pkg_template` and additional ones in `view`. `template` is not modified.
|
||||
"""
|
||||
function substitute(
|
||||
template::AbstractString,
|
||||
|
Loading…
Reference in New Issue
Block a user