Skip to content

Commit 0f9e836

Browse files
authored
Support configuration with a config::Dict kwarg. (#83)
1 parent d3dc7c2 commit 0f9e836

4 files changed

Lines changed: 143 additions & 120 deletions

File tree

docs/Manifest.toml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,9 @@ version = "0.8.1"
5858

5959
[[Documenter]]
6060
deps = ["Base64", "Dates", "DocStringExtensions", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
61-
git-tree-sha1 = "fb16819c1bcf5e99b8e316e329e5e0958550334e"
62-
repo-rev = "master"
63-
repo-url = "https://github.com/JuliaDocs/Documenter.jl.git"
61+
git-tree-sha1 = "0e52069b5970cb27234153f578227947565152c5"
6462
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
65-
version = "0.24.0-DEV"
63+
version = "0.24.0"
6664

6765
[[FFMPEG]]
6866
deps = ["BinaryProvider", "Libdl"]
@@ -116,7 +114,7 @@ uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
116114
deps = ["Base64", "JSON", "REPL"]
117115
path = ".."
118116
uuid = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
119-
version = "2.1.0"
117+
version = "2.1.1"
120118

121119
[[Logging]]
122120
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
@@ -153,12 +151,12 @@ version = "1.1.0"
153151

154152
[[Parsers]]
155153
deps = ["Dates", "Test"]
156-
git-tree-sha1 = "a23968e107c0544aca91bfab6f7dd34de1206a54"
154+
git-tree-sha1 = "0139ba59ce9bc680e2925aec5b7db79065d60556"
157155
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
158-
version = "0.3.9"
156+
version = "0.3.10"
159157

160158
[[Pkg]]
161-
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
159+
deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
162160
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
163161

164162
[[PlotThemes]]

docs/make.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,24 @@ Literate.script(EXAMPLE, OUTPUT, preprocess = preprocess)
2020

2121
# generate the example notebook for the documentation, keep in sync with outputformats.md
2222
Literate.markdown(joinpath(@__DIR__, "src/outputformats.jl"), OUTPUT; credit = false, name = "name")
23-
Literate.notebook(joinpath(@__DIR__, "src/outputformats.jl"), OUTPUT, name = "notebook")
24-
Literate.script(joinpath(@__DIR__, "src/outputformats.jl"), OUTPUT, credit = false)
25-
26-
# replace the link in outputformats.md
27-
travis_tag = get(ENV, "TRAVIS_TAG", "")
28-
folder = isempty(travis_tag) ? "latest" : travis_tag
29-
url = "https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/$(folder)/"
30-
if get(ENV, "HAS_JOSH_K_SEAL_OF_APPROVAL", "") == "true"
31-
str = read(joinpath(@__DIR__, "src/outputformats.md"), String)
32-
str = replace(str, "[notebook.ipynb](generated/notebook.ipynb)." => "[notebook.ipynb]($(url)generated/notebook.ipynb).")
33-
write(joinpath(@__DIR__, "src/outputformats.md"), str)
34-
end
23+
Literate.notebook(joinpath(@__DIR__, "src/outputformats.jl"), OUTPUT; name = "notebook")
24+
Literate.script(joinpath(@__DIR__, "src/outputformats.jl"), OUTPUT; credit = false)
25+
26+
# # replace the link in outputformats.md
27+
# travis_tag = get(ENV, "TRAVIS_TAG", "")
28+
# folder = isempty(travis_tag) ? "latest" : travis_tag
29+
# url = "https://nbviewer.jupyter.org/github/fredrikekre/Literate.jl/blob/gh-pages/$(folder)/"
30+
# if get(ENV, "HAS_JOSH_K_SEAL_OF_APPROVAL", "") == "true"
31+
# str = read(joinpath(@__DIR__, "src/outputformats.md"), String)
32+
# str = replace(str, "[notebook.ipynb](generated/notebook.ipynb)." => "[notebook.ipynb]($(url)generated/notebook.ipynb).")
33+
# write(joinpath(@__DIR__, "src/outputformats.md"), str)
34+
# end
3535

3636

3737
makedocs(
3838
format = Documenter.HTML(
3939
assets = ["assets/custom.css"],
40-
40+
prettyurls = haskey(ENV, "GITHUB_ACTIONS"),
4141
),
4242
modules = [Literate],
4343
sitename = "Literate.jl",

docs/src/outputformats.md

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ and see how this is rendered in each of the output formats.
1212

1313
## [**4.1.** Markdown Output](@id Markdown-Output)
1414

15-
The (default) markdown output of the source snippet above is as follows
15+
Markdown output is generated by [`Literate.markdown`](@ref). The (default) markdown output
16+
of the source snippet above is as follows:
1617

1718
```@eval
1819
import Markdown
@@ -28,24 +29,25 @@ an `@meta` block have been added, that sets the `EditURL` variable. This is used
2829
by Documenter to redirect the "Edit on GitHub" link for the page,
2930
see [Interaction with Documenter](@ref).
3031

31-
Some of the output rendering can be controlled with keyword arguments to
32-
[`Literate.markdown`](@ref):
32+
See the section about [Configuration](@ref) for how to configure the behavior and resulting
33+
output of [`Literate.markdown`](@ref).
3334

3435
```@docs
3536
Literate.markdown
3637
```
3738

3839
## [**4.2.** Notebook Output](@id Notebook-Output)
3940

40-
The (default) notebook output of the source snippet can be seen here:
41-
[notebook.ipynb](generated/notebook.ipynb).
41+
Notebook output is generated by [`Literate.notebook`](@ref). The (default) notebook output
42+
of the source snippet can be seen here: [notebook.ipynb](generated/notebook.ipynb).
4243

4344
We note that lines starting with `# ` are placed in markdown cells,
4445
and the code lines have been placed in code cells. By default the notebook
4546
is also executed and output cells populated. The current working directory
4647
is set to the specified output directory the notebook is executed.
47-
Some of the output rendering can be controlled with keyword
48-
arguments to [`Literate.notebook`](@ref):
48+
49+
See the section about [Configuration](@ref) for how to configure the behavior and resulting
50+
output of [`Literate.notebook`](@ref).
4951

5052
```@docs
5153
Literate.notebook
@@ -70,7 +72,8 @@ and the [reveal.js](https://github.com/hakimel/reveal.js) notebook extension
7072

7173
## [**4.3.** Script Output](@id Script-Output)
7274

73-
The (default) script output of the source snippet above is as follows
75+
Script output is generated by [`Literate.script`](@ref). The (default) script output of the
76+
source snippet above is as follows:
7477

7578
```@eval
7679
import Markdown
@@ -81,9 +84,32 @@ Markdown.parse(str)
8184
```
8285

8386
We note that lines starting with `# ` are removed and only the
84-
code lines have been kept. Some of the output rendering can be controlled
85-
with keyword arguments to [`Literate.script`](@ref):
87+
code lines have been kept.
88+
89+
See the section about [Configuration](@ref) for how to configure the behavior and resulting
90+
output of [`Literate.script`](@ref).
8691

8792
```@docs
8893
Literate.script
8994
```
95+
96+
## [**4.4.** Configuration](@id Configuration)
97+
98+
The behavior of [`Literate.markdown`](@ref), [`Literate.notebook`](@ref) and
99+
[`Literate.script`](@ref) can be configured by keyword arguments. There are two
100+
ways to do this; pass `config::Dict` as a keyword argument, or pass individual
101+
keyword arguments.
102+
103+
!!! note "Configuration precedence"
104+
Individual keyword arguments takes precedence over the `config` dictionary, so for e.g.
105+
`Literate.markdown(...; config = Dict("name" => "hello"), name = "world")` the
106+
resulting configuration for `name` will be `"world"`. Both individual keyword arguments
107+
and the `config` dictionary takes precedence over the default.
108+
109+
Available configurations with description and default values are given in the reference for
110+
[`Literate.DEFAULT_CONFIGURATION`](@ref) just below.
111+
112+
113+
```@docs
114+
Literate.DEFAULT_CONFIGURATION
115+
```

0 commit comments

Comments
 (0)