# Documenter.jl help for first time user

**URL:** <https://discourse.julialang.org/t/documenter-jl-help-for-first-time-user/124966>\
**Category:** New to Julia\
**Tags:** documenter\
**Created:** [January 20, 2025, 1:35pm UTC](https://discourse.julialang.org/t/documenter-jl-help-for-first-time-user/124966 "2025-01-20T13:35:59Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![acroscarrillo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/acroscarrillo/32/214810_2.png) [@acroscarrillo](https://discourse.julialang.org/u/acroscarrillo)\
**Post date:** [January 20, 2025, 1:35pm UTC](https://discourse.julialang.org/t/documenter-jl-help-for-first-time-user/124966/1 "2025-01-20T13:35:59Z")

</div>

I am following the official Documenter.jl’s Guide and I am running into problems.

**To give some context:**

> I have a numerical “library” I made for my research I want to make public with Documenter.jl using GitHub. It is very basic, essentially a `/src` folder containing all the source code for the simulations and a `/experiments` folder that uses `include("/src/src_file.jl")` to perform various numerical experiments.

**What I’ve tried:**

> I figured that in essence my code structure is the same as if everything was inside a massive `src.jl` file which gets called by `experiment_1.jl` files. So I created the following minimal example:

```julia
repo/
│── repo_env/ # Environment folder (only contains Documenter.jl)
│ │── Manifest.toml    
│ │── Project.toml   
│── src/
│ │── src.jl # Module file
│ │── test.jl # A file the module calls
│── docs/
│ │── make.jl # The Guide example

```

> with the following contents:

```julia
# src/src.jl
module Test_Module

export test

include("test.jl")

end # end of module

```

```julia
# src/test.jl
function test(x) 
    return 2*x 
end

```

```julia
# docs/make.jl
push!(LOAD_PATH,"../src/")

using Documenter, .Test_Module

makedocs(sitename="My Documentation")

```

> The reason I made a module (something I wouldnt normally do since I dont use/understand them properly) is because I sense that it is needed. In fact, the official Guide mentions that “Firstly, **we need a Julia module to document.** This could be a package generated via `PkgDev.generate` or a single `.jl` script accessible via Julia’s `LOAD_PATH` .”

**Results/errors:**

> To be fair I’ve tried a plethora of little tweaks and none work with slightly different errors. I’m gonna put this one as it’s the one I expect to learn the most from:

```julia
(base) alex@Lord-Commander-Flagship Quantum_Geometric_Complexity % julia --project=repo_env docs/make.jl
ERROR: LoadError: UndefVarError: `Test_Module` not defined in `Main`
Suggestion: check for spelling errors or missing imports.
in expression starting at /Users/alex/Documents/GitHub/Quantum_Geometric_Complexity/docs/make.jl:3

```

> So it’s obviously not finding the module `Test_Module` despite following the official Guide advice on this issue:  
> "  
> If your source directory is not accessible through Julia’s LOAD\_PATH, you might wish to add the following line at the top of make.jl
> 
> ```julia
> push!(LOAD_PATH,"../src/")
> 
> ```
> 
> "

**Help!**

> I would love to see a minimal working example for something as basic as what I am doing and understand why I get the errors I get.

* * *

* * *

**Unsolicited opinion:**

> For what is worth, I believe that the way the official Guide is written, it implicitly assumes the reader is versed in Modules, Packages and what not. This is fine and should probably be a good idea to learn anyways. However, there are many Julia users like myself who limit to writting efficient (yet unproffessional) numerical code and wish to share it. I know many Julia users in my enviroment that would follow a very similar workflow as what I described in the context above. Perhaps this could be addressed! (I would love to if I manage to understand what’s going on…)

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [January 20, 2025, 1:57pm UTC](https://discourse.julialang.org/t/documenter-jl-help-for-first-time-user/124966/2 "2025-01-20T13:57:42Z")

</div>

I haven’t read your post in full to attempt an answer at your specific question, but this workshop was made exactly for people wanting to write documentation with documenter.jl , even starting just from pure scripts or source code functions :

[![](https://global.discourse-cdn.com/julialang/original/3X/0/d/0d97b959970b10995cb806bc86d10f66feb9dc41.jpeg "Writing and Maintaining Exceptional Documentation | JuliaCon 2024 Workshop") ](https://www.youtube.com/watch?v=ZDQ28X3mGSo)

an answer should be there.

As for your unsolicited opinion 😛 : it is entirely possible to use Documenter.jl locally without knowning much, if anything, about the concept of modules and packages. However, doing so will make everything so much harder for you. It is literally easier to first learn the basisc of packages (5 minutes max in the official docs) and then go to documenter. And the advantage: you also learn about environments as you learn the other things, which a very important component of reproducible workflows.

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [January 20, 2025, 2:15pm UTC](https://discourse.julialang.org/t/documenter-jl-help-for-first-time-user/124966/3 "2025-01-20T14:15:40Z")

</div>

Some minimal examples can be found here:

> **[Create new package · JuliaNotes.jl](https://m3g.github.io/JuliaNotes.jl/stable/new_package/)**
>
> Documentation for JuliaNotes.jl.

and

> **[Publish Docs · JuliaNotes.jl](https://m3g.github.io/JuliaNotes.jl/stable/publish_docs/)**
>
> Documentation for JuliaNotes.jl.

I use those instructions every time I´m creating a new package, but do not intend them to be comprehensive at all.

---

<div class="post-metadata">

**Author:** ![acroscarrillo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/acroscarrillo/32/214810_2.png) [@acroscarrillo](https://discourse.julialang.org/u/acroscarrillo)\
**Post date:** [January 20, 2025, 3:19pm UTC](https://discourse.julialang.org/t/documenter-jl-help-for-first-time-user/124966/4 "2025-01-20T15:19:48Z")

</div>

Great resource, let’s see if I can make it work after watching this! Speaker seems to be a close relative of yours 😉

---

<div class="post-metadata">

**Author:** ![acroscarrillo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/acroscarrillo/32/214810_2.png) [@acroscarrillo](https://discourse.julialang.org/u/acroscarrillo)\
**Post date:** [January 20, 2025, 11:08pm UTC](https://discourse.julialang.org/t/documenter-jl-help-for-first-time-user/124966/5 "2025-01-20T23:08:13Z")

</div>

I have now watched the entire video and I am ashamed to admit that it doesn’t solve my issue. Worst is I don’t even know how to debug the code, errors are often unexpected `ArgumentError: Unable to determine the commit for the remote repository` (but there’s no repo!)

---

<div class="post-metadata">

**Author:** ![acroscarrillo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/acroscarrillo/32/214810_2.png) [@acroscarrillo](https://discourse.julialang.org/u/acroscarrillo)\
**Post date:** [January 20, 2025, 11:09pm UTC](https://discourse.julialang.org/t/documenter-jl-help-for-first-time-user/124966/6 "2025-01-20T23:09:54Z")

</div>

However, I really enjoyed the video and found it a great reference for documenting my code and future packages in the future. It’s pretty sexy the figs generation within the docs!

---

<div class="post-metadata">

**Author:** ![Tetrakai](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@Tetrakai](https://discourse.julialang.org/u/Tetrakai)\
**Post date:** [January 21, 2025, 2:13am UTC](https://discourse.julialang.org/t/documenter-jl-help-for-first-time-user/124966/7 "2025-01-21T02:13:12Z")

</div>

I think you need this directory structure:

```julia
repo/
│
│── Manifest.toml    
│── Project.toml   
│── src/
│ │── src.jl # Module file
│ │── test.jl # A file the module calls
│── docs/
│ │── make.jl # The Guide example

```

Then change to this line of `docs/make.jl`:

```julia
using Documenter, Test_Module

```

Then you will need to install git and initialize a git repo in your project folder (`repo/`). You do not need to use github, but I’m 95% sure you need a git repo for this line (of `make.jl`) to work:

`makedocs(sitename="My Documentation")`

You also need to activate a second project in your `/docs` directory (there should be a `Project.toml` in there).

There may be more but try that and see what error you get.

---

<div class="post-metadata">

**Author:** ![Tetrakai](https://avatars.discourse-cdn.com/v4/letter/t/4da419/32.png) [@Tetrakai](https://discourse.julialang.org/u/Tetrakai)\
**Post date:** [January 21, 2025, 2:22am UTC](https://discourse.julialang.org/t/documenter-jl-help-for-first-time-user/124966/8 "2025-01-21T02:22:10Z")

</div>

I also see there is no docstring, try this:

```julia
# src/test.jl
"""
    test(x)

Multiplies x by 2.
"""
function test(x) 
    return 2*x 
end

```

**Edit:**

Another thing is you need a `docs/src/index.md` file. Create one (including the new `docs/src/` directory), and put this in it:

````julia
# Test_Module
```@contents
```

## Documentation
```@meta
CurrentModule = Test_Module
```

```@autodocs
Modules = [Test_Module]
```

## Index
```@index
```

````

---

<div class="post-metadata">

**Author:** ![Eliassj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eliassj/32/204117_2.png) [@Eliassj](https://discourse.julialang.org/u/Eliassj)\
**Post date:** [January 21, 2025, 8:00am UTC](https://discourse.julialang.org/t/documenter-jl-help-for-first-time-user/124966/9 "2025-01-21T08:00:16Z")

</div>

I felt similarly to you when starting out with Documenter.jl. In the future, I would recommend using PkgTemplates.jl! It allows you to interactively generate a template package with the proper structure and files for Documenter.jl as well as a bunch of other tools (all optional of course).

I would also recommend keeping code in a module and developing it as a package (starting from PkgTemplates) no matter if you plan on releasing it. Once you get the hang of it it really pays off such as through enabling the use of Revise.jl!

---

<div class="post-metadata">

**Author:** ![acroscarrillo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/acroscarrillo/32/214810_2.png) [@acroscarrillo](https://discourse.julialang.org/u/acroscarrillo)\
**Post date:** [January 21, 2025, 10:59am UTC](https://discourse.julialang.org/t/documenter-jl-help-for-first-time-user/124966/10 "2025-01-21T10:59:16Z")

</div>

Thank you so much for your help. The following works!

The last issue I faced was that the call `using Documenter, Test_Module` inside `docs/make.jl` wasn’t working. Essentially I was getting `ERROR: LoadError: UndefVarError: `Test\_Module`not defined in`Main``. Turns out I had to name the file containing my module,`src/src.jl` to `src/Test_Module.jl` to work. I dont understand why, but I suspect this is to do with how `using()` works in Julia: perhaps it is related to a file name rather than its contents?

**Regardless, this is the complete minimal working example for future learners:**

**New file structure:**

> │── Manifest.toml  
> │── Project.toml # has LinearAlgebra.jl only  
> │── docs/  
> │ │── Manifest.toml  
> │ │── make.jl  
> │ │── Project.toml # has Documenter.jl only  
> │ │── src/  
> │ │ │── index.md  
> │── src/  
> │ │── Test\_Module.jl  
> │ │── test.jl

**Contents:**

```julia
# src/Test_Module.jl
module Test_Module

export test

include("test.jl")

end # end of module

```

```julia
# src/test.jl
"""
    test(x)

Multiplies x by 2.
"""
function test(x) 
    return 2*x 
end

```

```julia
# docs/make.jl
push!(LOAD_PATH,"../src/")

using Documenter, Test_Module

makedocs(sitename="My Documentation")

```

```julia
<!-- docs/src/index.md -->
...(same as Tetrakai)...
(I cant figure out the correct syntaxt to not mess up the formatting of this code)

```

**This produces:**

 ![Screenshot 2025-01-21 at 11.59.01](https://global.discourse-cdn.com/julialang/original/3X/3/f/3fdd803c5757fdd802f1866824d5abcc72bf4d9f.png)

* * *

* * *

**Credit:**  
I mark my own answer as the solution to my question since, well, it is. However, as anyone can tell, it’s far from my authorship and I would like to credit everyone above who spoon fed me this one out \<3. Time to rewatch Datseris tutorial again now that everything is working!

---

<div class="post-metadata">

**Author:** ![Eben60](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eben60/32/13475_2.png) [@Eben60](https://discourse.julialang.org/u/Eben60)\
**Post date:** [January 21, 2025, 12:18pm UTC](https://discourse.julialang.org/t/documenter-jl-help-for-first-time-user/124966/11 "2025-01-21T12:18:48Z")

</div>

First, I’d like to use the opportunity to thank @lmiq for his great [JuliaNotes.jl](https://github.com/m3g/JuliaNotes.jl).

Then, to use the opportunity to advertise my PackageMaker.jl - a GUI to make creating packages (including documentation) easier.
