使用doc任务生成scaladoc后如何运行bash脚本? [英] How to run bash script after generating scaladoc using doc task?

查看:25
本文介绍了使用doc任务生成scaladoc后如何运行bash脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简短的 Bash 脚本,它对我的​​ Scaladoc 注释进行查找和替换,以生成指向第三方库的外部文档的链接.我希望每次使用 doc 任务生成 Scaladoc 时都运行此脚本.

I have a short Bash script that does a find-and-replace on my Scaladoc comments in order to generate links to external documentation of a third-party library. I would like this script to run every time I generate Scaladocs using the doc task.

我怎样才能做到这一点?

How can I achieve this?

推荐答案

其实很简单.首先,我检查了 doc 以查看它是什么(inspect doc 在 sbt 提示符下),注意到它是一个任务,并继续在 build.sbt:

It's actually pretty easy. First, I inspected doc to see what it was (inspect doc on the sbt prompt), noticed it was a task, and proceeded with declaring a dependency on itself on build.sbt:

doc in Compile <<= doc in Compile map { (file) =>
  Seq("bash", "-c", "ls >tmp.log").! // CWD is sbt's current dir
  file
}

我用来执行bash的那个东西和scala.sys.process是同一个库,所以你可以查一下Scaladoc.这是在 SBT 0.12.2 上测试的,我认为在 SBT 0.11.x 或 0.10.x 上可能会有细微差别.

That thing I used to execute bash is the same library as scala.sys.process, so you can look up Scaladoc for that. This was tested on SBT 0.12.2, and I think there might be a small difference on SBT 0.11.x or 0.10.x.

这篇关于使用doc任务生成scaladoc后如何运行bash脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆