Documenter.jl is not documenting any changes

I don’t know what I am doing wrong. I download the project Example.jl from GitHub.
JuliaLang/Example.jl: Example Julia package repo. (github.com)

I only changed the content of the Example.jl under src folder; just removed the hello function.

module Example
export domath


"""
    domath(x::Number)

Return `x + 5`.
"""
domath(x::Number) = x + 5

end

When I run

julia make.jl

inside docs folder using cmd on windows It showhow still builds index.html with the initial content. Still showing me hello function in documentation even do I removed it from Example.jl.

I would appreciate any help. Documenter.jl also does not work properly for my own package, and I assume the underlying problem is the same as here.

did you remember to save the change to file?

when you run julia make.jl, what’s the output in terminal, did you encounter any error message?

Thank you for the answer. I’m 100% sure it’s saved.

It generates the below output in the terminal.

And the resulting document is:

I am suspecting though one thing; after downloading Example.jl from GitHub and making the first:
julia make.jl

It threw an error and asked me to make Pkg.add("Example"). I suspect that it’s somehow creating the document from the library itself, not from the folder.

But I’m making a pure guess.

For example, I made a copy of Example and saved it as xyz. So the new package is called xyz. Made the relevant changes in the docs folder.

image

The content of Example.jl:

module Example
export domath


"""
    domath(x::Number)

Return `x + 5`.
"""
domath(x::Number) = x + 5

end

The content of the make.jl

using Documenter, xyz

makedocs(modules = [xyz], sitename = "xyz.jl")

# deploydocs(repo = "github.com/JuliaLang/Example.jl.git")

The content of index.md:

# xyz

Example Julia package repo.


@autodocs
Modules = [xyz]
# 3 left quotation marks before and after @autodocs. it is not displaying correctly here if I add them.

After running:

julia make.jl

The output in the terminal is:
image

It’s asking me to install the package first. I am sure I’m making a simple mistake somewhere, but I could not figure it out.

The documentation of Documenter.jl needs to be definitely improved. Nowadays, Julia, R, and Python languages are used predominantly by non-computer scientists, and it is very difficult to figure out the problem.

This solved my problem:
additionnal documentation of julia make.jl for newbies · Issue #1565 · JuliaDocs/Documenter.jl (github.com)

using Pkg
Pkg.activate("..")
push!(LOAD_PATH,"../src/")
1 Like

While messing with the LOAD_PATH works, the standard approach here is to make sure you package is correctly added as a dev dependency to docs/Project.toml. That’s why you generally have something like Pkg.develop(PackageSpec(path=pwd())) in your docs CI configuration, e.g.:

2 Likes

@mortenpi, Thank you for the answer.

Could you please also advise how the content of make.jl looks like?

If I do it the way you suggest, it only impacts the folders in GitHub. How can I document the package I’m developing on my local machine?

I pushed the folders from my local to GitHub, but I added a new dependency; therefore, It threw the “Documentation workflow run failed for main branch” error:

ERROR: LoadError: ArgumentError: Package PortfolioAnalytics does not have NamedArrays in its dependencies:
- You may have a partially installed environment. Try `Pkg.instantiate()`
  to ensure all packages in the environment are installed.
- Or, if you have PortfolioAnalytics checked out for development and have
  added NamedArrays as a dependency but haven't updated your primary
  environment's manifest file, try `Pkg.resolve()`.
- Otherwise you may need to report an issue with PortfolioAnalytics

Basically, you do the exact same thing as on CI. Nothing goes into make.jl. Usually, when I need to build the docs for a newly cloned package, I run the following (assuming my working directory is in the root of the package):

$ julia --project=docs/

pkg> dev .

julia> include("docs/make.jl")

Note that you only need to do this once, since the relative path to your package gets stored in docs/Manifest.toml. Later, doing julia --project=docs/ docs/make.jl will pick up the correct package.

2 Likes

@mortenpi, I think to some extent, I understood. I added the content you provided to CI.yml, and it now works.

Introduction · PortfolioAnalytics (doganmehmet.github.io)

Could you please advise whether I should use documentation.yml now?

But this only works on Github, so on a local PC still does not work - it does not pull the docstrings from the functions.

My apologies, I am not a computer scientist, and it isn’t easy to figure out these kinds of things.

Locally, one thing you need to make sure is „which version of your package is used“.

If you just Pkg.add (or ] add ...) your package from the local folder, the package is copied over to the Julia folder. To load the package from the folder where you develop the package make sure tu run ] dev . in Julia REPL. that way the package is loaded from the folder where you issued this command. you can also check this in ] status that the package lists a folder behind where it loads from.

Then you can also run docs locally :slight_smile:

PS: Don‘t worry the start takes a while in any language with package development, feel free to ask further questions of course.

2 Likes

Thanks very much, This connected the dots. Finally, I can continue improving my package and the documentation.

(@v1.8) pkg> dev .
   Resolving package versions...
    Updating `C:\Users\ploot\.julia\environments\v1.8\Project.toml`
  [7876af07] ~ Example v0.5.3 ⇒ v0.5.4 `..\..\..\Downloads\Example`
    Updating `C:\Users\ploot\.julia\environments\v1.8\Manifest.toml`
  [7876af07] ~ Example v0.5.3 ⇒ v0.5.4 `..\..\..\Downloads\Example`
(@v1.8) pkg> status
Status `C:\Users\ploot\.julia\environments\v1.8\Project.toml`
  [336ed68f] CSV v0.10.9
  [159f3aea] Cairo v1.0.5
⌃ [a93c6f00] DataFrames v1.4.4
  [31c24e10] Distributions v0.25.80
  [e30172f5] Documenter v0.27.24
  [35a29f4d] DocumenterTools v0.1.16
  [7876af07] Example v0.5.4 `..\..\..\Downloads\Example`
julia> include("docs/make.jl")
┌ Warning: Unable to determine HTML(edit_link = ...) from remote HEAD branch, defaulting to "master".
│ Calling `git remote` failed with an exception. Set JULIA_DEBUG=Documenter to see the error.
│ Unless this is due to a configuration error, the relevant variable should be set explicitly.
└ @ Documenter.Utilities C:\Users\ploot\.julia\packages\Documenter\H5y27\src\Utilities\Utilities.jl:822
[ Info: SetupBuildDirectory: setting up build directory.
[ Info: Doctest: running doctests.
[ Info: ExpandTemplates: expanding markdown templates.
[ Info: CrossReferences: building cross-references.
[ Info: CheckDocument: running document checks.
[ Info: Populate: populating indices.
[ Info: RenderDocument: rendering document.
[ Info: HTMLWriter: rendering HTML pages.

It worked!

1 Like

…and on GitHub the documenter.yml GitHub workflow/action does the same then, but this way you can also generate the docs locally (in docs/build).but be careful not to add that folder to your repo, that is just a cause for merge conflicts.

Thanks again for the advice. Below you can see the content of documentation.yml and CI.yml. I hope I’m doing right!

This is the content of documentation.yml:

name: Documentation

on:
  push:
    branches:
      - main # update to match your development branch (master, main, dev, trunk, ...)
    tags: '*'
  pull_request:

jobs:
  build:
    permissions:
      contents: write
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: julia-actions/setup-julia@v1
        with:
          version: '1.8' # Julia version
      - name: Install dependencies
        run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
      - name: Build and deploy
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token
          DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key
        run: julia --project=docs/ docs/make.jl

This is the relevant part in CI.yml:

    docs:
      name: Documentation
      runs-on: ubuntu-latest
      steps:
        - uses: actions/checkout@v2
        - uses: julia-actions/setup-julia@v1
          with:
            version: '1.6'
        - run: |
            julia --project=docs -e '
              using Pkg
              Pkg.develop(PackageSpec(path=pwd()))
              Pkg.instantiate()'
        - run: julia --project=docs --color=yes docs/make.jl
          env:
            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
            DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}

Looks fine to me, we do docs with the docs action, see https://raw.githubusercontent.com/JuliaManifolds/Manifolds.jl/master/.github/workflows/documenter.yml

But as far as I can see yours looks fine as well.

I much apologize for being poorly literate on the matter.

I am struggling to get Documenter makedocs() function to work.

Q1: what does dev . in package mode do?

Q2: how do I verify that dev . has been succesfully been executed?

Q3: is there an activate docs/ missing here?

Thx!

It puts the package that is in the current folder (.) into development mode, that is, when you do using ThatPackage (the one on .) the code is compiled from that folder.

if you do ] status (that is in package mode) you see the folder listed after the package. For example in my status I have

  [0fc0a36d] Manopt v0.5.3 `../../../Repositories/Julia/Manopt.jl`

that activates the environment (Project.toml) in the docs/ folder.

1 Like

Right.

What determines the version number of Manopt ?

Well, the version in the folder that you dev-ed. If you check out the repository of a version a few releases back in that folder, that is what you are running on. If it is even something newer than the last registered version (because you develop that further) that is what you are running on.

1 Like

Right. Thanks again!