11

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.

4
  • What do you mean by "cross-reference"? Are you saying one would be able to do ?A.C.bar and then click on the highlighted foo in help mode and trigger ?A.B.foo ? I haven't seen that with other functions, I've only seen highlighting (as you've done). Commented Feb 22, 2017 at 10:12
  • 3
    @TasosPapastylianou While the Julia REPL does not have that feature, Documenter does. Commented Feb 22, 2017 at 16:59
  • Ah, I do apologise, I must have missed it in the title earlier! (also I was not aware of Documenter.jl) :) Commented Feb 22, 2017 at 20:33
  • @FengyangWang did you get this figured out? I'm in a similar situation now, getting doc reference errors and not sure what to do to fix it. Commented May 17, 2018 at 11:49

1 Answer 1

11

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.