【问题标题】:Cross-referencing functions from other submodule in Documenter.jlDocumenter.jl 中其他子模块的交叉引用函数
【发布时间】:2017-02-22 06:55:45
【问题描述】:

给定一个类似的模块层次结构

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

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

如何使用Documenter.jlbar 的文档字符串中交叉引用foo?我试过A.B.fooB.foo..B.foo 都没有成功。

【问题讨论】:

  • “交叉引用”是什么意思?你是说可以做?A.C.bar然后在帮助模式下点击突出显示的foo并触发?A.B.foo?我没有看到其他功能,我只看到突出显示(就像你所做的那样)。
  • @TasosPapastylianou 虽然 Julia REPL 没有该功能,但 Documenter does
  • 啊,对不起,我之前一定是在标题中错过了它! (我也不知道 Documenter.jl):)
  • @FengyangWang 你明白了吗?我现在处于类似情况,收到文档参考错误,不知道如何修复它。

标签: documentation julia cross-reference


【解决方案1】:

首先,B.fooC.bar 都需要 (i) 有文档字符串并且 (ii) 在 markdown 文件中,例如在Documenter @docs block

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

为了在它们之间进行交叉引用。其次,绑定B.foo 必须在C 模块内可见。这可以通过例如在C 模块中添加import ..B: foo(或在B 中添加export foo 和在C 中添加using ..B)来实现。这是一个工作示例:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-05
    • 2017-01-15
    • 2014-01-09
    • 2015-08-20
    相关资源
    最近更新 更多