From ec455aa9ae446b889eba3bf1a07ab3c67e4342cf Mon Sep 17 00:00:00 2001 From: Simon Exner <43469235+0815Creeper@users.noreply.github.com> Date: Wed, 18 Sep 2024 09:41:15 +0200 Subject: [PATCH] updated make.jl to new standart --- docs/make.jl | 105 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 92 insertions(+), 13 deletions(-) diff --git a/docs/make.jl b/docs/make.jl index fedd7643..a7f538ce 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -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("", 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" @@ -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",