javadoc 创建html,创建使用favicon的Javadoc HTML页面

这个脚本修复了马库斯解决方案中的一些问题,包括当目录无.html文件时创建不必要的文件,未处理JDK8版本的HTML文件,多次运行时重复插入favicon,以及不保留文件权限。它使用了一个更安全的临时文件创建方法,并且能够遍历子目录。在MacOS上可能无法正常工作,因为它依赖于`mktemp`命令。这个更新的版本可在html-tools存储库中找到,欢迎报告问题或提出改进意见。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

马库斯的解决方案是一个良好的开端。谢谢你提供它!

然而,它有一些问题:

如果目录不包含任何.html文件,则会创建一个文件

名为*.html。

它不会向JDK 8版本的javadoc生成的HTML文件添加favicon,该版本使用

而不是。

如果多次运行,它会多次插入favicon。

mktemp命令不可移植(例如,在Mac OS上不起作用)。

它不保留文件权限。

这是一个纠正这些问题的版本。可以在expanded version存储库中找到html-tools。如果您发现问题或想提出改进建议,请在此处发表评论或使用html-tools issue tracker。

#!/bin/sh

# Add favicon to header of HTML files.

# One use case is for javadoc-generated API documentation.

#

# Run like this:

# add-favicon

# The arguments should be paths relative to the current working directory.

# Once this has been run, running it another time has no effect.

patchIt () {

for f in $1/*.html ; do

if [ -f "$f" ]; then # if no .html files exist, f is literal "*.html"

tmpfile=`mktemp patch_favicon_XXXXX`

# This creates tmpfile, with the same permissions as $f.

# The next command will overwrite it but preserve the permissions.

# Hat tip to http://superuser.com/questions/170226/standard-way-to-duplicate-a-files-permissions for this trick.

\cp -p $f $tmpfile

sed -e " s%

\$%%" $f > $tmpfile

mv -f $tmpfile $f

fi;

done ;

for d in $1/* ; do

if [ -d $d ]; then echo "descending to "$d ; patchIt $d ../$2 ; fi ;

done

}

patchIt $1 $2

#eof

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值