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 ec455aa
Showing 1 changed file with 92 additions and 13 deletions.
105 changes: 92 additions & 13 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,90 @@ import Pkg;
Pkg.develop(path = joinpath(@__DIR__, "../../FMIFlux.jl"));
using Documenter, FMIFlux
using Documenter: GitHubActions
using Suppressor

makedocs(
example_pages = [
"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",
]

#check if all md files in examples are included in docs
for md in readdir("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)
if !(any([occursin(file, md) for file in readdir("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)
end
# removal of svgs is here if there is xml data in the md
r = open(joinpath("docs", "src", md), "r")
s = read(r, String)
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",
),
)
w = open(joinpath("docs", "src", md, "tmp"), "w+")
replace!(s, r"\<\?xml(?!<\\svg>)(.|\n)*?<\/svg>" => "")
write(w, s)
close(w)
end
close(r)
if isfile(joinpath("docs", "src", md, "tmp"))
mv(joinpath("docs", "src", md, "tmp"), joinpath("docs", "src", md), force = true)
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 = [
"examples/juliacon_2023.md",
"examples/modelica_conference_2021.md",
"examples/simple_hybrid_CS.md",
"examples/simple_hybrid_ME.md",
],
),
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"
]
"Examples" => example_pages
"FAQ" => "faq.md"
"Library Functions" => "library.md"
"Related Publication" => "related.md"
Expand All @@ -46,6 +108,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 ec455aa

Please sign in to comment.