# Binding docstring to struct field

**URL:** https://discourse.julialang.org/t/binding-docstring-to-struct-field/89439
**Category:** General Usage
**Created:** [October 28, 2022, 10:15am UTC](https://discourse.julialang.org/t/binding-docstring-to-struct-field/89439 "2022-10-28T10:15:43Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![nandoconde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nandoconde/32/19497_2.png) [@nandoconde](https://discourse.julialang.org/u/nandoconde)
#### Post date: [October 28, 2022, 10:15am UTC](https://discourse.julialang.org/t/binding-docstring-to-struct-field/89439/1 "2022-10-28T10:15:43Z")

</div>

Why does field docstring generation depend on where it was defined?

# In a file:

```julia
# MyModule.jl
module MyModule
"A docstring"
struct A
    "a docstring"
    a::Int64
end
end

```

```julia-auto
julia> include("MyModule.jl")
Main.MyModule

help?> MyModule.A.a
  a docstring

```

# In the REPL

```julia-auto
julia> ex = :(struct B
       "b docstring"
       b::Int64
       end);

julia> @eval $ex

help?> B.b
  B has fields b.

```

---

<div class="post-metadata">

### Author: ![nandoconde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nandoconde/32/19497_2.png) [@nandoconde](https://discourse.julialang.org/u/nandoconde)
#### Post date: [October 31, 2022, 8:16am UTC](https://discourse.julialang.org/t/binding-docstring-to-struct-field/89439/2 "2022-10-31T08:16:30Z")

</div>

Bump, just in case anybody knows

---

<div class="post-metadata">

### Author: ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)
#### Post date: [November 8, 2022, 10:30am UTC](https://discourse.julialang.org/t/binding-docstring-to-struct-field/89439/3 "2022-11-08T10:30:25Z")

</div>

I don’t know the underlying reason why, but observe in the REPL:

```julia
julia> struct B
           "b docstring"
            b::Int64
       end;

help?> B.b
  B has fields b.

```

while

```julia
julia> "Module B"
        struct B
           "b docstring"
            b::Int64
       end

help?> B.b
  b docstring

```

So it seems it’s not `include` versus REPL, but the use of a docstring for the module definition.

You can “see” the docstring registration via `Docs.meta(Main)`.

Actually, possibly related to an open issue (from 2016):  
[docstrings for inner constructors are ignored · Issue #16730 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/16730)
