【问题标题】:Where does scaladoc look for the rootdoc.txt to create the root docscaladoc 在哪里寻找 rootdoc.txt 来创建根文档
【发布时间】:2018-01-07 07:44:44
【问题描述】:

这是Generate scaladoc for root package 的副本,但答案没有说明sbt doc 在哪里寻找rootdoc.txt

我加了

 scalacOptions in doc ++= Seq("-doc-root-content", "rootdoc.txt")

到我的build.sbt,但sbt doc 似乎没有扫描它。我试着把它放在build.sbt旁边,在srcsrc/mainsrc/main/scala

我正在使用sbt 0.12.3

【问题讨论】:

    标签: scala packages scaladoc


    【解决方案1】:

    您的论点似乎根本没有提供给scaladoc。我无法弄清楚为什么在将范围限定为doc 时未传递命令行参数,但如果您不将其范围限定为doc 而是Compile,则它可以工作:

     scalacOptions in Compile ++= Seq("-doc-root-content", "rootdoc.txt")
    

    rootdoc.txt位于项目的根目录。

    【讨论】:

    • 这样做会导致:[error] bad option: '-doc-root-content' 当您尝试 sbt compile
    【解决方案2】:

    您应该使用绝对文件路径:

    scalacOptions in doc <++= baseDirectory map { d =>
      Seq("-doc-root-content", d / "rootdoc.txt" getPath)
    }
    

    这将使 scaladoc 在项目的根目录中查找 rootdoc.txt,也就是 build.sbt 旁边

    【讨论】:

    • 感谢您的快速回复,但它不起作用。我的build.sbt 旁边有一个rootdoc.txt 并运行sbt clean doc。我的target/scala-2.10/api/index.html 只显示了一个带有package org 的空包
    【解决方案3】:

    正确的解决方案似乎是

    settings(
       // Get scaladoc to add rootdoc.txt content to index.html
       scalacOptions in (Compile,doc) ++= Seq("-doc-root-content", "rootdoc.txt")
    ).
    

    关注https://github.com/pnerg/sbt-scaladoc-settings-plugin/blob/master/README.md

    这让我很难过。

    【讨论】:

      猜你喜欢
      • 2023-04-03
      • 1970-01-01
      • 2011-10-02
      • 1970-01-01
      • 1970-01-01
      • 2015-02-06
      • 1970-01-01
      • 2015-01-16
      • 1970-01-01
      相关资源
      最近更新 更多