Skip to content

Commit

Permalink
Fix escaping of docstring in @__DIR__ (#53225)
Browse files Browse the repository at this point in the history
This issue was introduced in #52442.
The markdown parser had issues with the triple-quotes.
Usually you can use quadruple-quotes to fix this, but
this does not appear to be supported, so we escape
each with backslash.

Here is the corrected docstring rendered:

```julia-repl
help?> @__DIR__
  @__DIR__ -> String

  Macro to obtain the absolute path of the current directory as a string.

  If in a script, returns the directory of the script containing the @__DIR__ macrocall. If run from a REPL or if
  evaluated by julia -e <expr>, returns the current working directory.

  Example
  ≡≡≡≡≡≡≡

  The example illustrates the difference in the behaviors of @__DIR__ and pwd(), by creating a simple script in a
  different directory than the current working one and executing both commands:

  julia> cd("/home/JuliaUser") # working directory

  julia> # create script at /home/JuliaUser/Projects
         open("/home/JuliaUser/Projects/test.jl","w") do io
             print(io, """
                 println("@__DIR__ = ", @__DIR__)
                 println("pwd() = ", pwd())
             """)
         end

  julia> # outputs script directory and current working directory
         include("/home/JuliaUser/Projects/test.jl")
  @__DIR__ = /home/JuliaUser/Projects
  pwd() = /home/JuliaUser
```
  • Loading branch information
sjkelly committed Feb 7, 2024
1 parent 41bbfb4 commit d453af8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3548,10 +3548,10 @@ julia> cd("/home/JuliaUser") # working directory
julia> # create script at /home/JuliaUser/Projects
open("/home/JuliaUser/Projects/test.jl","w") do io
print(io, """
print(io, \"\"\"
println("@__DIR__ = ", @__DIR__)
println("pwd() = ", pwd())
""")
\"\"\")
end
julia> # outputs script directory and current working directory
Expand Down

0 comments on commit d453af8

Please sign in to comment.