Constants

Module

Constants

Macros

PDFHighlights.Internal.Constants.@constantMacro
@constant(name::Symbol, docstring::String, value::Union{Expr, String}) -> Expr

Create a constant with a documentation string and export it.

Arguments

  • name::Symbol: name of the constant
  • docstring::String: documentation string
  • value::Union{Expr, String}: value of the constant

Returns

  • Expr: constant definition

Example

using PDFHighlights
using Suppressor
using SyntaxTree

name = :CONSTANT_NAME
docstring = "Docstring"
value = "Value"

d1 = @capture_out @macroexpand(
    PDFHighlights.Internal.Constants.@constant(
        CONSTANT_NAME,
        "Docstring",
        "Value"
    )
) |> linefilter! |> dump

macro oof()
    return esc(
        quote
            @doc $(docstring)
            const $(name) = $(value)
            export $(name)
        end
    )
end

d2 = @capture_out @macroexpand(@oof) |> linefilter! |> dump

d1 == d2
source