Adding Documentation
This section details how to set up a documentation page using Documenter.jl. This is a more concise version of the instructions included in the documentation for that package.
- In your repo, create a - docs/directory, and a- docs/src/directory that will conntain all the source- .mdfiles for your documentation.
- Create a - docs/make.jlfile. This file is responsible for building and deploying your documentation. Here is the basic starting point:- using Documenter using JuliaTemplateRepo # your package name here makedocs( sitename = "JuliaTemplateRepo", # your package name here format = Documenter.HTML(prettyurls = false), # optional pages = [ "Introduction" => "index.md" ] ) # Documenter can also automatically deploy documentation to gh-pages. # See "Hosting Documentation" and deploydocs() in the Documenter manual # for more information. deploydocs( repo = "github.com/bjack205/JuliaTemplateRepo.jl.git", )
- Add documentation files to - docs/src. Once the files are in- docs/src, add them to the- makedocscommand.
- Add Documentation dependencies. Nearly identical to the tests, we need to add any dependencies we use to build the documentation, which obviously must include Documenter.jl. Activate the - docs/directory and add Documenter- julia> ] activate docs (docs) pkg> add DocumenterThen add a- [compat]entry for Documenter.
- Add deploy keys for your repo. Install DocumenterTools.jl and enter the following into your REPL - using DocumenterTools using JuliaTemplateRepo # your package name here DocumenterTools.genkeys(JuliaTemplateRepo) # your package name hereCopy the first public key (starts with- ssh-rsaand ends with- Documenter). Go to your repository settings in GitHub and select "Deploy Keys". Add the deploy key, using- documenteras the name. - Then copy the very long environment variable and save it as the - DOCUMENTER_KEYsecret on GitHub: 
- Add a GitHub Action to build your documentation. Create a new GitHub action (called - Documenter.yml) and paste the code found here:
- Add Documentation badge to README. Add the following line to the top of the file, replacing the user/organize and repo names in the url: - [](https://bjack205.github.io/JuliaTemplateRepo.jl/dev)
Writing Docstrings
As stated in the Julia manual, start the docstring with the signature, which is indented with 4 spaces so it prints as Julia code. You can use normal markdown syntax, such as headings, to make your docstrings look since and stay organized. See the above example and the Documenter.jl docs on how to include $\LaTeX$ math into the docstrings.
Building documentation locally
You can build the documentation locally by only running the makedocs function, and disabling prettyurls. It's common to update docstrings in your code and want these changes reflected in your build. After making a change to the docstring, you need to "rebuild" the docstrings by executing the whole file, easily done with CTRL-SHIFT-RETURN in Juno. You can then rebuild the the docs (using CTRL-RETURN in Juno) and the docstrings will be updated.