7 Star 1 Fork 0

Admin / atl_cloud_api

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
showdoc_api.sh 1.98 KB
一键复制 编辑 原始数据 按行查看 历史
lcx 提交于 2021-01-14 17:58 . lcx
#! /bin/bash
#
# 文档说明: https://www.showdoc.cc/page/741656402509783
#
api_key="e081b146bc63e8a7ce7dd0a9d20f51f02007728815" #api_key
api_token="6fc64537f8759801e3f71ad123fa84621843745226" #api_token
url="https://www.showdoc.cc/server/?s=/api/open/fromComments" #同步到的url。使用www.showdoc.cc的不需要修改,使用开源版的请修改
#
#
#
#
#
#
# 如果第一个参数是目录,则使用参数目录。若无,则使用脚本所在的目录。
if [[ -z "$1" ]] || [[ ! -d "$1" ]] ; then #目录判断,如果$1不是目录或者是空,则使用当前目录
curren_dir=$(dirname $(readlink -f $0))
else
curren_dir=$(cd $1; pwd)
fi
#echo "$curren_dir"
# 递归搜索文件
searchfile() {
old_IFS="$IFS"
IFS=$'\n' #IFS修改
for chkfile in $1/*
do
filesize=`ls -l $chkfile | awk '{ print $5 }'`
maxsize=$((1024*1024*1)) # 1M以下的文本文件才会被扫描
if [[ -f "$chkfile" ]] && [ $filesize -le $maxsize ] && [[ -n $(file $chkfile | grep text) ]] ; then # 只对text文件类型操作
echo "正在扫描 $chkfile"
result=$(sed -n -e '/\/\*\*/,/\*\//p' $chkfile | grep showdoc) # 正则匹配
if [ ! -z "$result" ] ; then
txt=$(sed -n -e '/\/\*\*/,/\*\//p' $chkfile)
#echo "sed -n -e '/\/\*\*/,/\*\//p' $chkfile"
#echo $result
if [[ $txt =~ "@url" ]] && [[ $txt =~ "@title" ]]; then
echo -e "\033[32m $chkfile 扫描到内容 , 正在生成文档 \033[0m "
# 通过接口生成文档
curl -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' "${url}" --data-binary @- <<CURL_DATA
from=shell&api_key=${api_key}&api_token=${api_token}&content=${txt}
CURL_DATA
fi
fi
fi
if [[ -d $chkfile ]] ; then
searchfile $chkfile
fi
done
IFS="$old_IFS"
}
#执行搜索
searchfile $curren_dir
#
sys=$(uname)
if [[ $sys =~ "MS" ]] || [[ $sys =~ "MINGW" ]] || [[ $sys =~ "win" ]] ; then
read -s -n1 -p "按任意键继续 ... " # win环境下为照顾用户习惯,停顿一下
fi
1
https://gitee.com/youheone_1668751282/atl_cloud_api.git
git@gitee.com:youheone_1668751282/atl_cloud_api.git
youheone_1668751282
atl_cloud_api
atl_cloud_api
master

搜索帮助