Skip to content

Commit

Permalink
Update README and docs generation (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman authored Nov 23, 2024
1 parent 5fc0669 commit 9c6639c
Show file tree
Hide file tree
Showing 27 changed files with 166 additions and 148 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ If you are unable to construct a minimal code that demonstrates the bug or unexp
```julia
[YOUR MINIMAL RUNNABLE CODE HERE]
```

</p></details>


Expand Down
2 changes: 2 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ If practical and applicable, please include a minimal demonstration of the previ
```julia
[YOUR MINIMAL DEMONSTRATION OF PREVIOUS BEHAVIOR]
```

</p></details>

<details><summary>Minimal demonstration of new behavior</summary><p>

```julia
[YOUR MINIMAL DEMONSTRATION OF NEW BEHAVIOR]
```

</p></details>

# How Has This Been Tested?
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
fail-fast: false
matrix:
version:
- '1.10'
- 'lts'
- '1'
os:
- ubuntu-latest
- macOS-latest
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/LiterateCheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ jobs:
version: 1
- name: Install Literate and generate docs
run: |
julia -e 'using Pkg; Pkg.add(PackageSpec(name="Literate"))'
julia -e 'using Literate; Literate.markdown("examples/README.jl", "docs/src"; flavor=Literate.DocumenterFlavor(), name="index")'
julia -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()
Pkg.add(PackageSpec(name="Literate"))'
julia -e 'include("make_readme.jl")'
- name: Check if docs need to be updated
run: |
julia -e '
out = Cmd(`git diff --name-only`) |> read |> String
if out == ""
exit(0)
else
@error "The documentation is outdated, rerun Literate to regenerate them."
@error "The docs are outdated, rerun Literate to regenerate them."
write(stdout, out)
out_diff = Cmd(`git diff`) |> read |> String
@error "Diff:"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
.vscode/
/docs/Manifest.toml
/docs/build/
/docs/src/index.md
Manifest.toml
benchmark/*.json
docs/build/
Expand Down
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ version = "0.1.0"
[deps]
Git = "d7ba0133-e1db-5d97-8f8c-041e4b3a1eb2"
Git_jll = "f8c6e375-362e-5223-8a59-34ff63f689eb"
LibGit2 = "76f85450-5226-5b5a-8eaa-529ad045b433"
PkgSkeleton = "d254efa0-af53-535e-b7f1-03c1c9fbcbe7"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"

[compat]
Aqua = "0.8.9"
Git = "1.3.1"
Git_jll = "2.46.2"
LibGit2 = "1.10"
PkgSkeleton = "1.3.1"
Preferences = "1.4.3"
Test = "1.10"
Expand Down
1 change: 0 additions & 1 deletion README.md

This file was deleted.

40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# 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

````julia
using ITensorPkgSkeleton: ITensorPkgSkeleton
````

This step might be required to circumvent issues with
the version of git installed by `Git.jl`.

````julia
ITensorPkgSkeleton.use_system_git!()
````

If `path` isn't specified, it defaults to `~/.julia/dev`.

````julia
ITensorPkgSkeleton.generate("NewPkg"; path=mktempdir())
````

---

*This page was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*

1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Git_jll = "f8c6e375-362e-5223-8a59-34ff63f689eb"
ITensorPkgSkeleton = "3d388ab1-018a-49f4-ae50-18094d5f71ea"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
6 changes: 4 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using ITensorPkgSkeleton
using Documenter
using ITensorPkgSkeleton: ITensorPkgSkeleton
using Documenter: Documenter, DocMeta, deploydocs, makedocs

DocMeta.setdocmeta!(
ITensorPkgSkeleton, :DocTestSetup, :(using ITensorPkgSkeleton); recursive=true
)

include("make_index.jl")

makedocs(;
modules=[ITensorPkgSkeleton],
authors="ITensor developers <[email protected]> and contributors",
Expand Down
9 changes: 9 additions & 0 deletions docs/make_index.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Literate: Literate
using ITensorPkgSkeleton: ITensorPkgSkeleton

Literate.markdown(
joinpath(pkgdir(ITensorPkgSkeleton), "examples", "README.jl"),
joinpath(pkgdir(ITensorPkgSkeleton), "docs", "src");
flavor=Literate.DocumenterFlavor(),
name="index",
)
56 changes: 0 additions & 56 deletions docs/src/index.md

This file was deleted.

14 changes: 0 additions & 14 deletions examples/README.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,3 @@ using ITensorPkgSkeleton: ITensorPkgSkeleton
ITensorPkgSkeleton.use_system_git!()
# If `path` isn't specified, it defaults to `~/.julia/dev`.
ITensorPkgSkeleton.generate("NewPkg"; path=mktempdir())

# 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",
)
```
=#
9 changes: 9 additions & 0 deletions make_readme.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Literate: Literate
using ITensorPkgSkeleton: ITensorPkgSkeleton

Literate.markdown(
joinpath(pkgdir(ITensorPkgSkeleton), "examples", "README.jl"),
joinpath(pkgdir(ITensorPkgSkeleton));
flavor=Literate.CommonMarkFlavor(),
name="README",
)
17 changes: 15 additions & 2 deletions src/ITensorPkgSkeleton.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module ITensorPkgSkeleton

using Git: git
using LibGit2: LibGit2
using PkgSkeleton: PkgSkeleton
using Preferences: Preferences

Expand Down Expand Up @@ -93,6 +94,15 @@ function set_default_template_path(template)
return joinpath(pkgdir(ITensorPkgSkeleton), "templates", template)
end

function is_git_repo(path)
return try
LibGit2.GitRepo(path)
return true
catch
return false
end
end

function generate(
pkg_name; path=default_path(), templates=default_templates(), user_replacements=(;)
)
Expand All @@ -103,11 +113,14 @@ function generate(
# Process downstream package information.
user_replacements = format_downstream_pkgs(user_replacements)
pkg_path = joinpath(path, pkg_name)
is_new_repo = !is_git_repo(pkg_path)
branch_name = default_branch_name()
user_replacements_dict = Dict(keys(user_replacements) .=> values(user_replacements))
PkgSkeleton.generate(pkg_path; templates, user_replacements=user_replacements_dict)
# Change the default branch.
change_branch_name(pkg_path, branch_name)
if is_new_repo
# Change the default branch if this is a new repository.
change_branch_name(pkg_path, branch_name)
end
return nothing
end

Expand Down
1 change: 1 addition & 0 deletions templates/default/.github/ISSUE_TEMPLATE/BUG_REPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ If you are unable to construct a minimal code that demonstrates the bug or unexp
```julia
[YOUR MINIMAL RUNNABLE CODE HERE]
```

</p></details>


Expand Down
2 changes: 2 additions & 0 deletions templates/default/.github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ If practical and applicable, please include a minimal demonstration of the previ
```julia
[YOUR MINIMAL DEMONSTRATION OF PREVIOUS BEHAVIOR]
```

</p></details>

<details><summary>Minimal demonstration of new behavior</summary><p>

```julia
[YOUR MINIMAL DEMONSTRATION OF NEW BEHAVIOR]
```

</p></details>

# How Has This Been Tested?
Expand Down
2 changes: 1 addition & 1 deletion templates/default/.github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
fail-fast: false
matrix:
version:
- '1.10'
- 'lts'
- '1'
os:
- ubuntu-latest
- macOS-latest
Expand Down
10 changes: 7 additions & 3 deletions templates/default/.github/workflows/LiterateCheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ jobs:
version: 1
- name: Install Literate and generate docs
run: |
julia -e 'using Pkg; Pkg.add(PackageSpec(name="Literate"))'
julia -e 'using Literate; Literate.markdown("examples/README.jl", "docs/src"; flavor=Literate.DocumenterFlavor(), name="index")'
julia -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()
Pkg.add(PackageSpec(name="Literate"))'
julia -e 'include("make_readme.jl")'
- name: Check if docs need to be updated
run: |
julia -e '
out = Cmd(`git diff --name-only`) |> read |> String
if out == ""
exit(0)
else
@error "The documentation is outdated, rerun Literate to regenerate them."
@error "The docs are outdated, rerun Literate to regenerate them."
write(stdout, out)
out_diff = Cmd(`git diff`) |> read |> String
@error "Diff:"
Expand Down
2 changes: 2 additions & 0 deletions templates/default/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
.vscode/
/docs/Manifest.toml
/docs/build/
/docs/src/index.md
Manifest.toml
benchmark/*.json
docs/build/
test/LocalPreferences.toml
1 change: 0 additions & 1 deletion templates/default/README.md

This file was deleted.

29 changes: 29 additions & 0 deletions templates/default/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# {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

````julia
using {PKGNAME}: {PKGNAME}
````

Examples go here.

---

*This page was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*

4 changes: 3 additions & 1 deletion templates/default/docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
{PKGNAME} = "70ffe8f8-8519-465d-b12c-3b7d28f4e5e2"
Git_jll = "f8c6e375-362e-5223-8a59-34ff63f689eb"
{PKGNAME} = "3d388ab1-018a-49f4-ae50-18094d5f71ea"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
Loading

0 comments on commit 9c6639c

Please sign in to comment.