DocStringExtensions - interpolation string "$" allowed only in the preamble but not inside the structure

I would like to pass a function to some docstrings inside a structure (by using $) not only in the preamble as in the example.

works without $ inside the structure

using Parameters, DocStringExtensions

"""
# My parameter preamble
These parameters are in use at $(pwd())...
# Fields
$(TYPEDFIELDS)
"""
@with_kw struct params
	# Parameters definition
	""" this is a Float"""
	a  ::Float64	=  1.
end

output in Atom by typing ?params

help?> params
search: params Parameters @pack_params @unpack_params partialsortperm partialsortperm!

  My parameter preamble
  ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
  These parameters are in use at C:\Users\yrodrigu\synapse\Merge...
  Fields
  ≡≡≡≡≡≡≡≡
    •    a::Float64
        this is a Float Default: 1.0

However, if $(pwd()) is in a docstring inside the structure as in the example below an error message is shown.

using Parameters, DocStringExtensions

 """
 # My parameter preamble
 These parameters are in use at $(pwd()) ...
 # Fields
 $(TYPEDFIELDS)
 """
 @with_kw struct params
 	# Parameters definition
 	""" this is a Float $(pwd()) """
 	a  ::Float64 	= 1.
 end

ERROR MESSAGE:


Closest candidates are:
decolon2(!Matched::Symbol) at C:\Users\yrodrigu\.julia\packages\Parameters\l76EM\src\Parameters.jl:102
decolon2(!Matched::Expr) at C:\Users\yrodrigu\.julia\packages\Parameters\l76EM\src\Parameters.jl:101
in expression starting at C:\Users\yrodrigu\synapse\Merge\params_synapse.jl:522
in expression starting at C:\Users\yrodrigu\synapse\Merge\params_synapse.jl:513
in @doc at [base\boot.jl:461](#)
in at [DocStringExtensions\BEyNH\src\templates.jl:11](#)
in docm at [base\docs\Docs.jl:509](#)
in docm at [base\docs\Docs.jl:509](#)
in macroexpand at [base\expr.jl:106](#)
in #macroexpand#32 at [base\expr.jl:107](#)
in @with_kw at [Parameters\l76EM\src\Parameters.jl:631](#)
in with_kw at [Parameters\l76EM\src\Parameters.jl:442](#)

You can use @doc "...." object to have more control over the documentation string (which, in fact, can be an arbitrary object), including to do interpolation into the string.

2 Likes

thanks!