Skip to content

Commit

Permalink
Add documentation via Documenter.jl
Browse files Browse the repository at this point in the history
  • Loading branch information
sloede committed Sep 20, 2023
1 parent e8082bc commit 37ba743
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Documentation

on:
push:
branches:
- master
tags: '*'
pull_request:

jobs:
build:
permissions:
contents: write
statuses: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: '1.6'
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- name: Build and deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key
run: julia --project=docs/ docs/make.jl
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Preferences
# Preferences.jl

[![Docs-stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliapackaging.github.io/Preferences.jl/stable)
[![Docs-dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliapackaging.github.io/Preferences.jl/dev)
[![Continuous Integration][ci-img]][ci-url]
[![Code Coverage][codecov-img]][codecov-url]
[![License: MIT](https://img.shields.io/badge/License-MIT-success.svg)](https://opensource.org/licenses/MIT)

[ci-url]: https://github.com/JuliaPackaging/Preferences.jl/actions?query=workflow%3ACI
[codecov-url]: https://codecov.io/gh/JuliaPackaging/Preferences.jl
Expand Down Expand Up @@ -98,3 +101,12 @@ end
```
Note that these cannot be merged into a single `@static if`. Loading
the package with `using Preferences` must be done on its own.

## Authors
This repository was initiated by Elliot Saba
([@staticfloat](https://github.com/staticfloat)) and continues to be maintained by him and
other contributors.

## License and contributing
Preferences.jl is licensed under the MIT license (see [LICENSE.md](LICENSE.md)).
Contributions by volunteers are welcome!
3 changes: 3 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
build/
src/index.md
src/license.md
6 changes: 6 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"

[compat]
Documenter = "1"
55 changes: 55 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using Documenter
using Preferences

# Copy files and modify them for the docs so that we do not maintain two
# versions manually.
open(joinpath(@__DIR__, "src", "index.md"), "w") do io
# Point to source license file
println(io, """
```@meta
EditURL = "https://github.com/JuliaPackaging/Preferences.jl/blob/master/README.md"
```
""")
# Write the modified contents
for line in eachline(joinpath(dirname(@__DIR__), "README.md"))
line = replace(line, "[LICENSE.md](LICENSE.md)" => "[License](@ref)")
println(io, line)
end
end

open(joinpath(@__DIR__, "src", "license.md"), "w") do io
# Point to source license file
println(io, """
```@meta
EditURL = "https://github.com/JuliaPackaging/Preferences.jl/blob/master/LICENSE.md"
```
""")
# Write the modified contents
println(io, "# License")
println(io, "")
for line in eachline(joinpath(dirname(@__DIR__), "LICENSE.md"))
println(io, "> ", line)
end
end

# Build docs
makedocs(;
sitename = "Preferences.jl",
modules = [Preferences],
format = Documenter.HTML(
prettyurls=get(ENV, "CI", "false") == "true",
canonical = "https://juliapackaging.github.io/Preferences.jl/stable"
),
pages = [
"Home" => "index.md",
"Reference" => "reference.md",
"License" => "license.md"
]
)

# Deploy docs
deploydocs(;
repo = "github.com/JuliaPackaging/Preferences.jl.git",
devbranch = "master",
push_preview = false,
)
9 changes: 9 additions & 0 deletions docs/src/reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Reference

```@meta
CurrentModule = Preferences
```

```@autodocs
Modules = [Preferences]
```

0 comments on commit 37ba743

Please sign in to comment.