diff --git a/CHANGELOG.md b/CHANGELOG.md index c9d3b2bac8..8e2afd6c9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ * ![Enhancement][badge-enhancement] The Markdown and LaTeX output writers can now handle multimedia output, such as images, from `@example` blocks. ([#938][github-938]) +* ![Bugfix][badge-bugfix] Paths in `include` calls in `@eval`, `@example`, `@repl` and `jldoctest` + blocks are now interpreted to be relative `pwd`, which is set to the output directory of the + resulting file. ([#941][github-941]) + ## Version `v0.21.2` * ![Bugfix][badge-bugfix] `linkcheck` now handles servers that do not support `HEAD` requests @@ -210,6 +214,7 @@ [github-934]: https://github.com/JuliaDocs/Documenter.jl/pull/934 [github-935]: https://github.com/JuliaDocs/Documenter.jl/pull/935 [github-938]: https://github.com/JuliaDocs/Documenter.jl/pull/938 +[github-941]: https://github.com/JuliaDocs/Documenter.jl/pull/941 [documenterlatex]: https://github.com/JuliaDocs/DocumenterLaTeX.jl [documentermarkdown]: https://github.com/JuliaDocs/DocumenterMarkdown.jl diff --git a/docs/src/man/syntax.md b/docs/src/man/syntax.md index c3a8a46993..d52a133c92 100644 --- a/docs/src/man/syntax.md +++ b/docs/src/man/syntax.md @@ -331,6 +331,10 @@ a + b Leading and trailing newlines are removed from the rendered code blocks. Trailing whitespace on each line is also removed. +!!! note + The working directory, `pwd`, is set to the directory in `build` where the file + will be written to, and the paths in `include` calls are interpreted to be relative to `pwd`. + **Hiding Source Code** Code blocks may have some content that does not need to be displayed in the final document. @@ -486,6 +490,10 @@ julia> a + b Named `@repl ` blocks behave in the same way as named `@example ` blocks. +!!! note + The working directory, `pwd`, is set to the directory in `build` where the file + will be written to, and the paths in `include` calls are interpreted to be relative to `pwd`. + ## `@setup ` block These are similar to `@example` blocks, but both the input and output are hidden from the @@ -548,7 +556,8 @@ Which will generate a markdown version of the CSV file table.csv and render it i Note that each `@eval` block evaluates its contents within a separate module. When evaluating each block the present working directory, `pwd`, is set to the directory in -`build` where the file will be written to. +`build` where the file will be written to, and the paths in `include` calls are interpreted +to be relative to `pwd`. Also, instead of returning `nothing` in the example above we could have returned a new `Markdown.MD` object through `Markdown.parse`. This can be more appropriate when the diff --git a/src/Expanders.jl b/src/Expanders.jl index 809a6d0fe6..54a678c0a1 100644 --- a/src/Expanders.jl +++ b/src/Expanders.jl @@ -694,7 +694,7 @@ function get_new_sandbox(name::Symbol) # eval(expr) is available in the REPL (i.e. Main) so we emulate that for the sandbox Core.eval(m, :(eval(x) = Core.eval($m, x))) # modules created with Module() does not have include defined - Core.eval(m, :(include(x) = Base.include($m, x))) + Core.eval(m, :(include(x) = Base.include($m, abspath(x)))) return m end