Docstring on multiple lines with a module that does not import Core and Base

I’m working on a module that does not import Core and Base to test a functionality.

I’ve tried adding docstrings to the function the naive way, which I call “naive” because it doesn’t allow me the option of dispatching the docstrings. As an example:

julia> math = Module(:math, false, false)
Main.math

julia> @eval math add(x, y::$Signed) = $(+)(x, y)
add (generic function with 1 method)

julia> @doc """
           add(x, y::Signed)

       This sums up `x` and the `Signed` integer
       `y` and returns the result.
       """
       math.add
Main.math.add

julia> @eval math add(x, y::$Unsigned) = $(+)(x, y)
add (generic function with 2 methods)

julia> @doc """
           add(x, y::Unsigned)

       This sums up `x` and the `Unsigned` integer
       `y` and returns the result.
       """
       math.add
Main.math.add

help?> math.add
  add(x, y::Unsigned)

  This sums up x and the Unsigned integer y and returns the result.

The above is not what I want. I’ve tried doing it the other way of using what I think will work but I don’t understand the Tuple error message:

julia> math = Module(:math, false, false)
Main.math

julia> @eval math begin 
           """
               add(x, y::Signed)
           
           This sums up `x` and the `Signed` integer
           `y`, and returns the result.
           """
           add(x, y::$Signed) = $(+)(x, y)
           
           """
               add(x, y::Unsigned)
               
           This sums up `x` and the `Unsigned` integer
           `y`, and returns the result.
           """ 
           add(x, y::$Unsigned) = $(+)(x, y)
       end
ERROR: UndefVarError: Tuple not defined

I’d import Tuple it still didn’t work. What way is there to solve this, so I can dispatch the docstrings? I still don’t want to import Core and Base, so baremodule isn’t an option.

math.add needs to be on the same line as the end quote, otherwise it won’t be parsed as an argument to the @doc macro.

I did as you’ve just said and it doesn’t some the issue one bit.

julia> @doc """
           add(x, y::Signed)

       This sums up `x` and the `Signed` integer
       `y` and returns the result.
       """ math.add
Main.math.add

julia> @doc """
           add(x, y::Unsigned)

       This sums up `x` and the `Unsigned` integer
       `y` and returns the result.
       """ math.add
Main.math.add

help?> math.add
  add(x, y::Unsigned)

  This sums up x and the Unsigned integer y and returns the result.

What I want to know is the Tuple error and how do I go about solving it so I can dispatch the docstrings from the second example I provided?

What’s the problem? You are getting the docstring you asked for, no? (Realize that, by default, docstrings are interpreted using text/markdown formatting, which re-wraps paragraphs for you.
You can alternatively use a unformatted text/plain docstring by wrapping the docstring in a Text("...") object.)

You didn’t read my write up @stevengj . That is not what I want. I only provided that as the only solution I know of.

This is what I want:

julia> math = Module(:math, false, false)
Main.math

julia> @eval math begin 
           """
               add(x, y::Signed)
           
           This sums up `x` and the `Signed` integer
           `y`, and returns the result.
           """
           add(x, y::$Signed) = $(+)(x, y)
           
           """
               add(x, y::Unsigned)
               
           This sums up `x` and the `Unsigned` integer
           `y`, and returns the result.
           """ 
           add(x, y::$Unsigned) = $(+)(x, y)
       end
ERROR: UndefVarError: Tuple not defined

But then I ask how do I go about the Tuple error since its not something I understand.

julia> @doc """
           add(x, y::Signed)

       This sums up `x` and the `Signed` integer
       `y` and returns the result.
       """
       math.add(x, y::Signed)
Main.math.add

julia> @eval math add(x, y::$Unsigned) = $(+)(x, y)
add (generic function with 2 methods)

julia> @doc """
           add(x, y::Unsigned)

       This sums up `x` and the `Unsigned` integer
       `y` and returns the result.
       """
       math.add(x, y::Unsigned)
Main.math.add

help?> math.add
  add(x, y::Signed)

  This sums up x and the Signed integer y and returns the result.

  ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

  add(x, y::Unsigned)

  This sums up x and the Unsigned integer y and returns the result.

Already found the solution on slack, but you neatly gave it @digital_carver . Thank you