mirror of
https://github.com/LouisShark/chatgpt_system_prompt.git
synced 2025-07-05 22:30:37 -04:00
docs: generate toc
This commit is contained in:
parent
d00ba1c345
commit
cb20615b40
2 changed files with 79 additions and 0 deletions
21
generate_toc_for_readme.sh
Normal file
21
generate_toc_for_readme.sh
Normal file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
generate_toc() {
|
||||
local dir=$1
|
||||
local base_dir=$(pwd)
|
||||
|
||||
for file in "$dir"/*; do
|
||||
if [ -d "$file" ]; then
|
||||
local dir_name=$(basename "$file")
|
||||
echo "- [$dir_name](#$dir_name)"
|
||||
echo " $(generate_toc "$file")"
|
||||
elif [ -f "$file" ] && [[ $file == *.md ]]; then
|
||||
local title=$(basename "$file" .md)
|
||||
local link=$(echo "$file" | sed "s|^$base_dir/||")
|
||||
local encoded_link=$(python -c "import urllib.parse; print(urllib.parse.quote('''$link'''))")
|
||||
echo " - [$title]($encoded_link)"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
generate_toc .
|
Loading…
Add table
Add a link
Reference in a new issue