Skip to content

Commit 4168d9d

Browse files
Merge pull request #66 from ArnoStrouwen/doc_improv
Doc improv
2 parents ba225d7 + 3991571 commit 4168d9d

File tree

8 files changed

+190
-158
lines changed

8 files changed

+190
-158
lines changed

.JuliaFormatter.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
style = "sciml"
1+
style = "sciml"
2+
format_markdown = true

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
/Manifest.toml
1+
Manifest.toml
2+
docs/build

README.md

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# RuntimeGeneratedFunctions.jl
22

3-
43
[![Join the chat at https://julialang.zulipchat.com #sciml-bridged](https://img.shields.io/static/v1?label=Zulip&message=chat&color=9558b2&labelColor=389826)](https://julialang.zulipchat.com/#narrow/stream/279055-sciml-bridged)
54
[![Global Docs](https://img.shields.io/badge/docs-SciML-blue.svg)](https://docs.sciml.ai/RuntimeGeneratedFunctions/stable/)
65

76
[![codecov](https://codecov.io/gh/SciML/RuntimeGeneratedFunctions.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/SciML/RuntimeGeneratedFunctions.jl)
87
[![Build Status](https://github.com/SciML/RuntimeGeneratedFunctions.jl/workflows/CI/badge.svg)](https://github.com/SciML/RuntimeGeneratedFunctions.jl/actions?query=workflow%3ACI)
98

10-
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor's%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
9+
[![ColPrac: Contributor's Guide on Collaborative Practices for Community Packages](https://img.shields.io/badge/ColPrac-Contributor%27s%20Guide-blueviolet)](https://github.com/SciML/ColPrac)
1110
[![SciML Code Style](https://img.shields.io/static/v1?label=code%20style&message=SciML&color=9558b2&labelColor=389826)](https://github.com/SciML/SciMLStyle)
1211

13-
1412
`RuntimeGeneratedFunctions` are functions generated at runtime without world-age
1513
issues and with the full performance of a standard Julia anonymous function. This
1614
builds functions in a way that avoids `eval`.
@@ -37,7 +35,7 @@ using RuntimeGeneratedFunctions
3735
RuntimeGeneratedFunctions.init(@__MODULE__)
3836

3937
function no_worldage()
40-
ex = :(function f(_du,_u,_p,_t)
38+
ex = :(function f(_du, _u, _p, _t)
4139
@inbounds _du[1] = _u[1]
4240
@inbounds _du[2] = _u[2]
4341
nothing
@@ -47,7 +45,7 @@ function no_worldage()
4745
u = rand(2)
4846
p = nothing
4947
t = nothing
50-
f1(du,u,p,t)
48+
f1(du, u, p, t)
5149
end
5250
no_worldage()
5351
```
@@ -62,9 +60,9 @@ to the `@RuntimeGeneratedFunction` constructor. For example
6260
RuntimeGeneratedFunctions.init(@__MODULE__)
6361

6462
module A
65-
using RuntimeGeneratedFunctions
66-
RuntimeGeneratedFunctions.init(A)
67-
helper_function(x) = x + 1
63+
using RuntimeGeneratedFunctions
64+
RuntimeGeneratedFunctions.init(A)
65+
helper_function(x) = x + 1
6866
end
6967

7068
function g()
@@ -93,13 +91,13 @@ RuntimeGeneratedFunctions.init(@__MODULE__)
9391
# Imagine HelperModule is in a separate package and will be precompiled
9492
# separately.
9593
module HelperModule
96-
using RuntimeGeneratedFunctions
97-
RuntimeGeneratedFunctions.init(HelperModule)
94+
using RuntimeGeneratedFunctions
95+
RuntimeGeneratedFunctions.init(HelperModule)
9896

99-
function construct_rgf(cache_module, context_module, ex)
100-
ex = :((x)->$ex^2 + x)
101-
RuntimeGeneratedFunction(cache_module, context_module, ex)
102-
end
97+
function construct_rgf(cache_module, context_module, ex)
98+
ex = :((x) -> $ex^2 + x)
99+
RuntimeGeneratedFunction(cache_module, context_module, ex)
100+
end
103101
end
104102

105103
function g()
@@ -112,4 +110,3 @@ end
112110
f = g()
113111
@show f(1)
114112
```
115-

docs/make.jl

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,25 @@ cp("./docs/Manifest.toml", "./docs/src/assets/Manifest.toml", force = true)
55
cp("./docs/Project.toml", "./docs/src/assets/Project.toml", force = true)
66

77
makedocs(sitename = "RuntimeGeneratedFunctions.jl",
8-
authors = "Chris Rackauckas",
9-
modules = [RuntimeGeneratedFunctions],
10-
clean = true, doctest = false,
11-
strict = [
12-
:doctest,
13-
:linkcheck,
14-
:parse_error,
15-
:example_block,
16-
# Other available options are
17-
# :autodocs_block, :cross_references, :docs_block, :eval_block, :example_block, :footnote, :meta_block, :missing_docs, :setup_block
18-
],
19-
format = Documenter.HTML(analytics = "UA-90474609-3",
20-
assets = ["assets/favicon.ico"],
21-
canonical = "https://docs.sciml.ai/RuntimeGeneratedFunctions/stable/"),
22-
pages = [
23-
"RuntimeGeneratedFunctions.jl: Efficient Staged Compilation" => "index.md",
24-
])
8+
authors = "Chris Rackauckas",
9+
modules = [RuntimeGeneratedFunctions],
10+
clean = true, doctest = false, linkcheck = true,
11+
strict = [
12+
:doctest,
13+
:linkcheck,
14+
:parse_error,
15+
:example_block,
16+
:cross_references,
17+
# Other available options are
18+
# :autodocs_block, :cross_references, :docs_block, :eval_block, :example_block, :footnote, :meta_block, :missing_docs, :setup_block
19+
],
20+
format = Documenter.HTML(analytics = "UA-90474609-3",
21+
assets = ["assets/favicon.ico"],
22+
canonical = "https://docs.sciml.ai/RuntimeGeneratedFunctions/stable/"),
23+
pages = [
24+
"RuntimeGeneratedFunctions.jl: Efficient Staged Compilation" => "index.md",
25+
"API" => "api.md",
26+
])
2527

2628
deploydocs(;
27-
repo = "github.com/SciML/RuntimeGeneratedFunctions.jl")
29+
repo = "github.com/SciML/RuntimeGeneratedFunctions.jl")

docs/src/api.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# API
2+
3+
```@autodocs
4+
Modules = [RuntimeGeneratedFunctions]
5+
```

docs/src/index.md

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ using RuntimeGeneratedFunctions
2626
RuntimeGeneratedFunctions.init(@__MODULE__)
2727

2828
function no_worldage()
29-
ex = :(function f(_du,_u,_p,_t)
29+
ex = :(function f(_du, _u, _p, _t)
3030
@inbounds _du[1] = _u[1]
3131
@inbounds _du[2] = _u[2]
3232
nothing
@@ -36,24 +36,24 @@ function no_worldage()
3636
u = rand(2)
3737
p = nothing
3838
t = nothing
39-
f1(du,u,p,t)
39+
f1(du, u, p, t)
4040
end
4141
no_worldage()
4242
```
4343

4444
## Changing how global symbols are looked up
4545

4646
If you want to use helper functions or global variables from a different
47-
module within your function expression you'll need to pass a `context_module`
47+
module within your function expression, you'll need to pass a `context_module`
4848
to the `@RuntimeGeneratedFunction` constructor. For example
4949

5050
```julia
5151
RuntimeGeneratedFunctions.init(@__MODULE__)
5252

5353
module A
54-
using RuntimeGeneratedFunctions
55-
RuntimeGeneratedFunctions.init(A)
56-
helper_function(x) = x + 1
54+
using RuntimeGeneratedFunctions
55+
RuntimeGeneratedFunctions.init(A)
56+
helper_function(x) = x + 1
5757
end
5858

5959
function g()
@@ -66,12 +66,12 @@ end
6666

6767
## Precompilation and setting the function expression cache
6868

69-
For technical reasons RuntimeGeneratedFunctions needs to cache the function
69+
For technical reasons, RuntimeGeneratedFunctions needs to cache the function
7070
expression in a global variable within some module. This is normally
7171
transparent to the user, but if the `RuntimeGeneratedFunction` is evaluated
7272
during module precompilation, the cache module must be explicitly set to the
7373
module currently being precompiled. This is relevant for helper functions in
74-
some module which construct a RuntimeGeneratedFunction on behalf of the user.
74+
some module, which construct a RuntimeGeneratedFunction on behalf of the user.
7575
For example, in the following code, any third party user of
7676
`HelperModule.construct_rgf()` user needs to pass their own module as the
7777
`cache_module` if they want the returned function to work after precompilation:
@@ -82,13 +82,13 @@ RuntimeGeneratedFunctions.init(@__MODULE__)
8282
# Imagine HelperModule is in a separate package and will be precompiled
8383
# separately.
8484
module HelperModule
85-
using RuntimeGeneratedFunctions
86-
RuntimeGeneratedFunctions.init(HelperModule)
85+
using RuntimeGeneratedFunctions
86+
RuntimeGeneratedFunctions.init(HelperModule)
8787

88-
function construct_rgf(cache_module, context_module, ex)
89-
ex = :((x)->$ex^2 + x)
90-
RuntimeGeneratedFunction(cache_module, context_module, ex)
91-
end
88+
function construct_rgf(cache_module, context_module, ex)
89+
ex = :((x) -> $ex^2 + x)
90+
RuntimeGeneratedFunction(cache_module, context_module, ex)
91+
end
9292
end
9393

9494
function g()
@@ -103,56 +103,72 @@ f = g()
103103
```
104104

105105
## Reproducibility
106+
106107
```@raw html
107108
<details><summary>The documentation of this SciML package was built using these direct dependencies,</summary>
108109
```
110+
109111
```@example
110112
using Pkg # hide
111113
Pkg.status() # hide
112114
```
115+
113116
```@raw html
114117
</details>
115118
```
119+
116120
```@raw html
117121
<details><summary>and using this machine and Julia version.</summary>
118122
```
123+
119124
```@example
120125
using InteractiveUtils # hide
121126
versioninfo() # hide
122127
```
128+
123129
```@raw html
124130
</details>
125131
```
132+
126133
```@raw html
127134
<details><summary>A more complete overview of all dependencies and their versions is also provided.</summary>
128135
```
136+
129137
```@example
130138
using Pkg # hide
131-
Pkg.status(;mode = PKGMODE_MANIFEST) # hide
139+
Pkg.status(; mode = PKGMODE_MANIFEST) # hide
132140
```
141+
133142
```@raw html
134143
</details>
135144
```
145+
136146
```@raw html
137147
You can also download the
138148
<a href="
139149
```
150+
140151
```@eval
141152
using TOML
142-
version = TOML.parse(read("../../Project.toml",String))["version"]
143-
name = TOML.parse(read("../../Project.toml",String))["name"]
144-
link = "https://github.com/SciML/"*name*".jl/tree/gh-pages/v"*version*"/assets/Manifest.toml"
153+
version = TOML.parse(read("../../Project.toml", String))["version"]
154+
name = TOML.parse(read("../../Project.toml", String))["name"]
155+
link = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
156+
"/assets/Manifest.toml"
145157
```
158+
146159
```@raw html
147160
">manifest</a> file and the
148161
<a href="
149162
```
163+
150164
```@eval
151165
using TOML
152-
version = TOML.parse(read("../../Project.toml",String))["version"]
153-
name = TOML.parse(read("../../Project.toml",String))["name"]
154-
link = "https://github.com/SciML/"*name*".jl/tree/gh-pages/v"*version*"/assets/Project.toml"
166+
version = TOML.parse(read("../../Project.toml", String))["version"]
167+
name = TOML.parse(read("../../Project.toml", String))["name"]
168+
link = "https://github.com/SciML/" * name * ".jl/tree/gh-pages/v" * version *
169+
"/assets/Project.toml"
155170
```
171+
156172
```@raw html
157173
">project</a> file.
158-
```
174+
```

0 commit comments

Comments
 (0)