| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# 2019 Darko Poljak (darko.poljak at gmail.com) |
| 4 |
# |
| 5 |
# This file is part of cdist. |
| 6 |
# |
| 7 |
# cdist is free software: you can redistribute it and/or modify |
| 8 |
# it under the terms of the GNU General Public License as published by |
| 9 |
# the Free Software Foundation, either version 3 of the License, or |
| 10 |
# (at your option) any later version. |
| 11 |
# |
| 12 |
# cdist is distributed in the hope that it will be useful, |
| 13 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
# GNU General Public License for more details. |
| 16 |
# |
| 17 |
# You should have received a copy of the GNU General Public License |
| 18 |
# along with cdist. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
# |
| 20 |
# |
| 21 |
# Generate cdist-types.rst that lists available types. |
| 22 |
# |
| 23 |
|
| 24 |
__cdist_pwd="$(pwd -P)" |
| 25 |
__cdist_mydir="${0%/*}"; |
| 26 |
__cdist_abs_mydir="$(cd "$__cdist_mydir" && pwd -P)" |
| 27 |
__cdist_myname=${0##*/}; |
| 28 |
__cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname" |
| 29 |
|
| 30 |
filename="${__cdist_myname%.sh}" |
| 31 |
dest="$__cdist_abs_mydir/$filename" |
| 32 |
|
| 33 |
cd "$__cdist_abs_mydir" |
| 34 |
|
| 35 |
exec > "$dest" |
| 36 |
cat << eof |
| 37 |
cdist types |
| 38 |
=========== |
| 39 |
|
| 40 |
.. toctree:: |
| 41 |
:titlesonly: |
| 42 |
|
| 43 |
eof |
| 44 |
|
| 45 |
# If there is no such file then ls prints error to stderr, |
| 46 |
# so redirect stderr to /dev/null. |
| 47 |
for type in $(ls man7/cdist-type__*.rst 2>/dev/null | LC_ALL=C sort); do |
| 48 |
no_dir="${type#man7/}"; |
| 49 |
no_type="${no_dir#cdist-type}"; |
| 50 |
name="${no_type%.rst}"; |
| 51 |
manref="${no_dir%.rst}" |
| 52 |
man="${manref}(7)" |
| 53 |
|
| 54 |
echo " $name" "<man7/${manref}>" |
| 55 |
done |