aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAkianonymus <anonymus.aki@gmail.com>2022-08-28 12:30:35 +0530
committerAkianonymus <anonymus.aki@gmail.com>2022-09-03 17:24:25 +0530
commit28b41de2f491ef598197823c04fc7e86ae76a625 (patch)
treeb480ea1c0f58e4802e92a6de9baf26f27b6e855d /scripts
parentfeat: Incremental highlight loading (diff)
fragment | Implement better autocmd management | refactor
add a all_buffers option - colorizer will activate on all buffers, empty or not, still respect filetypes option handle errors when detach is called multiple times from the same buffer use bufdelete and bufdelete to remove the autocmds use a more efficient compile parse_fn function use custom ldoc template to generate vim help
Diffstat (limited to 'scripts')
-rw-r--r--scripts/gen_docs.sh69
1 files changed, 69 insertions, 0 deletions
diff --git a/scripts/gen_docs.sh b/scripts/gen_docs.sh
new file mode 100644
index 0000000..3363d42
--- /dev/null
+++ b/scripts/gen_docs.sh
@@ -0,0 +1,69 @@
+#!/usr/bin/env bash
+
+create_vim_doc() (
+ local project_name="${1:?}"
+ local target="${2:?}"
+ local template="${3:?}"
+ local cur_dir
+ cur_dir="$(pwd)"
+
+ if [[ -d "${target}" ]]; then
+ cp "${template}" "${TMP_DIR}/ldoc.ltp" || return 1
+ else
+ echo "No such template exists"
+ return 1
+ fi
+
+ if [[ -d "${target}" ]]; then
+ ldoc -p "${project_name}" -t "${project_name} Docs" -u "${target}" -l "${TMP_DIR}" -d "${TMP_DIR}" || cleanup
+ cd "${TMP_DIR}/modules" || exit 1
+ cat "${project_name}".html "${project_name}"*.*.html >"${project_name}".txt || cleanup
+ elif [[ -f "${target}" ]]; then
+ ldoc -p "${project_name}" -t "${project_name} Docs" -u "${target}" -l "${TMP_DIR}" -d "${TMP_DIR}" || cleanup
+ cd "${TMP_DIR}" || exit 1
+ cat index.html >"${project_name}".txt || cleanup
+ else
+ echo "Invalid target"
+ return 1
+ fi
+ echo "vim:tw=80:ts=8:noet:ft=help:norl:" >>"${project_name}".txt
+ # format each line to be within 80 columns
+ # replace <pre> and </pre> with > and < respectively
+ # Sometimes running the command one time is not enough, reason unknown
+ nvim --headless +"set tw=80" \
+ +'%norm gqq' \
+ +'%norm gqq' \
+ +'%s/<pre>/>/g' \
+ +'%s/<\/pre>/</g' \
+ "${project_name}".txt \
+ +"wqa" || {
+ echo "Coundn't format with nvim, but help file be placed"
+ }
+ mkdir -p "${cur_dir}/doc"
+ cp "${project_name}".txt "${cur_dir}/doc/${project_name}.txt" || cleanup
+ echo
+ echo "${cur_dir}/doc/${project_name}.txt" created
+
+ return 0
+)
+
+main() {
+ TMP_DIR="$(mktemp -d)"
+
+ cleanup() { rm -rf "${TMP_DIR}" exit 0; }
+
+ project_name="colorizer"
+ if command -v ldoc 1>/dev/null; then
+ # html docs
+ ldoc -f discount -p "${project_name}" -t "${project_name} Docs" -u lua "${@}" -s doc || cleanup
+
+ # vim docs
+ create_vim_doc "${project_name}" lua doc/ldoc_vim.ltp || cleanup
+ else
+ echo "Error: Install ldoc first"
+ fi
+
+ cleanup
+}
+
+main "${@}"