Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross-referencing functions from other submodule in Documenter.jl

Given a module hierarchy like

module A
    module B; function foo end; end
    module C
        """
            bar(x)

        Like [`foo`](@ref), but more `bar`.
        """
        function bar end
    end
end

How could I cross-reference foo from the docstring of bar using Documenter.jl? I have tried A.B.foo, B.foo, and ..B.foo without success.

like image 206
Fengyang Wang Avatar asked Feb 22 '17 06:02

Fengyang Wang


1 Answers

First, both B.foo and C.bar needs to (i) have docstrings and (ii) be in the markdown file, e.g. in a Documenter @docs block.

```@docs
A.B.foo
A.C.bar
```

in order to cross-reference between them. Second, the binding B.foo must be visible inside the C module. This can be achieved by, for example, adding import ..B: foo in the C module (or adding export foo in B and using ..B in C). Here is a working example:

module A
    module B
        "foo function"
        function foo end
    end
    module C
        import ..B: foo
        """
            bar(x)

        Like [`foo`](@ref), but more `bar`.
        """
        function bar end
    end
end # module
like image 103
fredrikekre Avatar answered Sep 23 '22 11:09

fredrikekre