Skip to content

Commit

Permalink
Call abspath on the argument in the sandboxes include function.
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Feb 6, 2019
1 parent a4cd0b4 commit 97cb69c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion docs/src/man/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -486,6 +490,10 @@ julia> a + b

Named `@repl <name>` blocks behave in the same way as named `@example <name>` 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 <name>` block

These are similar to `@example` blocks, but both the input and output are hidden from the
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Expanders.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 97cb69c

Please sign in to comment.