VirtualBox

source: vbox/trunk/doc/manual/dita-refentry-flat-to-single-topic.sh@ 100077

Last change on this file since 100077 was 99514, checked in by vboxsync, 20 months ago

manual: Added the changelog to the (DITA) manual. bugref:10302

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.6 KB
Line 
1#!/usr/bin/env kmk_ash
2# $Id: dita-refentry-flat-to-single-topic.sh 99514 2023-04-22 01:59:25Z vboxsync $
3## @file
4# Helper Script for splitting up a convert manpage into separate topic
5# files (named by @id).
6#
7
8#
9# Copyright (C) 2023 Oracle and/or its affiliates.
10#
11# This file is part of VirtualBox base platform packages, as
12# available from https://www.virtualbox.org.
13#
14# This program is free software; you can redistribute it and/or
15# modify it under the terms of the GNU General Public License
16# as published by the Free Software Foundation, in version 3 of the
17# License.
18#
19# This program is distributed in the hope that it will be useful, but
20# WITHOUT ANY WARRANTY; without even the implied warranty of
21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22# General Public License for more details.
23#
24# You should have received a copy of the GNU General Public License
25# along with this program; if not, see <https://www.gnu.org/licenses>.
26#
27# SPDX-License-Identifier: GPL-3.0-only
28#
29
30
31#
32# This script is very internal, so we got the following fixed position parameters:
33# 1: The input DITA file (output from docbook-refentry-to-manual-dita.xsl).
34# 2: dita-refentry-flat-topic-ids.xsl
35# 3: dita-refentry-flat-to-single-topic.xsl
36# 4: The out directory.
37# 5: '--'
38# 6+: xsltproc invocation (sans output, input and xslt file).
39#
40if test $# -lt 6; then
41 echo "syntax error: too few arguments" 1>&2;
42 exit 2;
43fi
44MY_INPUT_FILE="$1"
45MY_XSLT_TOPIC_IDS="$2"
46MY_XSLT_TO_SINGLE_TOPIC="$3"
47MY_OUTPUT_DIR="$4"
48if test "$5" != "--"; then
49 echo "syntax error: Expected '--' as the 5th parameter, got: $5" 1>&2;
50 exit 2;
51fi
52shift 5
53
54if ! test -f "${MY_INPUT_FILE}"; then
55 echo "error: Input file does not exists or is not a regular file: ${MY_INPUT_FILE}" 1>&2;
56 exit 1;
57fi
58if ! test -f "${MY_XSLT_TOPIC_IDS}"; then
59 echo "error: The given dita-refentry-flat-topic-ids.xsl file does not exists or is not a regular file: ${MY_XSLT_TOPIC_IDS}" 1>&2;
60 exit 1;
61fi
62if ! test -f "${MY_XSLT_TO_SINGLE_TOPIC}"; then
63 echo "error: The given dita-refentry-flat-to-single-topic.xsl file does not exists or is not a regular file: ${MY_XSLT_TO_SINGLE_TOPIC}" 1>&2;
64 exit 1;
65fi
66if ! test -d "${MY_OUTPUT_DIR}"; then
67 echo "error: Destination directory does not exists or not a directory: ${MY_OUTPUT_DIR}" 1>&2;
68 exit 1;
69fi
70
71# Exit on failure.
72set -e
73
74#
75# First get the ID list from it.
76#
77MY_TOPIC_IDS=$($* "${MY_XSLT_TOPIC_IDS}" "${MY_INPUT_FILE}")
78
79#
80# Extract each topic.
81#
82for MY_ID in ${MY_TOPIC_IDS};
83do
84 $* \
85 --stringparam g_sMode topic \
86 --stringparam g_idTopic "${MY_ID}" \
87 --output "${MY_OUTPUT_DIR}/${MY_ID}.dita" "${MY_XSLT_TO_SINGLE_TOPIC}" "${MY_INPUT_FILE}"
88done
89exit 0
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette