63 lines
1.7 KiB
Bash
Executable File
63 lines
1.7 KiB
Bash
Executable File
#!/bin/zsh
|
|
# This script is used to build all the documentation.
|
|
|
|
# Specify the output directory's name.
|
|
outputdir="pdf_out"
|
|
|
|
# Specify the file paths, in the order where they should be built.
|
|
filepaths=('nodes/single_node.h.ms' 'nodes/double_node.h.ms' 'nodes/tree_node.h.ms' 'strings/strzcpy.ms' 'stack/stack.h.ms' 'linked_lists/double_linked_list.h.ms' 'linked_lists/single_linked_list.h.ms' 'utils/time_function.h.ms' 'trees/binary_tree/binary_tree.h.ms' 'misc_algorithms/search/binary_search.h.ms')
|
|
|
|
# Prompt the user for the option they want (pdf/html/utf8).
|
|
echo "Please choose an output option: pdf, html or utf8."
|
|
select choice in "pdf" "html" "utf8"; do
|
|
case $choice in
|
|
pdf )
|
|
filetype="pdf";
|
|
break;;
|
|
|
|
html )
|
|
filetype="html";
|
|
break;;
|
|
|
|
utf8 )
|
|
filetype="utf8";
|
|
break;;
|
|
esac
|
|
done
|
|
|
|
# Debug print.
|
|
#echo $filetype
|
|
|
|
# Get the initial root.
|
|
root_directory=$(pwd)
|
|
|
|
# Create a directory to store the PDFs.
|
|
mkdir -p $root_directory/
|
|
|
|
# Loop over the paths: change directory, build, go back up to the root directory.
|
|
for i in $filepaths; do
|
|
# Get the current directory that we should change into, from the current array variable.
|
|
current_directory=$(dirname $i)
|
|
cd $current_directory
|
|
|
|
# Create the current output directory.
|
|
# TODO: Finish working on this, needs a way to figure the paths out!
|
|
|
|
# Get the input and output file names.
|
|
input_file=$(basename $i)
|
|
output_file=$(echo $input_file | sed "s/ms/$filetype/")
|
|
|
|
# Debug prints.
|
|
#echo "current_directory = $current_directory"
|
|
#echo "input_file = $input_file"
|
|
#echo "output_file = $output_file"
|
|
|
|
# Create the output file.
|
|
touch $output_file
|
|
# Generate docs.
|
|
groff -ms -T$filetype $input_file > $output_file
|
|
|
|
# Go back up to the root.
|
|
cd $root_directory
|
|
done
|