Gentoo Archives: gentoo-dev

From: Anna Vyalkova <cyber+gentoo@×××××.in>
To: gentoo-dev@l.g.o
Cc: vim@g.o
Subject: [gentoo-dev] [PATCH v5 7/9] vim-doc.eclass: document update_vim_helptags
Date: Mon, 11 Apr 2022 12:35:58
Message-Id: 20220411123306.24750-8-cyber+gentoo@sysrq.in
In Reply to: [gentoo-dev] [PATCH v5 0/9] Vim eclasses by Anna Vyalkova
1 Signed-off-by: Anna Vyalkova <cyber+gentoo@×××××.in>
2 ---
3 eclass/vim-doc.eclass | 4 ++++
4 1 file changed, 4 insertions(+)
5
6 diff --git a/eclass/vim-doc.eclass b/eclass/vim-doc.eclass
7 index 968f4657b6..119ce79307 100644
8 --- a/eclass/vim-doc.eclass
9 +++ b/eclass/vim-doc.eclass
10 @@ -1,100 +1,104 @@
11 # Copyright 1999-2022 Gentoo Authors
12 # Distributed under the terms of the GNU General Public License v2
13
14 # @ECLASS: vim-doc.eclass
15 # @MAINTAINER:
16 # vim@g.o
17 # @SUPPORTED_EAPIS: 6 7 8
18 # @BLURB: Eclass for vim{,-plugin}.eclass to update documentation tags.
19 # @DESCRIPTION:
20 # This eclass is used by vim.eclass and vim-plugin.eclass to update
21 # the documentation tags. This is necessary since vim doesn't look in
22 # /usr/share/vim/vimfiles/doc for documentation; it only uses the
23 # versioned directory, for example /usr/share/vim/vim62/doc
24 #
25 # We depend on vim being installed, which is satisfied by either the
26 # DEPEND in vim-plugin or by whatever version of vim is being
27 # installed by the eclass.
28
29 case ${EAPI} in
30 6|7|8) ;;
31 *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
32 esac
33
34 if [[ ! ${_VIM_DOC_ECLASS} ]] ; then
35
36 +# @FUNCTION: update_vim_helptags
37 +# @USAGE:
38 +# @DESCRIPTION:
39 +# Update the documentation tags in the versioned Vim directory.
40 update_vim_helptags() {
41 debug-print-function ${FUNCNAME} "${@}"
42
43 local vimfiles helpfile files vim d
44
45 # This is where vim plugins are installed
46 vimfiles="${EROOT}"/usr/share/vim/vimfiles
47
48 if [[ ${PN} != vim-core ]]; then
49 # Find a suitable vim binary for updating tags :helptags
50 vim=$(type -P vim 2>/dev/null)
51 [[ -z "${vim}" ]] && vim=$(type -P gvim 2>/dev/null)
52 [[ -z "${vim}" ]] && vim=$(type -P kvim 2>/dev/null)
53 if [[ -z "${vim}" ]]; then
54 ewarn "No suitable vim binary to rebuild documentation tags"
55 fi
56 fi
57
58 # Make vim not try to connect to X. See :help gui-x11-start
59 # in vim for how this evil trickery works.
60 if [[ -n "${vim}" ]] ; then
61 ln -s "${vim}" "${T}/tagvim" || die
62 vim="${T}/tagvim"
63 fi
64
65 # Install the documentation symlinks into the versioned vim
66 # directory and run :helptags
67 for d in "${EROOT%/}"/usr/share/vim/vim[0-9]*; do
68 [[ -d "${d}/doc" ]] || continue # catch a failed glob
69
70 # Remove links
71 readarray -d '' files < <(find "${d}"/doc -name "*.txt" -type l -print0 || die "cannot traverse ${d}/doc" )
72 for helpfile in "${files[@]}"; do
73 if [[ $(readlink -f "${helpfile}") == "${vimfiles}"/* ]]; then
74 rm "${helpfile}" || die
75 fi
76 done
77
78 # Remove stale dirs, if possible
79 readarray -d '' files < <(find "${d}" -print0 || die "cannot traverse ${d}")
80 if [[ -f "${d}/doc/tags" && ${#files[@]} -eq 3 ]]; then
81 # /usr/share/vim/vim61
82 # /usr/share/vim/vim61/doc
83 # /usr/share/vim/vim61/doc/tags
84 einfo "Removing ${d}"
85 rm -r "${d}" || die
86 continue
87 fi
88
89 # Re-create / install new links
90 if [[ -d "${vimfiles}"/doc ]]; then
91 for helpfile in "${vimfiles}"/doc/*.txt; do
92 if [[ ! -e "${d}/doc/$(basename "${helpfile}")" ]]; then
93 ln -s "${helpfile}" "${d}/doc" || die
94 fi
95 done
96 fi
97
98 # Update tags; need a vim binary for this
99 if [[ -n "${vim}" ]]; then
100 einfo "Updating documentation tags in ${d}"
101 DISPLAY= "${vim}" -u NONE -U NONE -T xterm -X -n -f \
102 '+set nobackup nomore' \
103 "+helptags ${d}/doc" \
104 '+qa!' </dev/null &>/dev/null || die
105 fi
106 done
107
108 if [[ -n "${vim}" && -f "${vim}" ]]; then
109 rm "${vim}" || die
110 fi
111 }
112
113 _VIM_DOC_ECLASS=1
114 fi
115 --
116 2.35.1