2021-09-04 15:05:37 +00:00
|
|
|
#!/bin/zsh
|
|
|
|
# This script is used to build all the documentation.
|
|
|
|
|
|
|
|
# TODO: create options for generating different file types (pdf, html or utf8 to console/file).
|
|
|
|
# Prompt user at the start for what type they want.
|
|
|
|
|
2021-09-06 16:29:37 +00:00
|
|
|
# Specify the file paths, in the order where they should be built.
|
2021-09-22 08:50:23 +00:00
|
|
|
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')
|
2021-09-06 16:29:37 +00:00
|
|
|
|
2021-09-04 16:50:58 +00:00
|
|
|
# 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
|
|
|
|
|
2021-09-04 15:05:37 +00:00
|
|
|
# Get the initial root.
|
|
|
|
root_directory=$(pwd)
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
# Get the input and output file names.
|
|
|
|
input_file=$(basename $i)
|
2021-09-04 16:50:58 +00:00
|
|
|
output_file=$(echo $input_file | sed "s/ms/$filetype/")
|
2021-09-04 15:05:37 +00:00
|
|
|
|
|
|
|
# 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.
|
2021-09-06 16:29:37 +00:00
|
|
|
groff -ms -T$filetype $input_file > $output_file
|
2021-09-04 15:05:37 +00:00
|
|
|
|
|
|
|
# Go back up to the root.
|
|
|
|
cd $root_directory
|
|
|
|
done
|