diff --git a/docs/make.jl b/docs/make.jl index b1459db..8e42332 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -13,8 +13,7 @@ EXAMPLE = joinpath(@__DIR__, "..", "examples", "example.jl") OUTPUT = joinpath(@__DIR__, "src/generated") function preprocess(str) - str = replace(str, "MYVARIABLE" => "z") - str = replace(str, "MYVALUE" => "1.0 + 2.0im") + str = replace(str, "x = 123" => "y = 321"; count=1) return str end diff --git a/examples/example.jl b/examples/example.jl index 6e12c0b..fcef7d7 100644 --- a/examples/example.jl +++ b/examples/example.jl @@ -87,11 +87,17 @@ plot(x, [y1, y2]) # ### Custom processing # # It is possible to give Literate custom pre- and post-processing functions. -# For example, here we insert two placeholders, which we will replace with -# something else at time of generation. We have here replaced our placeholders -# with `z` and `1.0 + 2.0im`: +# For example, here we insert a placeholder value `x = 123` in the source, and use a +# preprocessing function that replaces it with `y = 321` in the rendered output. -MYVARIABLE = MYVALUE +x = 123 + +# In this case the preprocessing function is defined by + +function pre(s::String) + s = replace(s, "x = 123" => "y = 321") + return s +end # ### [Documenter.jl interaction](@id documenter-interaction) #