Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added FMIExport Examples to doc #256

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/Documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ jobs:
rm -r $WORK_TREE/jupyter-src
cp ./README.md ./docs/src/index.md

- name: "Check out fmi-export repository"
uses: actions/checkout@v4
with:
repository: 'ThummeTo/FMIExport.jl'
ref: 'examples'
path: 'FMIExport.jl'

- name: "Copy fmi-export examples"
env:
WORK_TREE: './docs/src/examples/fmiexport_examples'
SRC_FOLDER_PATH: 'FMIExport.jl/examples'
# copy the examples from the examples branch (.md, .svg) and copy the readme in the docs folder
# $SRC_FOLDER_PATH/jupyter-src/*.svg $SRC_FOLDER_PATH/pluto-src/*.html
run: |
mkdir $WORK_TREE
mv $SRC_FOLDER_PATH/*.md $WORK_TREE
rm -r $SRC_FOLDER_PATH/*

- name: "Install dependencies"
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'

Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ deps/src/
# Build artifacts for creating documentation generated by the Documenter package
docs/build/
docs/site/
docs/src/index.md
docs/src/examples
!docs/src/examples/overview.md
!docs/src/examples/workshops.md
!docs/src/examples/pics

# File generated by Pkg, the package manager, based on a corresponding Project.toml
# It records a fixed state of all packages used by the project. As such, it should not be
Expand Down
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
FMIBase = "900ee838-d029-460e-b485-d98a826ceef2"
FMICore = "8af89139-c281-408e-bce2-3005eb87462f"
FMIExport = "31b88311-cab6-44ed-ba9c-fe5a9abbd67a"
FMIImport = "9fcbc62e-52a0-44e9-a616-1359a0008194"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
Expand Down
51 changes: 42 additions & 9 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

import Pkg;
Pkg.develop(path = joinpath(@__DIR__, "../../FMI.jl"));
using Documenter, Plots, JLD2, DataFrames, CSV, MAT, FMI, FMIBase, FMIImport, FMICore
using Plots, JLD2, DataFrames, CSV, MAT # need to be loaded, as they enable optional features in FMI.jl
using FMI, FMIBase, FMIImport, FMICore, FMIExport
using Documenter
using Documenter: GitHubActions
using Suppressor

Expand All @@ -20,13 +22,43 @@ example_pages = [
"Multithreading" => joinpath("examples", "multithreading.md"),
"Multiprocessing" => joinpath("examples", "multiprocessing.md"),
"Pluto Workshops" => joinpath("examples", "workshops.md"),
"FMIExport Examples" => [
"Export Bouncing Ball" => joinpath("examples", "fmiexport_examples", "Export-BouncingBall.md"),
]
]

function recursive_second(vec)
s = []
for e in vec
if typeof(e[2]) == String
push!(s, e[2])
else
append!(s, recursive_second(e[2]))
end
end
return s
end
function recursive_second_filter!(f, a)
deleteat = []
for i in keys(a)
if typeof(a[i][2]) == String
if f(a[i]) == false
push!(deleteat, i)
end
else
recursive_second_filter!(f, a[i][2])
if length(a[i][2]) == 0
push!(deleteat, i)
end
end
end
deleteat!(a, deleteat)
return a
end
mdFilesInExampleDir = filter(f -> endswith(f, ".md"), collect(Iterators.flatten([(length(item[3]) > 0) ? [joinpath(item[1],f) for f in item[3]] : [] for item in walkdir(joinpath("docs", "src", "examples"))])))
#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])
for md in mdFilesInExampleDir
if !occursin("README", md) && all([!endswith(md, file) for file in recursive_second(example_pages)])
print(
string(
"::warning title=Example-Warning::example \"",
Expand All @@ -39,17 +71,18 @@ 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)
for md in recursive_second(example_pages)
# check if file is missing
if !(any([occursin(file, md) for file in readdir(joinpath("docs", "src", "examples"))]))
if !(any([occursin(md, file) for file in mdFilesInExampleDir]))
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)
println(md)
recursive_second_filter!(e -> e[2] ≠ md, example_pages)
else
# removal of svgs is here if there is xml data in the md
r = open(joinpath("docs", "src", md), "r")
Expand Down Expand Up @@ -97,7 +130,7 @@ my_makedocs() = makedocs(
"fmi3_lowlevel_library_functions.md",
],
),
modules = [FMI, FMIImport, FMICore, FMIBase],
modules = [FMI, FMIImport, FMIExport, FMICore, FMIBase],
checkdocs = :exports,
linkcheck = true,
warnonly = :linkcheck,
Expand Down
6 changes: 5 additions & 1 deletion docs/src/examples/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This section discusses the included examples of the FMI.jl library.
If you require further information about the function calls, see the function sections of the [library](https://thummeto.github.io/FMI.jl/dev/library/).

Examples are subdevided into *Basics*, *Advanced*, *Pluto workshops* and *Publication appendices*.
Examples are subdevided into *Basics*, *Advanced*, *Export*, *Pluto workshops* and *Publication appendices*.


**Basic examples:**
Expand All @@ -22,6 +22,10 @@ Examples are subdevided into *Basics*, *Advanced*, *Pluto workshops* and *Public
- [__Multiprocessing__](https://thummeto.github.io/FMI.jl/dev/examples/multiprocessing/): Shows how to use multiprocessing to simulate multiple FMUs.


**FMIExport.jl examples:**

- [__Export-BouncingBall__](https://thummeto.github.io/FMI.jl/dev/examples/fmiexport_examples/Export-BouncingBall/): Export an FMU of a BouncingBall, that is implemented in Julia

**Pluto workshops:**

- [__Pluto workshops__](https://thummeto.github.io/FMI.jl/dev/examples/workshops/): [Pluto](https://plutojl.org/) based notebooks, that can easyly be executed on your own Pluto-Setup.
Expand Down
Loading
Loading