• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2
3# Copyright 2011 Google Inc. All Rights Reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#     http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17set -o errexit
18set -o nounset
19
20STATUS=0
21
22# Print each of its arguments on stderr (one per line) prefixed by the
23# basename of this script.
24stderr()
25{
26  local me=$(basename "$0")
27  local i
28  for i
29  do
30    echo >&2 "$me: $i"
31  done
32}
33
34# Print each of its arguments on stderr (one per line) prefixed by the
35# basename of this script and 'error'.
36error()
37{
38  local i
39  for i
40  do
41    stderr "error: $i"
42  done
43  STATUS=1
44}
45
46generate_header()
47{
48  cat <<EOF
49/**
50 * \\mainpage
51EOF
52}
53
54generate_footer()
55{
56  cat <<EOF
57 */
58EOF
59}
60
61include_file()
62{
63  local file="$1"
64  if ! [ -r "$file" ]
65  then
66    error "'$file' is not readable."
67    return
68  fi
69  cat <<EOF
70 * \\section $file
71 * \\verbatim
72EOF
73  cat < "$file"
74  cat <<EOF
75 \\endverbatim
76EOF
77}
78
79if [ $# -eq 0 ]
80then
81  echo >&2 "usage: $0 inputs..."
82  exit 1
83fi
84
85generate_header
86for i in "$@"
87do
88  include_file "$i"
89done
90generate_footer
91
92exit $STATUS
93