Skip to content

Commit

Permalink
updated make.jl to new standart
Browse files Browse the repository at this point in the history
  • Loading branch information
0815Creeper committed Sep 18, 2024
1 parent 2d36501 commit 13eac2c
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 13 deletions.
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"

[compat]
julia = "1.6"
113 changes: 100 additions & 13 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,99 @@ import Pkg;
Pkg.develop(path = joinpath(@__DIR__, "../../FMIFlux.jl"));
using Documenter, FMIFlux
using Documenter: GitHubActions
using Suppressor

makedocs(
example_pages = [
"Overview" => joinpath("examples", "overview.md"),
"Simple CS-NeuralFMU" => joinpath("examples", "simple_hybrid_CS.md"),
"Simple ME-NeuralFMU" => joinpath("examples", "simple_hybrid_ME.md"),
"Growing Horizon ME-NeuralFMU" => joinpath("examples", "growing_horizon_ME.md"),
"JuliaCon 2023" => joinpath("examples", "juliacon_2023.md"),
"MDPI 2022" => joinpath("examples", "mdpi_2022.md"),
"Modelica Conference 2021" => joinpath("examples", "modelica_conference_2021.md"),
"Pluto Workshops" => joinpath("examples", "workshops.md"),
]

#check if all md files in examples are included in docs
for md in readdir(joinpath("docs", "src", "examples"))
if endswith(md, ".md") &&
!occursin("README", md) &&
all([!endswith(file, md) for (x, file) in example_pages])
print(
string(
"::warning title=Example-Warning::example \"",
md,
"\" is not included in the doc-manual\r\n",
),
)
end
end

#remove any example pages, for witch the example can not be found
# and remove svgs if md building failed
for (x, md) in deepcopy(example_pages)
# check if file is missing
if !(any([occursin(file, md) for file in readdir(joinpath("docs", "src", "examples"))]))
print(
string(
"::warning title=Example-Warning::example-page \"",
md,
"\" is to be included in the doc-manual, but could not be found on the examples branch or in \"docs/src/examples\"\r\n",
),
)
filter!(e -> e (x => md), example_pages)
else
# removal of svgs is here if there is xml data in the md
r = open(joinpath("docs", "src", md), "r")
s = read(r, String)
close(r)
if occursin("<svg", s) && occursin("</svg>", s)
print(
string(
"::warning title=SVG-Warning::example-page \"",
md,
"\" has svg-xml text in it. Most likely, linking of support-files generated by jupyter is broken\"\r\n",
),
)
# regex replace exeeds stack limit: s = replace(s, r"\<\?xml(?!<\/svg>)(.|\n)*?<\/svg>" => "")
# so take iterative approach:
while occursin("<?xml", s) && occursin("</svg>", s)
a = findfirst("<?xml", s)[1] - 1
b = findfirst("</svg>", s)[end] + 1
s = string(s[1:a], s[b:end])
end
w = open(joinpath("docs", "src", md * "tmp"), "w+")
write(w, s)
close(w)
end
if isfile(joinpath("docs", "src", md * "tmp"))
mv(
joinpath("docs", "src", md * "tmp"),
joinpath("docs", "src", md),
force = true,
)
end
end
end

my_makedocs() = makedocs(
sitename = "FMIFlux.jl",
format = Documenter.HTML(
collapselevel = 1,
sidebar_sitename = false,
edit_link = nothing,
size_threshold_ignore = [joinpath("examples", "juliacon_2023.md", "modelica_conference_2021.md", "simple_hybrid_CS.md","simple_hybrid_ME.md")],
size_threshold = 512000,
size_threshold_ignore = [
],
),
warnonly = true,
modules = [FMIFlux],
checkdocs = :exports,
linkcheck = true,
warnonly = :linkcheck,
pages = Any[
"Introduction" => "index.md"
"Examples" => [
"Overview" => "examples/overview.md"
"Simple CS-NeuralFMU" => "examples/simple_hybrid_CS.md"
"Simple ME-NeuralFMU" => "examples/simple_hybrid_ME.md"
#"Growing Horizon ME-NeuralFMU" => "examples/growing_horizon_ME.md"
"JuliaCon 2023" => "examples/juliacon_2023.md"
#"MDPI 2022" => "examples/mdpi_2022.md"
"Modelica Conference 2021" => "examples/modelica_conference_2021.md"
"Pluto Workshops" => "examples/workshops.md"
]
"FAQ" => "faq.md"
"Examples" => example_pages
"Library Functions" => "library.md"
"Related Publication" => "related.md"
"Contents" => "contents.md"
Expand All @@ -46,6 +116,23 @@ function deployConfig()
return GitHubActions(github_repository, github_event_name, github_ref)
end

output = ""
try
global output = @capture_err begin
my_makedocs()
end
catch e
my_makedocs() # if it fails, re-run without capturing, so that its stderr appears in the console/logs
end

# errors = findall(r"Error:.*", output)
warns = findall(r"Warning:.*", output)

for w in warns
s = string("::warning title=Documenter-Warning::", output[w], "\r\n")
print(s)
end

deploydocs(
repo = string("github.com/", get(ENV, "GITHUB_REPOSITORY", ""), "git"),
devbranch = "main",
Expand Down

0 comments on commit 13eac2c

Please sign in to comment.