# Generate doc string with function signature

**URL:** <https://discourse.julialang.org/t/generate-doc-string-with-function-signature/9073>\
**Category:** New to Julia\
**Tags:** documentation\
**Created:** [February 15, 2018, 1:54am UTC](https://discourse.julialang.org/t/generate-doc-string-with-function-signature/9073 "2018-02-15T01:54:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Post date:** [February 15, 2018, 1:54am UTC](https://discourse.julialang.org/t/generate-doc-string-with-function-signature/9073/1 "2018-02-15T01:54:17Z")

</div>

Hi there,

I think I heard something like this before but I don’t remember. Is there a package/tool that generates and include function signatures in the doc string? E.g.

```julia
"""
@sig
Basically, add `x` and `y` together.
"""
add_these(x::Float64, y::Float64) = x + y

```

turning into something like:

```julia
"""
add_these(x::Float64, y::Float64)::Float64

Basically, add `x` and `y` together.
"""
add_these(x::Float64, y::Float64) = x + y

```

---

<div class="post-metadata">

**Author:** ![mortenpi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mortenpi/32/158_2.png) [@mortenpi](https://discourse.julialang.org/u/mortenpi)\
**Post date:** [February 15, 2018, 2:03am UTC](https://discourse.julialang.org/t/generate-doc-string-with-function-signature/9073/2 "2018-02-15T02:03:29Z")

</div>

[DocStringExtensions](https://github.com/JuliaDocs/DocStringExtensions.jl) is what you’re looking for.

---

<div class="post-metadata">

**Author:** ![RaulDurand](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rauldurand/32/2044_2.png) [@RaulDurand](https://discourse.julialang.org/u/RaulDurand)\
**Post date:** [April 28, 2019, 3:35am UTC](https://discourse.julialang.org/t/generate-doc-string-with-function-signature/9073/3 "2019-04-28T03:35:23Z")

</div>

[DocStringExtensions](https://github.com/JuliaDocs/DocStringExtensions.jl) works great but it provides a list with signatures from all methods ( using `$(SIGNATURES)`).

Is there a way to add only the signature of the method being documented?

---

<div class="post-metadata">

**Author:** ![mortenpi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mortenpi/32/158_2.png) [@mortenpi](https://discourse.julialang.org/u/mortenpi)\
**Post date:** [April 28, 2019, 10:44pm UTC](https://discourse.julialang.org/t/generate-doc-string-with-function-signature/9073/4 "2019-04-28T22:44:56Z")

</div>

Not at the moment, but I would be happy to review a PR for that.

---

<div class="post-metadata">

**Author:** ![RaulDurand](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rauldurand/32/2044_2.png) [@RaulDurand](https://discourse.julialang.org/u/RaulDurand)\
**Post date:** [April 29, 2019, 10:31pm UTC](https://discourse.julialang.org/t/generate-doc-string-with-function-signature/9073/5 "2019-04-29T22:31:39Z")

</div>

I saw that DocStringExtensions uses the `methods` function which brings all signatures. I do not know how to get the signature from the current method. Actually, I do not know how to get a handle for the current method being documented.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [April 30, 2019, 6:41am UTC](https://discourse.julialang.org/t/generate-doc-string-with-function-signature/9073/6 "2019-04-30T06:41:18Z")

</div>

I think you can base most of the code on `SIGNATURES`, except instead of [getting all the methods](https://github.com/JuliaDocs/DocStringExtensions.jl/blob/25736c3cee2c099cdda5c32fd20bf2d9939d5ebb/src/abbreviations.jl#L292), just use the single one.

If you don’t want to do this, I can make a PR, I wanted this functionality too for a long time.

---

<div class="post-metadata">

**Author:** ![RaulDurand](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rauldurand/32/2044_2.png) [@RaulDurand](https://discourse.julialang.org/u/RaulDurand)\
**Post date:** [April 30, 2019, 11:30am UTC](https://discourse.julialang.org/t/generate-doc-string-with-function-signature/9073/7 "2019-04-30T11:30:33Z")

</div>

Please feel free to submit a PR.
