-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathmake.jl
175 lines (165 loc) · 6.35 KB
/
make.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#
# Copyright (c) 2021 Tobias Thummerer, Lars Mikelsons, Josef Kircher
# Licensed under the MIT license. See LICENSE file in the project root for details.
#
import Pkg;
Pkg.develop(path = joinpath(@__DIR__, "../../FMI.jl"));
using Documenter, Plots, JLD2, DataFrames, CSV, MAT, FMI, FMIBase, FMIImport, FMICore
using Documenter: GitHubActions
using Suppressor
example_pages = [
"Overview" => joinpath("examples", "overview.md"),
"Simulate" => joinpath("examples", "simulate.md"),
"Parameterize" => joinpath("examples", "parameterize.md"),
"Inputs" => joinpath("examples", "inputs.md"),
"Multiple instances" => joinpath("examples", "multiple_instances.md"),
"Modelica conference 2021" => joinpath("examples", "modelica_conference_2021.md"),
"Manipulation" => joinpath("examples", "manipulation.md"),
"Multithreading" => joinpath("examples", "multithreading.md"),
"Multiprocessing" => joinpath("examples", "multiprocessing.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. The svg-xml text has been removed for the doc-manual, but also no plot will be displayed\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 = "FMI.jl",
format = Documenter.HTML(
collapselevel = 1,
sidebar_sitename = false,
edit_link = nothing,
size_threshold = 512000,
size_threshold_ignore = [
"deprecated.md",
"fmi2_lowlevel_library_functions.md",
"fmi3_lowlevel_library_functions.md",
],
),
modules = [FMI, FMIImport, FMICore, FMIBase],
checkdocs = :exports,
linkcheck = true,
warnonly = :linkcheck,
pages = Any[
"Introduction" => "index.md"
"Features" => "features.md"
"FAQ" => "faq.md"
"Examples" => example_pages
"User Level API - FMI.jl" => "library.md"
"Developer Level API" => Any[
"fmi version independent content"=>Any[
"fmi_lowlevel_library_constants.md",
"fmi_lowlevel_modeldescription_functions.md",
"fmi_lowlevel_library_functions.md",
],
"FMI2 specific content"=>Any[
"fmi2_lowlevel_library_constants.md",
"FMI2 Functions in FMI Import/Core .jl"=>Any[
"fmi2_lowlevel_modeldescription_functions.md",
"fmi2_lowlevel_library_functions.md",
"fmi2_lowlevel_ME_functions.md",
"fmi2_lowlevel_CS_functions.md",
],
],
"FMI3 specific content"=>Any[
"fmi3_lowlevel_library_constants.md",
"FMI3 Functions in FMI Import/Core .jl"=>Any[
"fmi3_lowlevel_modeldescription_functions.md",
"fmi3_lowlevel_library_functions.md",
"fmi3_lowlevel_ME_functions.md",
"fmi3_lowlevel_CS_functions.md",
"fmi3_lowlevel_SE_functions.md",
],
],
]
"API Index" => "index_library.md"
"FMI Tool Information" => "fmi-tool-info.md"
"Related Publication" => "related.md"
"Contents" => "contents.md"
hide("Deprecated" => "deprecated.md")
],
)
function deployConfig()
github_repository = get(ENV, "GITHUB_REPOSITORY", "")
github_event_name = get(ENV, "GITHUB_EVENT_NAME", "")
if github_event_name == "workflow_run" || github_event_name == "repository_dispatch"
github_event_name = "push"
end
github_ref = get(ENV, "GITHUB_REF", "")
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",
deploy_config = deployConfig(),
)