Skip to content

Commit

Permalink
simplify setting all files in subdirectory in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaLampert committed Aug 20, 2024
1 parent 99583ab commit 090883c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 25 deletions.
28 changes: 5 additions & 23 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,12 @@ using DispersiveShallowWater
using TrixiBase
using Changelog: Changelog

# Dynamically replace all files in subdirectories of the source directory to include all files in these subdirectories
# Dynamically set all files in subdirectories of the source directory to include all files in these subdirectories
# This way they don't need to be listed explicitly
EQUATIONS_FILES_TO_BE_INSERTED = joinpath.(Ref("equations"),
readdir(joinpath(dirname(@__DIR__), "src",
"equations")))
CALLBACKS_STEP_FILES_TO_BE_INSERTED = joinpath.(Ref("callbacks_step"),
readdir(joinpath(dirname(@__DIR__), "src",
"callbacks_step")))

ref_path = joinpath(@__DIR__, "src", "ref.md")
lines = readlines(ref_path)
open(ref_path, "w") do io
for line in lines
if contains(line, "EQUATIONS_FILES_TO_BE_INSERTED")
line = replace(line,
"EQUATIONS_FILES_TO_BE_INSERTED" => EQUATIONS_FILES_TO_BE_INSERTED)
end
if contains(line, "CALLBACKS_STEP_FILES_TO_BE_INSERTED")
line = replace(line,
"CALLBACKS_STEP_FILES_TO_BE_INSERTED" => CALLBACKS_STEP_FILES_TO_BE_INSERTED)
end
println(io, line)
end
end
EQUATIONS_FILES = joinpath.(Ref("equations"), readdir(joinpath(dirname(@__DIR__), "src",
"equations")))
CALLBACKS_STEP_FILES = joinpath.(Ref("callbacks_step"), readdir(joinpath(dirname(@__DIR__), "src",
"callbacks_step")))

# Define module-wide setups such that the respective modules are available in doctests
DocMeta.setdocmeta!(DispersiveShallowWater, :DocTestSetup, :(using DispersiveShallowWater);
Expand Down
4 changes: 2 additions & 2 deletions docs/src/ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Pages = ["DispersiveShallowWater.jl"]

```@autodocs
Modules = [DispersiveShallowWater]
Pages = EQUATIONS_FILES_TO_BE_INSERTED
Pages = Main.EQUATIONS_FILES
```

## Mesh
Expand Down Expand Up @@ -48,7 +48,7 @@ Pages = ["semidiscretization.jl"]

```@autodocs
Modules = [DispersiveShallowWater]
Pages = CALLBACKS_STEP_FILES_TO_BE_INSERTED
Pages = Main.CALLBACKS_STEP_FILES
```

## Utilities
Expand Down

0 comments on commit 090883c

Please sign in to comment.