From 13eac2c95dcfb18dc1ed3c642a1ac947650dd133 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/Project.toml | 1 + docs/make.jl | 113 ++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 101 insertions(+), 13 deletions(-) diff --git a/docs/Project.toml b/docs/Project.toml index 67a236d2..42c482d4 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,5 +1,6 @@ [deps] Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" +Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb" [compat] julia = "1.6" diff --git a/docs/make.jl b/docs/make.jl index fedd7643..6b19b4b1 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -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("", 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("", s) + a = findfirst("", 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" @@ -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",