File: gen_rst_index

package info (click to toggle)
intel-gpu-tools 2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 63,360 kB
  • sloc: xml: 781,458; ansic: 360,567; python: 8,336; yacc: 2,781; perl: 1,196; sh: 1,177; lex: 487; asm: 227; lisp: 35; makefile: 30
file content (43 lines) | stat: -rwxr-xr-x 922 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash -e
# SPDX-License-Identifier: (GPL-2.0 OR MIT)

## Copyright (C) 2023    Intel Corporation                 ##
## Author: Mauro Carvalho Chehab <mchehab@kernel.org>      ##
##                                                         ##
## Small script to produce a ReST index file               ##

if [ $# -lt 3 ]; then
	echo 'Usage: $0: <title> <files> <dest_dir>' >&2
	exit 1
fi

title=$1
shift

args=( "$@" )

dest_dir=${args[${#args[@]}-1]}
unset args[${#args[@]}-1]

if [ ! -d $dest_dir ]; then
	echo "Error: $dest_dir directory doesn't exist" >&2
	exit 1
fi

dest_file="$dest_dir/index.rst"

echo $title > "$dest_file"
len=${#title}
for i in $(seq 1 $len); do
	echo -n "=" >> "$dest_file"
done
echo >> "$dest_file"
echo >> "$dest_file"

echo ".. toctree::" >> "$dest_file"
echo "   :maxdepth: 1" >> "$dest_file"
echo >> "$dest_file"

for i in "${!args[@]}"; do
	echo "   ${args[$i]}" >> "$dest_file"
done