diff --git a/.github/workflows/FormatCheck.yml b/.github/workflows/FormatCheck.yml new file mode 100644 index 0000000..bb6d933 --- /dev/null +++ b/.github/workflows/FormatCheck.yml @@ -0,0 +1,35 @@ +name: Format check +on: + push: + branches: [main] + tags: [v*] + pull_request: + +jobs: + format: + name: "Format Check" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 + with: + version: 1 + - name: Install JuliaFormatter and format + run: | + julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))' + julia -e 'using JuliaFormatter; format(".", verbose=true)' + - name: Check format + run: | + julia -e ' + out = Cmd(`git diff --name-only`) |> read |> String + if out == "" + exit(0) + else + @error "The following files have not been formatted:" + write(stdout, out) + out_diff = Cmd(`git diff`) |> read |> String + @error "Diff:" + write(stdout, out_diff) + exit(1) + @error "" + end' diff --git a/.gitignore b/.gitignore index 4fbdec0..b8f9c0c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ Manifest.toml benchmark/*.json docs/build/ +test/LocalPreferences.toml diff --git a/README.md b/README.md deleted file mode 100644 index 78020a7..0000000 --- a/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# ITensorPkgSkeleton.jl - -[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/ITensorPkgSkeleton.jl/stable/) -[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/ITensorPkgSkeleton.jl/dev/) -[![Build Status](https://github.com/ITensor/ITensorPkgSkeleton.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ITensor/ITensorPkgSkeleton.jl/actions/workflows/CI.yml?query=branch%3Amain) -[![Coverage](https://codecov.io/gh/ITensor/ITensorPkgSkeleton.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/ITensorPkgSkeleton.jl) -[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle) -[![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl) - -```julia -using ITensorPkgSkeleton: ITensorPkgSkeleton -# This step might be required to circumvent issues with -# the version of git installed by `Git.jl`. -ITensorPkgSkeleton.use_system_git!() -ITensorPkgSkeleton.generate("NewPkg") -``` diff --git a/README.md b/README.md new file mode 120000 index 0000000..8785db1 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +docs/src/index.md \ No newline at end of file diff --git a/docs/Project.toml b/docs/Project.toml index 40e65f5..07dd32d 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,3 +1,4 @@ [deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" +Git_jll = "f8c6e375-362e-5223-8a59-34ff63f689eb" ITensorPkgSkeleton = "3d388ab1-018a-49f4-ae50-18094d5f71ea" diff --git a/docs/src/index.md b/docs/src/index.md index 1acba50..1438199 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -1,14 +1,56 @@ ```@meta -CurrentModule = ITensorPkgSkeleton +EditURL = "../../examples/README.jl" ``` -# ITensorPkgSkeleton +# ITensorPkgSkeleton.jl -Documentation for [ITensorPkgSkeleton](https://github.com/ITensor/ITensorPkgSkeleton.jl). +[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/ITensorPkgSkeleton.jl/stable/) +[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/ITensorPkgSkeleton.jl/dev/) +[![Build Status](https://github.com/ITensor/ITensorPkgSkeleton.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ITensor/ITensorPkgSkeleton.jl/actions/workflows/CI.yml?query=branch%3Amain) +[![Coverage](https://codecov.io/gh/ITensor/ITensorPkgSkeleton.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/ITensorPkgSkeleton.jl) +[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle) +[![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl) -```@index +## Installation instructions + +```julia +julia> using Pkg: Pkg + +julia> Pkg.add("https://github.com/ITensor/ITensorPkgSkeleton.jl") ``` -```@autodocs -Modules = [ITensorPkgSkeleton] +## Examples + +````@example index +using ITensorPkgSkeleton: ITensorPkgSkeleton +```` + +This step might be required to circumvent issues with +the version of git installed by `Git.jl`. + +````@example index +ITensorPkgSkeleton.use_system_git!() +```` + +If `path` isn't specified, it defaults to `~/.julia/dev`. + +````@example index +ITensorPkgSkeleton.generate("NewPkg"; path=tempdir()) +```` + +You can generate this README with: +```julia +using Literate: Literate +using ITensorPkgSkeleton: ITensorPkgSkeleton +Literate.markdown( + joinpath(pkgdir(ITensorPkgSkeleton), "examples", "README.jl"), + joinpath(pkgdir(ITensorPkgSkeleton), "docs", "src"); + flavor=Literate.DocumenterFlavor(), + name="index", +) ``` + +--- + +*This page was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).* + diff --git a/examples/Project.toml b/examples/Project.toml new file mode 100644 index 0000000..668a5cb --- /dev/null +++ b/examples/Project.toml @@ -0,0 +1,2 @@ +[deps] +ITensorPkgSkeleton = "3d388ab1-018a-49f4-ae50-18094d5f71ea" diff --git a/examples/README.jl b/examples/README.jl new file mode 100644 index 0000000..f801d74 --- /dev/null +++ b/examples/README.jl @@ -0,0 +1,41 @@ +# # ITensorPkgSkeleton.jl +# +# [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/ITensorPkgSkeleton.jl/stable/) +# [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/ITensorPkgSkeleton.jl/dev/) +# [![Build Status](https://github.com/ITensor/ITensorPkgSkeleton.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ITensor/ITensorPkgSkeleton.jl/actions/workflows/CI.yml?query=branch%3Amain) +# [![Coverage](https://codecov.io/gh/ITensor/ITensorPkgSkeleton.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/ITensorPkgSkeleton.jl) +# [![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle) +# [![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl) + +# ## Installation instructions + +#= +```julia +julia> using Pkg: Pkg + +julia> Pkg.add("https://github.com/ITensor/ITensorPkgSkeleton.jl") +``` +=# + +# ## Examples + +using ITensorPkgSkeleton: ITensorPkgSkeleton +# This step might be required to circumvent issues with +# the version of git installed by `Git.jl`. +ITensorPkgSkeleton.use_system_git!() +# If `path` isn't specified, it defaults to `~/.julia/dev`. +ITensorPkgSkeleton.generate("NewPkg"; path=tempdir()) + +# You can generate this README with: +#= +```julia +using Literate: Literate +using ITensorPkgSkeleton: ITensorPkgSkeleton +Literate.markdown( + joinpath(pkgdir(ITensorPkgSkeleton), "examples", "README.jl"), + joinpath(pkgdir(ITensorPkgSkeleton), "docs", "src"); + flavor=Literate.DocumenterFlavor(), + name="index", +) +``` +=# diff --git a/src/ITensorPkgSkeleton.jl b/src/ITensorPkgSkeleton.jl index 5c9a833..74af47b 100644 --- a/src/ITensorPkgSkeleton.jl +++ b/src/ITensorPkgSkeleton.jl @@ -61,11 +61,7 @@ function generate(pkg_name; path=default_path()) "USERNAME" => "ITensor developers", "USEREMAIL" => "support@itensor.org", ]) - PkgSkeleton.generate( - pkg_path; - templates=[template_dir], - user_replacements, - ) + PkgSkeleton.generate(pkg_path; templates=[template_dir], user_replacements) # Change the default branch. change_branch_name(pkg_path, branch_name) diff --git a/templates/default/.github/workflows/FormatCheck.yml b/templates/default/.github/workflows/FormatCheck.yml new file mode 100644 index 0000000..bb6d933 --- /dev/null +++ b/templates/default/.github/workflows/FormatCheck.yml @@ -0,0 +1,35 @@ +name: Format check +on: + push: + branches: [main] + tags: [v*] + pull_request: + +jobs: + format: + name: "Format Check" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 + with: + version: 1 + - name: Install JuliaFormatter and format + run: | + julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))' + julia -e 'using JuliaFormatter; format(".", verbose=true)' + - name: Check format + run: | + julia -e ' + out = Cmd(`git diff --name-only`) |> read |> String + if out == "" + exit(0) + else + @error "The following files have not been formatted:" + write(stdout, out) + out_diff = Cmd(`git diff`) |> read |> String + @error "Diff:" + write(stdout, out_diff) + exit(1) + @error "" + end' diff --git a/templates/default/README.md b/templates/default/README.md deleted file mode 100644 index b20e374..0000000 --- a/templates/default/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# {PKGNAME}.jl - -[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/{PKGNAME}.jl/stable/) -[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/{PKGNAME}.jl/dev/) -[![Build Status](https://github.com/ITensor/{PKGNAME}.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ITensor/{PKGNAME}.jl/actions/workflows/CI.yml?query=branch%3Amain) -[![Coverage](https://codecov.io/gh/ITensor/{PKGNAME}.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/{PKGNAME}.jl) -[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle) -[![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl) diff --git a/templates/default/README.md b/templates/default/README.md new file mode 120000 index 0000000..8785db1 --- /dev/null +++ b/templates/default/README.md @@ -0,0 +1 @@ +docs/src/index.md \ No newline at end of file diff --git a/templates/default/docs/src/index.md b/templates/default/docs/src/index.md index d5c66cf..88245eb 100644 --- a/templates/default/docs/src/index.md +++ b/templates/default/docs/src/index.md @@ -1,14 +1,45 @@ ```@meta -CurrentModule = {PKGNAME} +EditURL = "../../examples/README.jl" ``` -# {PKGNAME} +# {PKGNAME}.jl -Documentation for [{PKGNAME}](https://github.com/ITensor/{PKGNAME}.jl). +[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/{PKGNAME}.jl/stable/) +[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/{PKGNAME}.jl/dev/) +[![Build Status](https://github.com/ITensor/{PKGNAME}.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ITensor/{PKGNAME}.jl/actions/workflows/CI.yml?query=branch%3Amain) +[![Coverage](https://codecov.io/gh/ITensor/{PKGNAME}.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/{PKGNAME}.jl) +[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle) +[![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl) -```@index +## Installation instructions + +```julia +julia> using Pkg: Pkg + +julia> Pkg.add("https://github.com/ITensor/{PKGNAME}.jl") ``` -```@autodocs -Modules = [{PKGNAME}] +## Examples + +````@example index +using {PKGNAME}: {PKGNAME} +```` + +Show examples of using {PKGNAME}.jl + +You can generate this README with: +```julia +using Literate: Literate +using {PKGNAME}: {PKGNAME} +Literate.markdown( + joinpath(pkgdir({PKGNAME}), "examples", "README.jl"), + joinpath(pkgdir({PKGNAME}), "docs", "src"); + flavor=Literate.DocumenterFlavor(), + name="index", +) ``` + +--- + +*This page was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).* + diff --git a/templates/default/examples/Project.toml b/templates/default/examples/Project.toml new file mode 100644 index 0000000..668a5cb --- /dev/null +++ b/templates/default/examples/Project.toml @@ -0,0 +1,2 @@ +[deps] +ITensorPkgSkeleton = "3d388ab1-018a-49f4-ae50-18094d5f71ea" diff --git a/templates/default/examples/README.jl b/templates/default/examples/README.jl new file mode 100644 index 0000000..8bbcf0d --- /dev/null +++ b/templates/default/examples/README.jl @@ -0,0 +1,37 @@ +# # {PKGNAME}.jl +# +# [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ITensor.github.io/{PKGNAME}.jl/stable/) +# [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://ITensor.github.io/{PKGNAME}.jl/dev/) +# [![Build Status](https://github.com/ITensor/{PKGNAME}.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/ITensor/{PKGNAME}.jl/actions/workflows/CI.yml?query=branch%3Amain) +# [![Coverage](https://codecov.io/gh/ITensor/{PKGNAME}.jl/branch/main/graph/badge.svg)](https://codecov.io/gh/ITensor/{PKGNAME}.jl) +# [![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-4495d1.svg)](https://github.com/invenia/BlueStyle) +# [![Aqua](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl) + +# ## Installation instructions + +#= +```julia +julia> using Pkg: Pkg + +julia> Pkg.add("https://github.com/ITensor/{PKGNAME}.jl") +``` +=# + +# ## Examples + +using {PKGNAME}: {PKGNAME} +# Show examples of using {PKGNAME}.jl + +# You can generate this README with: +#= +```julia +using Literate: Literate +using {PKGNAME}: {PKGNAME} +Literate.markdown( + joinpath(pkgdir({PKGNAME}), "examples", "README.jl"), + joinpath(pkgdir({PKGNAME}), "docs", "src"); + flavor=Literate.DocumenterFlavor(), + name="index", +) +``` +=# diff --git a/templates/default/test/test_examples.jl b/templates/default/test/test_examples.jl new file mode 100644 index 0000000..80c513f --- /dev/null +++ b/templates/default/test/test_examples.jl @@ -0,0 +1,8 @@ +@eval module $(gensym()) +using {PKGNAME}: {PKGNAME} +using Test: @test, @testset + +@testset "examples" begin + include(joinpath(pkgdir({PKGNAME}), "examples", "README.jl")) +end +end diff --git a/test/Project.toml b/test/Project.toml index ba6da5f..615e420 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,4 +1,5 @@ [deps] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" +Git_jll = "f8c6e375-362e-5223-8a59-34ff63f689eb" ITensorPkgSkeleton = "3d388ab1-018a-49f4-ae50-18094d5f71ea" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/test/test_examples.jl b/test/test_examples.jl new file mode 100644 index 0000000..b73f3b5 --- /dev/null +++ b/test/test_examples.jl @@ -0,0 +1,8 @@ +@eval module $(gensym()) +using ITensorPkgSkeleton: ITensorPkgSkeleton +using Test: @test, @testset + +@testset "examples" begin + include(joinpath(pkgdir(ITensorPkgSkeleton), "examples", "README.jl")) +end +end