forked from llvm/mlir-www
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopy_docs.sh
executable file
·38 lines (34 loc) · 974 Bytes
/
copy_docs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash -exu
input_path=$1
output_path=$2
find $input_path -type d | grep -v includes/img | while read dir ; do
destdir=`realpath --relative-to=$input_path "$dir"`
mkdir -p "${output_path}/$destdir"
if ls $dir/*.md 1> /dev/null 2>&1; then
cat > "${output_path}/$destdir/_index.md" <<EOF
---
title: "${destdir##*/}"
date: 2019-11-29T15:26:15Z
draft: false
---
EOF
fi
done
cat > "${output_path}/_index.md" <<EOF
---
title: "Code Documentation"
date: 2019-11-29T15:26:15Z
draft: false
---
EOF
find $input_path -name "*.md" | while read file ; do
file=$(realpath --relative-to=$input_path $file)
title=$(grep -m 1 "^# " $input_path/$file | sed 's/^# //' ) &&
(echo "---" &&
echo "title: \"$title\"" &&
echo "date: 1970-01-01T00:00:00Z" &&
echo "draft: false" &&
echo "---" &&
grep -v "^# " $input_path/$file | sed 's|\[TOC\]|<p/>{{< toc >}}|' ) > $output_path/$file &&
echo "Processed $file"
done