Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Literate examples that generate docs and README #6

Merged
merged 5 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/FormatCheck.yml
Original file line number Diff line number Diff line change
@@ -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'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
Manifest.toml
benchmark/*.json
docs/build/
test/LocalPreferences.toml
16 changes: 0 additions & 16 deletions README.md

This file was deleted.

1 change: 1 addition & 0 deletions README.md
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Git_jll = "f8c6e375-362e-5223-8a59-34ff63f689eb"
ITensorPkgSkeleton = "3d388ab1-018a-49f4-ae50-18094d5f71ea"
54 changes: 48 additions & 6 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -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).*

2 changes: 2 additions & 0 deletions examples/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[deps]
ITensorPkgSkeleton = "3d388ab1-018a-49f4-ae50-18094d5f71ea"
41 changes: 41 additions & 0 deletions examples/README.jl
Original file line number Diff line number Diff line change
@@ -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",
)
```
=#
6 changes: 1 addition & 5 deletions src/ITensorPkgSkeleton.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,7 @@ function generate(pkg_name; path=default_path())
"USERNAME" => "ITensor developers",
"USEREMAIL" => "[email protected]",
])
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)
Expand Down
35 changes: 35 additions & 0 deletions templates/default/.github/workflows/FormatCheck.yml
Original file line number Diff line number Diff line change
@@ -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'
8 changes: 0 additions & 8 deletions templates/default/README.md

This file was deleted.

1 change: 1 addition & 0 deletions templates/default/README.md
43 changes: 37 additions & 6 deletions templates/default/docs/src/index.md
Original file line number Diff line number Diff line change
@@ -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).*

2 changes: 2 additions & 0 deletions templates/default/examples/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[deps]
ITensorPkgSkeleton = "3d388ab1-018a-49f4-ae50-18094d5f71ea"
37 changes: 37 additions & 0 deletions templates/default/examples/README.jl
Original file line number Diff line number Diff line change
@@ -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",
)
```
=#
8 changes: 8 additions & 0 deletions templates/default/test/test_examples.jl
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -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"
8 changes: 8 additions & 0 deletions test/test_examples.jl
Original file line number Diff line number Diff line change
@@ -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
Loading