# How to get the "automatic documentation text" when documentation has been defined?

**URL:** https://discourse.julialang.org/t/how-to-get-the-automatic-documentation-text-when-documentation-has-been-defined/59258
**Category:** General Usage
**Created:** [April 14, 2021, 8:35am UTC](https://discourse.julialang.org/t/how-to-get-the-automatic-documentation-text-when-documentation-has-been-defined/59258 "2021-04-14T08:35:09Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![maajdl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maajdl/32/22838_2.png) [@maajdl](https://discourse.julialang.org/u/maajdl)
#### Post date: [April 14, 2021, 8:35am UTC](https://discourse.julialang.org/t/how-to-get-the-automatic-documentation-text-when-documentation-has-been-defined/59258/1 "2021-04-14T08:35:09Z")

</div>

Hello

I do like the **automatically generated documentation** like this:

```julia
No documentation found.

ThinkWare.idea is a Function.

# 6 methods for generic function "idea":
[1] idea(mx::Mixture) in ThinkWare at C:\Users\Rodin\ThinkWare\src\ideas.jl:66
[2] idea(su::Substance) in ThinkWare at C:\Users\Rodin\ThinkWare\src\ideas.jl:60
[3] idea(su::Substance, T) in ThinkWare at C:\Users\Rodin\ThinkWare\src\ideas.jl:60
[4] idea(su::Substance, T, p) in ThinkWare at C:\Users\Rodin\ThinkWare\src\ideas.jl:60
[5] idea(mx::Mixture, T) in ThinkWare at C:\Users\Rodin\ThinkWare\src\ideas.jl:72
[6] idea(mx::Mixture, T, p) in ThinkWare at C:\Users\Rodin\ThinkWare\src\ideas.jl:72

```

When I create my own documentation, using Docs.getdoc(…), how can I arrange to automatically append the **automatically generated documentation**?  
Is there a function returning this **automatically generated documentation** without caring for existing documentation?

Thanks

Michel

---

<div class="post-metadata">

### Author: ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)
#### Post date: [April 14, 2021, 9:38am UTC](https://discourse.julialang.org/t/how-to-get-the-automatic-documentation-text-when-documentation-has-been-defined/59258/2 "2021-04-14T09:38:37Z")

</div>

> [@maajdl](#):
>
> When I create my own documentation, using Docs.getdoc(…), how can I arrange to automatically append the **automatically generated documentation**?

Perhaps [`METHODLIST`](https://juliadocs.github.io/DocStringExtensions.jl/stable/#DocStringExtensions.METHODLIST) or [`SIGNATURES`](https://juliadocs.github.io/DocStringExtensions.jl/stable/#DocStringExtensions.SIGNATURES) from [DocStringExtensions.jl](https://github.com/JuliaDocs/DocStringExtensions.jl) fits your needs?

* * *

However, if you want output more similar to what `methods(f)` give in the Julia REPL as part of your docstrings you can define your own abbreviation, for example like this:

```julia
using DocStringExtensions

struct Methods <: DocStringExtensions.Abbreviation end
const METHODS = Methods()
function DocStringExtensions.format(::Methods, buf, doc)
    binding = doc.data[:binding]
    func = Docs.resolve(binding)
    ml = methods(func)
    io = IOBuffer()
    show(io, MIME"text/plain"(), ml)
    el = eachline(seekstart(io))
    x = iterate(el)
    x === nothing && return ""
    io2 = IOBuffer()
    l1, s = x
    # First line is "# N methods for ..."
    println(io2, chop(l1, head=2, tail=0))
    x = iterate(el, s)
    while x !== nothing
        l, s = x
        m = match(r"\[\d+\] (.*)", l)
        println(io2, " - ", m[1])
        x = iterate(el, s)
    end
    return print(buf, strip(String(take!(io2))))
end

```

Example:

```julia
f(x) = 1
f(x::Int) = 2
f(x::Float64) = 3

"""
    f(x)

Do stuff.

$(METHODS)
"""
f

```

which gives

```shell
help?> f
search: f fd for fma fld fld1 fill fdio frexp foldr foldl flush floor float first fill!

  f(x)

  Do stuff

  3 methods for generic function "f":

    • f(x::Int64) in Main at /Users/fredrik/dev/DocStringExtensions/test.jl:31

    • f(x::Float64) in Main at /Users/fredrik/dev/DocStringExtensions/test.jl:32

    • f(x) in Main at /Users/fredrik/dev/DocStringExtensions/test.jl:30

```

---

<div class="post-metadata">

### Author: ![maajdl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maajdl/32/22838_2.png) [@maajdl](https://discourse.julialang.org/u/maajdl)
#### Post date: [April 14, 2021, 10:32am UTC](https://discourse.julialang.org/t/how-to-get-the-automatic-documentation-text-when-documentation-has-been-defined/59258/3 "2021-04-14T10:32:02Z")

</div>

Thanks.  
Good solution to simply use methods.  
Michel
