# How to add short inline documentation to a function?

**URL:** <https://discourse.julialang.org/t/how-to-add-short-inline-documentation-to-a-function/41714>\
**Category:** Tooling\
**Tags:** question, proposal, documentation, documenter\
**Created:** [June 19, 2020, 8:58am UTC](https://discourse.julialang.org/t/how-to-add-short-inline-documentation-to-a-function/41714 "2020-06-19T08:58:44Z")\
**Posts on this page:** 4\
**Page:** 1

<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:** [June 19, 2020, 8:58am UTC](https://discourse.julialang.org/t/how-to-add-short-inline-documentation-to-a-function/41714/1 "2020-06-19T08:58:44Z")

</div>

In C++/Doxygen it is possible to add short documentation e.g.

```cpp
int myf(int x); ///< My quick doc

```

Is it possible to use the same style in Julia/Documenter.jl, without having to write a docstring on its own line, like:

```julia
"""My quick doc"""
myf(x) = x+1

```

??

---

<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:** [June 19, 2020, 9:01am UTC](https://discourse.julialang.org/t/how-to-add-short-inline-documentation-to-a-function/41714/2 "2020-06-19T09:01:13Z")

</div>

I can see that `"""Add 1 to x """ myf(x) = x+1 ` works, but the other way around would be much better…

---

<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:** [June 19, 2020, 11:48am UTC](https://discourse.julialang.org/t/how-to-add-short-inline-documentation-to-a-function/41714/3 "2020-06-19T11:48:46Z")

</div>

I don’t think there is similar functionality in Julia.

Also, for single line, you may not need the triple quotes (unless you want to use unescaped quotes), so

```julia
"stuff" f(x) = 1

```

would work fine, too.

Finally, if you still don’t like prepending docstrings, you can write a macro

```julia
@docafter f(x) = 1 "stuff"

```

but personally I would just stick with what’s supported.

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [June 19, 2020, 1:00pm UTC](https://discourse.julialang.org/t/how-to-add-short-inline-documentation-to-a-function/41714/4 "2020-06-19T13:00:06Z")

</div>

Just to complement Tamas answers:

1. The triple quoting has nothing to do with documentation, it is just a convenient way of writing multiline strings. What documents is having a string object before the struct/field/method/function that you what to document.
2. This said, you can have a simple quoted string above some construct and it will document the same way (they do not need to be in the same line just because they are simple quoted), i.e.

```julia
"My documentation of struct A."
struct A
    "My documentation of field b."
    b :: Int
    "My documentation of field c."
    c :: Int
end

```
