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

**URL:** <https://discourse.julialang.org/t/docstring-on-multiple-lines-with-a-module-that-does-not-import-core-and-base/86799>\
**Category:** General Usage\
**Tags:** module\
**Created:** [September 5, 2022, 1:07pm UTC](https://discourse.julialang.org/t/docstring-on-multiple-lines-with-a-module-that-does-not-import-core-and-base/86799 "2022-09-05T13:07:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![uje](https://avatars.discourse-cdn.com/v4/letter/u/5f9b8f/32.png) [@uje](https://discourse.julialang.org/u/uje)\
**Post date:** [September 5, 2022, 1:07pm UTC](https://discourse.julialang.org/t/docstring-on-multiple-lines-with-a-module-that-does-not-import-core-and-base/86799/1 "2022-09-05T13:07:59Z")

</div>

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
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
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.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [September 5, 2022, 1:19pm UTC](https://discourse.julialang.org/t/docstring-on-multiple-lines-with-a-module-that-does-not-import-core-and-base/86799/2 "2022-09-05T13:19:41Z")

</div>

> [@uje](#):
>
> ```julia
> julia> @doc """
> add(x, y::Unsigned)
> 
> This sums up `x` and the `Unsigned` integer
> `y` and returns the result.
> """
> math.add
> Main.math.add
> 
> ```

`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.

---

<div class="post-metadata">

**Author:** ![uje](https://avatars.discourse-cdn.com/v4/letter/u/5f9b8f/32.png) [@uje](https://discourse.julialang.org/u/uje)\
**Post date:** [September 5, 2022, 1:23pm UTC](https://discourse.julialang.org/t/docstring-on-multiple-lines-with-a-module-that-does-not-import-core-and-base/86799/3 "2022-09-05T13:23:03Z")

</div>

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

```julia
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.

```

---

<div class="post-metadata">

**Author:** ![uje](https://avatars.discourse-cdn.com/v4/letter/u/5f9b8f/32.png) [@uje](https://discourse.julialang.org/u/uje)\
**Post date:** [September 5, 2022, 1:24pm UTC](https://discourse.julialang.org/t/docstring-on-multiple-lines-with-a-module-that-does-not-import-core-and-base/86799/4 "2022-09-05T13:24:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [September 5, 2022, 1:41pm UTC](https://discourse.julialang.org/t/docstring-on-multiple-lines-with-a-module-that-does-not-import-core-and-base/86799/5 "2022-09-05T13:41:38Z")

</div>

> [@uje](#):
>
> ```julia
> help?> math.add
> add(x, y::Unsigned)
> 
> This sums up x and the Unsigned integer y and returns the result.
> 
> ```

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.)

---

<div class="post-metadata">

**Author:** ![uje](https://avatars.discourse-cdn.com/v4/letter/u/5f9b8f/32.png) [@uje](https://discourse.julialang.org/u/uje)\
**Post date:** [September 5, 2022, 2:10pm UTC](https://discourse.julialang.org/t/docstring-on-multiple-lines-with-a-module-that-does-not-import-core-and-base/86799/6 "2022-09-05T14:10:33Z")

</div>

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
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.

---

<div class="post-metadata">

**Author:** ![digital\_carver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/digital_carver/32/33818_2.png) [@digital\_carver](https://discourse.julialang.org/u/digital_carver)\
**Post date:** [September 5, 2022, 3:04pm UTC](https://discourse.julialang.org/t/docstring-on-multiple-lines-with-a-module-that-does-not-import-core-and-base/86799/7 "2022-09-05T15:04:19Z")

</div>

```julia
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.

```

---

<div class="post-metadata">

**Author:** ![uje](https://avatars.discourse-cdn.com/v4/letter/u/5f9b8f/32.png) [@uje](https://discourse.julialang.org/u/uje)\
**Post date:** [September 5, 2022, 7:33pm UTC](https://discourse.julialang.org/t/docstring-on-multiple-lines-with-a-module-that-does-not-import-core-and-base/86799/8 "2022-09-05T19:33:59Z")

</div>

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