# Documenting a functor / callable struct

**URL:** <https://discourse.julialang.org/t/documenting-a-functor-callable-struct/8444>\
**Category:** General Usage\
**Tags:** functors\
**Created:** [January 18, 2018, 12:19am UTC](https://discourse.julialang.org/t/documenting-a-functor-callable-struct/8444 "2018-01-18T00:19:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmert](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmert/32/3161_2.png) [@jmert](https://discourse.julialang.org/u/jmert)\
**Post date:** [January 18, 2018, 12:19am UTC](https://discourse.julialang.org/t/documenting-a-functor-callable-struct/8444/1 "2018-01-18T00:19:20Z")

</div>

I’m interested in providing a docstring for a functor / callable struct I’m using, but I have to questions about that:

1. How do you correctly query for the doc string at the REPL? The `?MyFunc` (assuming code below) obviously shows the documentation for the struct, so how do you look for the callable method? (Guessing variations of something like `?(::MyFunc)` haven’t worked either.)
2. What’s the (probably related) syntax for making a reference in Documenter.jl’s Markdown?

Potentially related is the fact that I think there must be a bug in the current implementation — on both v0.6 and master, using the following file:

```julia
"""
Docs for `MyFunc` struct.
"""
mutable struct MyFunc
    x
end

"""
Docs for calling `f::MyFunc`.
"""
function (f::MyFunc)(x)
    f.x = x
    return f
end

```

including the file suggests the `f` symbol is being bound [somewhere] (based on the fact that it’s echoing the last thing in the file to the prompt) and trying to get help on whatever `f` is seems pretty ambiguous with both an error message _and_ the docstring I was hoping to find.

```julia
julia> include("functordoc.jl")
f

help?> f
search: fd for fma fld fft full fld1 find filt fill fft! fdio frexp foldr foldl flush floor float first findn filt! fill! fetch FFTW fldmod findnz findin filter falses finally foreach flipdim

Couldn't find f
Perhaps you meant fd, if, !, %, &, *, +, -, /, :, <, >, I, \, ^, |, ~, ×, ÷, π, ℯ, ∈, ∉, ∋, ∌, ∘, √, ∛, ∩, ∪, ≈, ≉, ≠, ≡, ≢, ≤, ≥, ⊆, ⊇, ⊈, ⊉, ⊊, ⊋, ⊻, ⋅, fft, fld, fma, for, Inf, Ref, eof, != or .%
  Docs for calling f::MyFunc.

```

If I’m not misinterpreting and/or doing something wrong, I’d be happy to open an issue on Github.

---

<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:** [January 18, 2018, 10:59am UTC](https://discourse.julialang.org/t/documenting-a-functor-callable-struct/8444/2 "2018-01-18T10:59:42Z")

</div>

`@doc f` returns just the `Docs for calling f::MyFunc.`, but I would still argue that this is a bug since `f` is technically an argument of that function, and could be anything (usually unrelated to the type).

Practically, for types I make callable I just document the type.

Please check that there is no issue and if not, open one.

---

<div class="post-metadata">

**Author:** ![thofma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thofma/32/1691_2.png) [@thofma](https://discourse.julialang.org/u/thofma)\
**Post date:** [January 18, 2018, 11:41am UTC](https://discourse.julialang.org/t/documenting-a-functor-callable-struct/8444/3 "2018-01-18T11:41:07Z")

</div>

This is bugged. Somehow the docstring is associated to the Symbol `:f`.

I think this is related to [https://github.com/JuliaLang/julia/issues/20087](https://github.com/JuliaLang/julia/issues/20087), but I would advise to open a new issue.

---

<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:** [January 18, 2018, 12:00pm UTC](https://discourse.julialang.org/t/documenting-a-functor-callable-struct/8444/4 "2018-01-18T12:00:09Z")

</div>

> [@thofma](#):
>
> but I would advise to open a new issue.

It looks like the same issue.

---

<div class="post-metadata">

**Author:** ![thofma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thofma/32/1691_2.png) [@thofma](https://discourse.julialang.org/u/thofma)\
**Post date:** [January 18, 2018, 12:20pm UTC](https://discourse.julialang.org/t/documenting-a-functor-callable-struct/8444/5 "2018-01-18T12:20:41Z")

</div>

Then just post the problem there.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [January 18, 2018, 1:47pm UTC](https://discourse.julialang.org/t/documenting-a-functor-callable-struct/8444/6 "2018-01-18T13:47:26Z")

</div>

Hopefully [https://github.com/JuliaLang/julia/pull/25626](https://github.com/JuliaLang/julia/pull/25626) should fix it.
