VirtualBox

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

Last change on this file since 106165 was 106061, checked in by vboxsync, 2 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1#!/usr/bin/env kmk_ash
2# $Id: dita-refentry-flat-to-single-topic.sh 106061 2024-09-16 14:03:52Z 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-2024 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 refentry.kmk file where the DITA file list will be appended.
37# 5: Variable name to update in refentry.kmk.
38# 6: The out directory.
39# 7: '--'
40# 8+: xsltproc invocation (sans output, input and xslt file).
41#
42if test $# -lt 8; then
43 echo "syntax error: too few arguments" 1>&2;
44 exit 2;
45fi
46MY_INPUT_FILE="$1"
47MY_XSLT_TOPIC_IDS="$2"
48MY_XSLT_TO_SINGLE_TOPIC="$3"
49MY_GENERATED_KMK="$4"
50MY_GENERATED_KMK_VARIABLE="$5"
51MY_OUTPUT_DIR="$6"
52if test "$7" != "--"; then
53 echo "syntax error: Expected '--' as the 7th parameter, got: $7" 1>&2;
54 exit 2;
55fi
56shift 7
57
58if ! test -f "${MY_INPUT_FILE}"; then
59 echo "error: Input file does not exists or is not a regular file: ${MY_INPUT_FILE}" 1>&2;
60 exit 1;
61fi
62if ! test -f "${MY_XSLT_TOPIC_IDS}"; then
63 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;
64 exit 1;
65fi
66if ! test -f "${MY_XSLT_TO_SINGLE_TOPIC}"; then
67 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;
68 exit 1;
69fi
70if ! test -d "${MY_OUTPUT_DIR}"; then
71 echo "error: Destination directory does not exists or not a directory: ${MY_OUTPUT_DIR}" 1>&2;
72 exit 1;
73fi
74
75# Exit on failure.
76set -e
77
78#
79# First get the ID list from it.
80#
81MY_TOPIC_IDS=$($* "${MY_XSLT_TOPIC_IDS}" "${MY_INPUT_FILE}")
82
83echo "${MY_GENERATED_KMK_VARIABLE} += \\" > "${MY_GENERATED_KMK}"
84
85#
86# Extract each topic.
87#
88for MY_ID in ${MY_TOPIC_IDS};
89do
90 $* \
91 --stringparam g_sMode topic \
92 --stringparam g_idTopic "${MY_ID}" \
93 --output "${MY_OUTPUT_DIR}/${MY_ID}.dita" "${MY_XSLT_TO_SINGLE_TOPIC}" "${MY_INPUT_FILE}"
94 echo " ${MY_OUTPUT_DIR}/${MY_ID}.dita \\" >> "${MY_GENERATED_KMK}"
95done
96
97echo "" >> "${MY_GENERATED_KMK}"
98exit 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