Skip to content

Commit

Permalink
feat: 🎸 Generate docs pages list programatically
Browse files Browse the repository at this point in the history
The docs pages list are generated based on the contents of the docs/src folder.

✅ Closes: #32
  • Loading branch information
abelsiqueira committed May 15, 2024
1 parent 027d819 commit 868a111
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 29 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning].
### Changed

- Update Cirrus CI image_family (#31)
- Prefix some doc files with a number and generate the pages programatically (#32)

### Fixed

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ This structure should be self-informative, as it is part of what most people use
- PackageName.jl/
- docs/
- src/
- contributing.md
- developer.md
- 90-contributing.md
- 90-developer.md
- index.md
- reference.md
- 90-reference.md
- make.jl
- Project.toml
- src/
Expand All @@ -136,8 +136,8 @@ This structure should be self-informative, as it is part of what most people use
The exceptions are:
- `test/Project.toml`: This is supported for a while, and it looks better. Time will tell if it was a bad idea.
- `docs/src/contributing.md`: Also known as CONTRIBUTING.md, it explains how contributors can get involved in the project.
- `docs/src/developer.md`: Also known as README.dev.md, it explains how to setup your local environment.
- `docs/src/90-contributing.md`: Also known as CONTRIBUTING.md, it explains how contributors can get involved in the project.
- `docs/src/90-developer.md`: Also known as README.dev.md, it explains how to setup your local environment.
### Linting and Formatting
Expand Down
4 changes: 2 additions & 2 deletions copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ _skip_if_exists:
- "**/*.jl"
- "!docs/make.jl"
- "**/*.md"
- "!docs/src/contributing.md"
- "!docs/src/developer.md"
- "!docs/src/90-contributing.md"
- "!docs/src/90-developer.md"
- "**/Project.toml"
- CITATION.cff
- LICENSE
Expand Down
7 changes: 2 additions & 5 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Don't forget to run
#
# pkg> dev ..
#
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
COPIERTemplate = "5022dd56-1d41-4538-9f4c-b20739ff8283"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
LiveServer = "16fef848-5104-11e9-1b77-fb7a48bbb589"

[compat]
Documenter = "1"
19 changes: 15 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ using Documenter

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

const page_rename = Dict("developer.md" => "Dev setup")

function nice_name(file)
file = replace(file, r"^[0-9]*-" => "")
if haskey(page_rename, file)
return page_rename[file]
end
return splitext(file)[1] |> x -> replace(x, "-" => " ") |> titlecase
end

makedocs(;
modules = [COPIERTemplate],
doctest = true,
Expand All @@ -16,10 +26,11 @@ makedocs(;
assets = ["assets/style.css"],
),
pages = [
"Home" => "index.md",
"Contributing" => "contributing.md",
"Dev setup" => "developer.md",
"Reference" => "reference.md",
"Home" => "index.md"
[
nice_name(file) => file for
file in readdir(joinpath(@__DIR__, "src")) if file != "index.md" && splitext(file)[2] == ".md"
]
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Otherwise, say what your proposed solution is and wait for a discussion around i
>
> Feel free to ping us after a few days if there are no responses.
If your solution involves code (or something that requires running the package locally), check the [developer documentation](developer.md).
If your solution involves code (or something that requires running the package locally), check the [developer documentation](90-developer.md).
Otherwise, you can use the GitHub interface directly to create your pull request.
2 changes: 1 addition & 1 deletion docs/src/developer.md → docs/src/90-developer.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Developer documentation

If you haven't, please read the [Contributing guidelines](contributing.md) first.
If you haven't, please read the [Contributing guidelines](90-contributing.md) first.

## Linting and formatting

Expand Down
4 changes: 2 additions & 2 deletions docs/src/reference.md → docs/src/90-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
## Contents

```@contents
Pages = ["reference.md"]
Pages = ["90-reference.md"]
```

## Index

```@index
Pages = ["reference.md"]
Pages = ["90-reference.md"]
```

```@autodocs
Expand Down
2 changes: 1 addition & 1 deletion template/README.md.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ If you use {{ PackageName }}.jl in your work, please cite using the reference gi

## Contributing

If you want to make contributions of any kind, please first that a look into our [contributing guide directly on GitHub](docs/src/contributing.md) or the [contributing page on the website](https://{{ PackageOwner }}.github.io/{{ PackageName }}.jl/dev/contributing/).
If you want to make contributions of any kind, please first that a look into our [contributing guide directly on GitHub](docs/src/90-contributing.md) or the [contributing page on the website](https://{{ PackageOwner }}.github.io/{{ PackageName }}.jl/dev/contributing/).

---

Expand Down
19 changes: 15 additions & 4 deletions template/docs/make.jl.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ using Documenter

DocMeta.setdocmeta!({{ PackageName }}, :DocTestSetup, :(using {{ PackageName }}); recursive = true)

const page_rename = Dict("developer.md" => "Developer docs") # Without the numbers

function nice_name(file)
file = replace(file, r"^[0-9]*-" => "")
if haskey(page_rename, file)
return page_rename[file]
end
return splitext(file)[1] |> x -> replace(x, "-" => " ") |> titlecase
end

makedocs(;
modules = [{{ PackageName }}],
doctest = true,
Expand All @@ -16,10 +26,11 @@ makedocs(;
assets = ["assets/style.css"],
),
pages = [
"Home" => "index.md",
"Contributing" => "contributing.md",
"Dev setup" => "developer.md",
"Reference" => "reference.md",
"Home" => "index.md";
[
nice_name(file) => file for
file in readdir(joinpath(@__DIR__), "src") if file != "index.md" && splitext(file[2]) == ".md"
]
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ Otherwise, say what your proposed solution is and wait for a discussion around i
>
> Feel free to ping us after a few days if there are no responses.

If your solution involves code (or something that requires running the package locally), check the [developer documentation](developer.md).
If your solution involves code (or something that requires running the package locally), check the [developer documentation](90-developer.md).
Otherwise, you can use the GitHub interface directly to create your pull request.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Developer documentation

If you haven't, please read the [Contributing guidelines](contributing.md) first.
If you haven't, please read the [Contributing guidelines](90-contributing.md) first.

## Linting and formatting

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
## Contents

```@contents
Pages = ["reference.md"]
Pages = ["90-reference.md"]
```

## Index

```@index
Pages = ["reference.md"]
Pages = ["90-reference.md"]
```

```@autodocs
Expand Down

0 comments on commit 868a111

Please sign in to comment.