# Best way to extend a type doc string

**URL:** https://discourse.julialang.org/t/best-way-to-extend-a-type-doc-string/76878
**Category:** General Usage
**Created:** [February 22, 2022, 3:58am UTC](https://discourse.julialang.org/t/best-way-to-extend-a-type-doc-string/76878 "2022-02-22T03:58:17Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![ablaom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ablaom/32/4889_2.png) [@ablaom](https://discourse.julialang.org/u/ablaom)
#### Post date: [February 22, 2022, 3:58am UTC](https://discourse.julialang.org/t/best-way-to-extend-a-type-doc-string/76878/1 "2022-02-22T03:58:17Z")

</div>

Pkg A defines some type `Foo`, and this includes the declaration of a document string.  
Pkg B extends the functionality of `Foo` objects and wants to _extend_, not replace, the type’s docstring.

What’s a clean way to do this?

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [February 22, 2022, 4:29am UTC](https://discourse.julialang.org/t/best-way-to-extend-a-type-doc-string/76878/2 "2022-02-22T04:29:48Z")

</div>

“it just works”

```julia
julia> module A
           """
           docstring in A
           """
           struct aa end
       end
Main.A

help?> Main.A.aa
  docstring in A

julia> module B
           using Main.A
           """
           docstring in B
           """
           Main.A.aa
       end
Main.B

help?> Main.A.aa
  docstring in A

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

  docstring in B

```

---

<div class="post-metadata">

### Author: ![ablaom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ablaom/32/4889_2.png) [@ablaom](https://discourse.julialang.org/u/ablaom)
#### Post date: [February 22, 2022, 5:49am UTC](https://discourse.julialang.org/t/best-way-to-extend-a-type-doc-string/76878/3 "2022-02-22T05:49:08Z")

</div>

Great. That answers the question that I posed!

But what if I want to do the extension in the same module. That does not “just work”, right?

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [February 22, 2022, 5:50am UTC](https://discourse.julialang.org/t/best-way-to-extend-a-type-doc-string/76878/4 "2022-02-22T05:50:25Z")

</div>

It should just work, much like you can have separate docstring for each method and they all show up

---

<div class="post-metadata">

### Author: ![ablaom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ablaom/32/4889_2.png) [@ablaom](https://discourse.julialang.org/u/ablaom)
#### Post date: [February 22, 2022, 6:01am UTC](https://discourse.julialang.org/t/best-way-to-extend-a-type-doc-string/76878/5 "2022-02-22T06:01:00Z")

</div>

It doesn’t seem to work:

```julia
"""
line 1
"""
struct Goo end

julia> @doc Goo   
  line 1

# now add post facto:
@doc """line2""" Goo

julia> @doc Goo
   line 2

```

“line 1” has been replaced.

What am I missing?

---

<div class="post-metadata">

### Author: ![Ralph\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ralph_smith/32/10344_2.png) [@Ralph\_Smith](https://discourse.julialang.org/u/Ralph_Smith)
#### Post date: [February 25, 2022, 4:43am UTC](https://discourse.julialang.org/t/best-way-to-extend-a-type-doc-string/76878/6 "2022-02-25T04:43:15Z")

</div>

1. a docstring is registered in the module where it is defined.
2. only one docstring in a module is associated with a (function/type, signature) pair  
a. defining another one replaces the incumbent.
3. a docstring for a bare type has a null signature (i.e., `Union{}`)  
a. constructors can add new docstrings.
