# Docstrings with Julia/Atom

**URL:** <https://discourse.julialang.org/t/docstrings-with-julia-atom/11956>\
**Category:** New to Julia\
**Created:** [June 26, 2018, 8:41am UTC](https://discourse.julialang.org/t/docstrings-with-julia-atom/11956 "2018-06-26T08:41:48Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![annoporci](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@annoporci](https://discourse.julialang.org/u/annoporci)\
**Post date:** [June 26, 2018, 8:41am UTC](https://discourse.julialang.org/t/docstrings-with-julia-atom/11956/1 "2018-06-26T08:41:48Z")

</div>

I am looking at code written about a year ago and successfully run within atom with — probably — Julia 0.5. I can’t even get started now. It is possible I am forgetting some basic stuff, as I haven’t used Julia in about a year and the mind forgets.

I’m on MacOS. I have installed the latest Julia (0.63). I have installed the latest Atom (1.28.0). I have the following updated packages: Hydrogen, language-julia, julia-client, linter-julia, uber-juno,

I can successfully execute `cd("/Users/myname/julia/")` in the Julia console and in the atom REPL, but get an error when I attempt to execute the whole file preceded by docstrings. Has the syntax for docstrings changed? My usage seems to be consistent with the answer here (unless I’m missing something):

> <https://stackoverflow.com/questions/19821247/how-to-make-user-defined-function-descriptions-docstrings-available-to-julia>

```
""" 
	blabla
"""

## blabla 
cd("/Users/myname/julia/")

```

Here is the error message:

```
ERROR: LoadError: cannot document the following expression:

cd("/Users/myname/julia/")

Stacktrace:
 [1] error(::String, ::String, ::Vararg{String,N} where N) at ./error.jl:30
 [2] include_string(::String, ::String) at ./loading.jl:522
 [3] include_string(::Module, ::String, ::String) at /Users/myname/.julia/v0.6/Compat/src/Compat.jl:88
 [4] (::Atom.##112#116{String,String})() at /Users/myname/.julia/v0.6/Atom/src/eval.jl:109
 [5] withpath(::Atom.##112#116{String,String}, ::Void) at /Users/myname/.julia/v0.6/CodeTools/src/utils.jl:30
 [6] withpath(::Function, ::String) at /Users/myname/.julia/v0.6/Atom/src/eval.jl:38
 [7] hideprompt(::Atom.##111#115{String,String}) at /Users/myname/.julia/v0.6/Atom/src/repl.jl:67
 [8] macro expansion at /Users/myname/.julia/v0.6/Atom/src/eval.jl:106 [inlined]
 [9] (::Atom.##110#114{Dict{String,Any}})() at ./task.jl:80
while loading untitled-8b0c8bf366079a4b60396bc23cf86087, in expression starting on line 2

```

---

<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 26, 2018, 8:52am UTC](https://discourse.julialang.org/t/docstrings-with-julia-atom/11956/2 "2018-06-26T08:52:31Z")

</div>

> [@annoporci](#):
>
> I attempt to execute the whole file preceded by docstrings

What is the use case for this? What are you trying to document with this docstring?

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [June 26, 2018, 9:18am UTC](https://discourse.julialang.org/t/docstrings-with-julia-atom/11956/3 "2018-06-26T09:18:46Z")

</div>

It is not possible to add a docstring to a function call; generally, all docstrings need to be attached to some kind of object (e.g. a method, function, or constant). You cannot attach a docstring to a whole file.

---

<div class="post-metadata">

**Author:** ![Nosferican](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nosferican/32/9275_2.png) [@Nosferican](https://discourse.julialang.org/u/Nosferican)\
**Post date:** [June 26, 2018, 11:25am UTC](https://discourse.julialang.org/t/docstrings-with-julia-atom/11956/4 "2018-06-26T11:25:25Z")

</div>

Attaching docstring to modules might be the closest to it.

---

<div class="post-metadata">

**Author:** ![ScottPJones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scottpjones/32/146_2.png) [@ScottPJones](https://discourse.julialang.org/u/ScottPJones)\
**Post date:** [June 26, 2018, 11:45am UTC](https://discourse.julialang.org/t/docstrings-with-julia-atom/11956/5 "2018-06-26T11:45:08Z")

</div>

I always have a docstring immediately before the module, works well with the help system. For example:

```julia
__precompile__ (true)
"""
API Tools package

Copyright 2018 Gandalf Software, Inc., Scott P. Jones

Licensed under MIT License, see LICENSE.md

(@def macro "stolen" from DiffEqBase.jl/src/util.jl :-) )
"""
module ModuleInterfaceTools

```

We even would use a “dummy” module for documentation purposes, for files we included directly.

```julia
"""
Brief description

Copyright info

License Info

(optional) full description
"""
module Foobar end
...

```

---

<div class="post-metadata">

**Author:** ![annoporci](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@annoporci](https://discourse.julialang.org/u/annoporci)\
**Post date:** [June 26, 2018, 1:25pm UTC](https://discourse.julialang.org/t/docstrings-with-julia-atom/11956/6 "2018-06-26T13:25:13Z")

</div>

Oh thanks. I see that I was not using the docstrings properly. Most likely I didn’t use to execute the whole file and had used the docstrings merely as a comment/info at the top. My bad.

Immediately after the `cd("/Users/myname/julia/")` command I load a module with `include("module.jl")`, so perhaps I intended the docstrings to document the module but placed them in the wrong file.

Thanks all of you for the feedback. Sorry for the lame question.

---

<div class="post-metadata">

**Author:** ![annoporci](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@annoporci](https://discourse.julialang.org/u/annoporci)\
**Post date:** [June 26, 2018, 1:26pm UTC](https://discourse.julialang.org/t/docstrings-with-julia-atom/11956/7 "2018-06-26T13:26:12Z")

</div>

Thanks for providing an example of use. Very useful!

For multiline comments not intended to be docstrings, I’ll use `#=` and `=#`, which I didn’t know / forgot about.

---

<div class="post-metadata">

**Author:** ![ScottPJones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scottpjones/32/146_2.png) [@ScottPJones](https://discourse.julialang.org/u/ScottPJones)\
**Post date:** [June 26, 2018, 1:30pm UTC](https://discourse.julialang.org/t/docstrings-with-julia-atom/11956/8 "2018-06-26T13:30:04Z")

</div>

> [@annoporci](#):
>
> Sorry for the lame question.

If you made an effort (i.e. tried to find an answer in the docs / googling), then _no_ question is lame, so don’t feel sorry.  
For quick responses, you might want to try either Gitter or Slack.

---

<div class="post-metadata">

**Author:** ![annoporci](https://avatars.discourse-cdn.com/v4/letter/a/ba9def/32.png) [@annoporci](https://discourse.julialang.org/u/annoporci)\
**Post date:** [June 26, 2018, 1:45pm UTC](https://discourse.julialang.org/t/docstrings-with-julia-atom/11956/9 "2018-06-26T13:45:30Z")

</div>

Thanks Scott, first time I hear of Gitter. Just signed up.

---

<div class="post-metadata">

**Author:** ![ScottPJones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scottpjones/32/146_2.png) [@ScottPJones](https://discourse.julialang.org/u/ScottPJones)\
**Post date:** [June 26, 2018, 1:48pm UTC](https://discourse.julialang.org/t/docstrings-with-julia-atom/11956/10 "2018-06-26T13:48:32Z")

</div>

Looking forward to seeing you in the Julia room: [JuliaLang/julia - Gitter](https://gitter.im/JuliaLang/julia)
