Files
hugotags/hugotags.sh

47 lines
743 B
Bash
Raw Permalink Normal View History

2025-05-29 17:55:42 -04:00
#!/usr/bin/bash
set -euo pipefail
hugo_docs_path="$1"
cd "$hugo_docs_path"
add_tag() {
2025-05-30 14:34:18 -04:00
local tagname fname
tagname="$1"
fname="$2"
2025-05-29 17:55:42 -04:00
2025-05-30 14:34:18 -04:00
# Tags file format: https://vimhelp.org/tagsrch.txt.html#ctags
printf "%s\t%s\t2\n" "$tagname" "$hugo_docs_path/$fname"
2025-05-29 17:55:42 -04:00
}
add_methods() {
2025-05-30 14:34:18 -04:00
local f title
2025-05-29 17:55:42 -04:00
2025-05-30 14:34:18 -04:00
for f in methods/*/*md; do
2025-05-29 17:55:42 -04:00
2025-05-30 14:34:18 -04:00
title="$(yq --front-matter extract .title "$f")"
add_tag "$title" "$f"
done
2025-05-29 17:55:42 -04:00
}
add_funcs() {
2025-05-30 14:34:18 -04:00
local f halias
2025-05-29 17:55:42 -04:00
2025-05-30 14:34:18 -04:00
for f in functions/*/*md; do
2025-05-29 17:55:42 -04:00
2025-05-30 14:34:18 -04:00
add_tag "$(basename "${f%.md}")" "$f"
2025-05-29 17:55:42 -04:00
2025-05-30 14:34:18 -04:00
halias="$(yq --front-matter extract .params.functions_and_methods.aliases[0] "$f")"
2025-05-29 17:55:42 -04:00
2025-05-30 14:34:18 -04:00
if [ "$halias" != "null" ]; then
add_tag "$halias" "$f"
fi
done
2025-05-29 17:55:42 -04:00
}
2025-05-30 14:34:18 -04:00
{
add_methods
add_funcs
} | grep -v _index.md | sort --ignore-case