diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f13815..4dd6bdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), *Note*: We try to adhere to these practices as of version [v1.1.0]. +## Version [1.3.0] - 2024-06-27 + +### Added + +- Adds support for `pkg_template` function that can be used to generate a `PkgTemplates.Template` for a Taija package. [#15] ## Version [1.2.3] - 2024-09-09 ### Removed diff --git a/src/TaijaBase.jl b/src/TaijaBase.jl index 7575a2a..a82dc61 100644 --- a/src/TaijaBase.jl +++ b/src/TaijaBase.jl @@ -1,8 +1,9 @@ module TaijaBase -export AbstractParallelizer +export AbstractParallelizer, pkg_template include("parallelization/base.jl") include("deprecated.jl") +include("template/template.jl") end diff --git a/src/parallelization/base.jl b/src/parallelization/base.jl index 3abf56a..6785d4e 100644 --- a/src/parallelization/base.jl +++ b/src/parallelization/base.jl @@ -1,4 +1,4 @@ "An abstract type for parallelizers. This type is owned by the `TaijaBase` module to allow shipping it to packages that depend on `TaijaBase`, without having to depend on the `TaijaParallel` module. See also [`parallelize`](@ref) for a detailed explanation." abstract type AbstractParallelizer end -include("functions.jl") +include("functions.jl") \ No newline at end of file diff --git a/src/template/template.jl b/src/template/template.jl new file mode 100644 index 0000000..8e13a29 --- /dev/null +++ b/src/template/template.jl @@ -0,0 +1,52 @@ +using PkgTemplates: PkgTemplates, @with_kw_noshow, @plugin, Plugin, default_file, Template, pkg_name, render_file, combined_view, tags, gen_file +const TAIJA_TEMPLATE_DIR = Ref{String}(joinpath(dirname(dirname(pathof(TaijaBase))), "templates")) + +""" + pkg_template(; user::String, authors::String, dir::String="~") + +Create a new package template with the following plugins: + +- `BlueStyleBadge` +- `Citation` +- `Codecov` +- `Documenter{GitHubActions}` +- `Develop` +- `Formatter(style="blue")` +- `License` +- `PkgBenchmark` +- `RegisterAction` + +# Arguments + +- `authors::String`: The authors of the package. +- `dir::String`: The directory where the package will be created. Default is `~`. + +# Example + +```julia +pkg_template(authors="Jane Doe", dir="~/Documents") +``` + +""" +function pkg_template(; authors::String, dir::String="~") + @eval begin + using PkgTemplates + Template(; + user="JuliaTrustworthyAI", + dir=$dir, + authors=$authors, + julia=v"1.10", + plugins=[ + BlueStyleBadge(), + Citation(), + Codecov(file=joinpath(TAIJA_TEMPLATE_DIR[], ".codecov.yml")), + Documenter{GitHubActions}(make_jl=Quarto().make_jl), + Formatter(style="blue"), + License(), + Quarto(), + RegisterAction(), + Tests(aqua=true) + ] + ) + end +end \ No newline at end of file diff --git a/templates/.codecov.yml b/templates/.codecov.yml new file mode 100644 index 0000000..64441d9 --- /dev/null +++ b/templates/.codecov.yml @@ -0,0 +1,6 @@ +coverage: + status: + project: + default: + target: 90% # the required coverage value + threshold: 0.5% # the leniency in hitting the target \ No newline at end of file diff --git a/templates/README.qmd b/templates/README.qmd new file mode 100644 index 0000000..63b0118 --- /dev/null +++ b/templates/README.qmd @@ -0,0 +1,25 @@ +--- +format: + commonmark: + variant: -raw_html+tex_math_dollars + wrap: none + mermaid-format: png +crossref: + fig-prefix: Figure + tbl-prefix: Table +output: asis +--- + +# {{{PKG}}}{{#HAS_INLINE_BADGES}} {{#BADGES}}{{{.}}} {{/BADGES}}{{/HAS_INLINE_BADGES}} +{{^HAS_INLINE_BADGES}} + +{{#BADGES}} +{{{.}}} +{{/BADGES}} +{{/HAS_INLINE_BADGES}} +{{#HAS_CITATION}} + +## Citing + +See [`CITATION.bib`](CITATION.bib) for the relevant reference(s). +{{/HAS_CITATION}} \ No newline at end of file diff --git a/templates/_quarto.yml b/templates/_quarto.yml new file mode 100644 index 0000000..da56317 --- /dev/null +++ b/templates/_quarto.yml @@ -0,0 +1,13 @@ +project: + title: "{{{PKG}}}.jl" + execute-dir: project +crossref: + fig-prefix: Figure + tbl-prefix: Table +resource-path: + - docs/src/assets +format: + commonmark: + variant: -raw_html+tex_math_dollars + wrap: preserve + mermaid-format: png \ No newline at end of file diff --git a/templates/index.qmd b/templates/index.qmd new file mode 100644 index 0000000..15f3a87 --- /dev/null +++ b/templates/index.qmd @@ -0,0 +1,14 @@ +```@meta +CurrentModule = {{{PKG}}} +``` + +# {{{PKG}}} + +Documentation for [{{{PKG}}}](https://{{{REPO}}}). + +```@index +``` + +```@autodocs +Modules = [{{{PKG}}}] +``` \ No newline at end of file diff --git a/test/Project.toml b/test/Project.toml index 09bf3c8..37d862a 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -4,4 +4,11 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [compat] Aqua = "0.8" +Distributions = "0.25" +Flux = "0.13, 0.14" +MLDataUtils = "0.5" +MLJBase = "1.5" +Optimisers = "0.3" +Plots = "1.40" +RDatasets = "0.7" julia = "1.6, 1.10" diff --git a/test/template.jl b/test/template.jl new file mode 100644 index 0000000..2a337fd --- /dev/null +++ b/test/template.jl @@ -0,0 +1,9 @@ +using PkgTemplates + +@testset "Template" begin + + dir = tempdir() + t = TaijaBase.pkg_template(authors="Jane Doe", dir=dir) + @test typeof(t) == PkgTemplates.Template + +end \ No newline at end of file