70 lines
1.8 KiB
Bash
Executable File
70 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# 获取版本号(从项目文件中)
|
|
version=$(grep -o '<Version>[^<]*</Version>' ThreatSource/ThreatSource.csproj | sed 's/<Version>\(.*\)<\/Version>/\1/')
|
|
|
|
if [ -z "$version" ]; then
|
|
echo "Error: Could not find version number in ThreatSource.csproj"
|
|
exit 1
|
|
fi
|
|
|
|
# 创建临时文件列表
|
|
temp_file="html_files.txt"
|
|
|
|
# 清空临时文件
|
|
> $temp_file
|
|
|
|
# 获取当前目录的绝对路径
|
|
current_dir=$(pwd)
|
|
|
|
# 创建发布目录(如果不存在)
|
|
mkdir -p "${current_dir}/publish"
|
|
|
|
# 首先添加主页
|
|
echo "file://${current_dir}/docs/_site/docs/index.html" >> $temp_file
|
|
|
|
# 添加文章
|
|
find "${current_dir}/docs/_site/docs/articles" -name "*.html" | sed 's|^|file://|' >> $temp_file
|
|
|
|
# 添加示例文档
|
|
find "${current_dir}/docs/_site/docs/examples" -name "*.html" | sed 's|^|file://|' >> $temp_file
|
|
|
|
# 添加API文档
|
|
find "${current_dir}/docs/_site/docs/api" -name "*.html" | sed 's|^|file://|' >> $temp_file
|
|
|
|
# 构建wkhtmltopdf命令
|
|
cmd="wkhtmltopdf \
|
|
--enable-local-file-access \
|
|
--enable-javascript \
|
|
--javascript-delay 1000 \
|
|
--no-stop-slow-scripts \
|
|
--enable-external-links \
|
|
--enable-internal-links \
|
|
--page-size A4 \
|
|
--margin-top 15 \
|
|
--margin-bottom 15 \
|
|
--margin-left 20 \
|
|
--margin-right 20 \
|
|
--footer-left \"ThreatSource Library\" \
|
|
--footer-right \"[page]/[topage]\" \
|
|
--footer-spacing 5 \
|
|
--footer-font-size 8 \
|
|
--disable-smart-shrinking \
|
|
--zoom 0.8 \
|
|
--dpi 300"
|
|
|
|
# 添加所有HTML文件到命令中
|
|
while IFS= read -r file; do
|
|
cmd="$cmd \"$file\""
|
|
done < "$temp_file"
|
|
|
|
# 添加输出文件名
|
|
cmd="$cmd \"${current_dir}/publish/ThreatSource-Library-${version}.pdf\""
|
|
|
|
# 执行命令
|
|
eval $cmd
|
|
|
|
# 删除临时文件
|
|
rm $temp_file
|
|
|
|
echo "PDF generation completed: publish/ThreatSource-Library-${version}.pdf" |