# The proper way of documenting constructors

**URL:** https://discourse.julialang.org/t/the-proper-way-of-documenting-constructors/17049
**Category:** General Usage
**Tags:** documentation, documenter
**Created:** [November 1, 2018, 11:46am UTC](https://discourse.julialang.org/t/the-proper-way-of-documenting-constructors/17049 "2018-11-01T11:46:40Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![fjarri](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fjarri/32/630_2.png) [@fjarri](https://discourse.julialang.org/u/fjarri)
#### Post date: [November 1, 2018, 11:46am UTC](https://discourse.julialang.org/t/the-proper-way-of-documenting-constructors/17049/1 "2018-11-01T11:46:40Z")

</div>

If a type has outer constructors, Julia’s REPL shows all their docstrings joined together with the type’s docstring when asked for help, which is pretty neat:

```julia
"Type docstring"
struct A 
    x
end

"Constructor docstring"
A() = A(0)

```

and then

```julia
help?> A

  Type docstring

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

  Constructor docstring

```

But if I make the constructor inner:

```julia
"Type docstring"
struct A
    x

    "Constructor docstring"
    A() = new(0)
end

```

then the help in REPL only shows `Type docstring`.

It is even worse in Documenter, where only `Type docstring` is shown for both variants for the doc file like

````
```@docs
A
```

````

So, is that the expected behavior or a bug (or the lack of a feature)? What is the recommended way of documenting constructors? Is it possible to make `Documenter` show all documented constructors like the REPL does? I would prefer to have inner constructors to control the contents of the type.

---

<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: [November 1, 2018, 1:18pm UTC](https://discourse.julialang.org/t/the-proper-way-of-documenting-constructors/17049/2 "2018-11-01T13:18:57Z")

</div>

[https://github.com/JuliaLang/julia/issues/16730](https://github.com/JuliaLang/julia/issues/16730)

---

<div class="post-metadata">

### Author: ![fjarri](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fjarri/32/630_2.png) [@fjarri](https://discourse.julialang.org/u/fjarri)
#### Post date: [November 1, 2018, 10:55pm UTC](https://discourse.julialang.org/t/the-proper-way-of-documenting-constructors/17049/3 "2018-11-01T22:55:06Z")

</div>

Thanks, that does fix the issue with REPL, unfortunately `Documenter` still ignores these docstrings.

---

<div class="post-metadata">

### Author: ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)
#### Post date: [July 7, 2023, 1:58pm UTC](https://discourse.julialang.org/t/the-proper-way-of-documenting-constructors/17049/4 "2023-07-07T13:58:47Z")

</div>

Hello, I know long time has passed, but just to say this doesn’t seem to be a problem any more… by adding `@doc` in front to the internal constructor’s docstring, I can have both the struct and the constructor documented in both the REPL and the Documenter output, e.g.:

- constructor: [Nn · BetaML.jl Documentation](https://sylvaticus.github.io/BetaML.jl/dev/Nn.html#BetaML.Nn.DenseLayer-Tuple%7BAny,%20Any%7D)
- struct: [Nn · BetaML.jl Documentation](https://sylvaticus.github.io/BetaML.jl/dev/Nn.html#BetaML.Nn.DenseLayer)

However you still need to manually add the `@doc` macro, at least until issue [#14962](https://github.com/JuliaLang/julia/issues/14962) will be solved.
