Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerome committed Oct 20, 2020
1 parent 2dc7729 commit 0eed8a6
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 68 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ RUN wget $(curl -s https://api.github.com/repos/mikefarah/yq/releases/latest | g

# ----- DocsAsCode -----

ADD scripts/docsascode/*.tex /usr/local/bin/templates/
# ADD scripts/docsascode/*.tex /usr/local/bin/templates/
ADD scripts/docsascode/*.lua /usr/local/bin/templates/
ADD scripts/docsascode/*.sh /usr/local/bin/

Expand Down
6 changes: 1 addition & 5 deletions outputs/build.dac
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@
# set -xe

function process {
echo "nothing to process"
}

function postprocess {
echo "nothing to postprocess"
printf "nothing to process\n"
}
13 changes: 3 additions & 10 deletions outputs/document/build.dac
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,10 @@ function process {

asciidoctor-pdf "${cmd_args[@]}" "$source_folder/.$filename.adoc"

echo " → file generated: "$output_file_prefix$filename.pdf
}

function postprocess {
local input_file=$1
local source_folder=$2
local destination_folder=$3
local filename=$4

rm -rf $destination_folder/.asciidoctor/
rm -f $source_folder/.$filename.adoc

chown $PID:$GID $destination_folder/$output_file_prefix$filename.pdf
}

echo $output_file_prefix$filename.pdf
}
11 changes: 2 additions & 9 deletions outputs/note/build.dac
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,10 @@ function process {

asciidoctor-pdf "${cmd_args[@]}" "$source_folder/.$filename.adoc"

echo " → file generated: "$output_file_prefix$filename.pdf
}

function postprocess {
local input_file=$1
local source_folder=$2
local destination_folder=$3
local filename=$4

rm -rf $destination_folder/.asciidoctor/
rm -f $source_folder/.$filename.adoc

chown $PID:$GID $destination_folder/$output_file_prefix$filename.pdf

echo $output_file_prefix$filename.pdf
}
11 changes: 2 additions & 9 deletions outputs/slides/build.dac
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,10 @@ function process {

asciidoctor-pdf "${cmd_args[@]}" "$source_folder/.$filename.adoc"

echo " → file generated: "$output_file_prefix$filename.pdf
}

function postprocess {
local input_file=$1
local source_folder=$2
local destination_folder=$3
local filename=$4

rm -rf $destination_folder/.asciidoctor/
rm -f $source_folder/.$filename.adoc

chown $PID:$GID $destination_folder/$output_file_prefix$filename.pdf

echo $output_file_prefix$filename.pdf
}
14 changes: 4 additions & 10 deletions outputs/slides/html/build.dac
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,13 @@ function process {
asciidoctor-revealjs $options_diagram $options_style $options_higlighter $source_folder/.$filename.adoc $options_output
chmod -R a+w $custom_destination_folder/

echo " → file generated: "$filename.html

decktape automatic $custom_destination_folder/$filename.html $custom_destination_folder/$filename.pdf >> /dev/null
echo " → file generated: "$filename.pdf
}

function postprocess {
local input_file=$1
local source_folder=$2
local destination_folder=$3
local filename=$4
# decktape automatic $custom_destination_folder/$filename.html $custom_destination_folder/$filename.pdf >> /dev/null
# echo " → file generated: "$filename.pdf

rm -f $source_folder/.$filename.adoc

chown $PID:$GID $custom_destination_folder/$filename.html $custom_destination_folder/$filename.pdf

echo $filename.html
}
4 changes: 2 additions & 2 deletions scripts/docsascode/2asciidoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
source yq_functions.sh

if [ "$#" -ne 2 ]; then
echo "Illegal number of parameters"
printf "Illegal number of parameters\n"
exit -1
fi

Expand Down Expand Up @@ -69,7 +69,7 @@ case "$1" in
;;

*)
echo "extension not supported. only rst,md and adoc."
printf "extension not supported. only rst,md and adoc.\n"
exit -1
;;
esac
Expand Down
4 changes: 2 additions & 2 deletions scripts/docsascode/2md.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# set -xe

if [ "$#" -ne 2 ]; then
echo "Illegal number of parameters"
printf "Illegal number of parameters\n"
exit -1
fi

Expand All @@ -27,7 +27,7 @@ case "$1" in
;;

*)
echo "extension not supported. only rst,md, adoc."
printf "extension not supported. only rst,md, adoc.\n"
exit -1
;;
esac
Expand Down
4 changes: 2 additions & 2 deletions scripts/docsascode/2rst.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# set -xe

if [ "$#" -ne 2 ]; then
echo "Illegal number of parameters"
printf "Illegal number of parameters\n"
exit -1
fi

Expand All @@ -20,7 +20,7 @@ case "$1" in
;;

*)
echo "extension not supported. only rst,md, adoc."
printf "extension not supported. only rst,md, adoc.\n"
exit -1
;;
esac
Expand Down
21 changes: 14 additions & 7 deletions scripts/docsascode/buildDoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ function build_doc {

[[ ! -z "$DEFAULT_DESTINATION" ]] && destination_folder=$DEFAULT_DESTINATION

echo "process file: "$filenameWithExtension
printf "process file: "$filenameWithExtension"\n"

# prepare outputs
initMeta $input_file
local meta_outputs=( $(readInMeta keywords $DEFAULT_OUTPUT) )

local meta_outputs=$(readInMeta keywords $DEFAULT_OUTPUT)
meta_outputs=(${meta_outputs//,/ })

# clean array
declare -a outputs_arr
for output in "${meta_outputs[@]}"; do
Expand Down Expand Up @@ -83,7 +85,7 @@ function build_doc {
# cp basic asciidoctor themes for dac theme extend
cp -rf $(gem environment gemdir)/gems/asciidoctor-pdf-$ASCIIDOCTOR_PDF_VERSION/data/themes/* $current_output_template_path/

echo " - process output: "$output
printf " - process output: "$output"\n"

# prepare to launch commands to produce output
rm -f $ymlFile
Expand All @@ -94,16 +96,21 @@ function build_doc {
source $current_output_template_path/build.dac

# launch process
process $input_file $pathname $destination_folder $filenameNoExtension
postprocess $input_file $pathname $destination_folder $filenameNoExtension
resultFile=$(process $input_file $pathname $destination_folder $filenameNoExtension)

if [ -f $destination_folder/$resultFile ]; then
printf " → file generated: "$resultFile"\n"
generatedFiles+=( "$destination_folder$resultFile" )
else
printf " → NO file generated\n"
fi

# clear temp folder
rm -rf $current_output_template_path
done

# remove ouput copy
rm -rf /_output/

}

[[ -z "$DEFAULT_OUTPUT" ]] && DEFAULT_OUTPUT=output.document
Expand All @@ -121,7 +128,7 @@ do
shift
;;
*)
echo "extension not supported. only rst,md, adoc."
printf "extension not supported. only rst,md, adoc.\n"
exit -1
;;
esac
Expand Down
4 changes: 2 additions & 2 deletions scripts/docsascode/checkDoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function check_doc {

source $current_exe_folder/check.dac

echo -e "\nprocess file: "$1
printf "\nprocess file: "$1"\n"

#merge all .dict file into a single with pws header and remove blank lines
cat $current_exe_folder/*.dict >> $current_exe_folder/.GLOBAL.dict 2>/dev/null
Expand Down Expand Up @@ -105,7 +105,7 @@ do
shift
;;
*)
echo "extension not supported. only rst,md, adoc."
printf "extension not supported. only rst,md, adoc.\n"
exit -1
;;
esac
Expand Down
8 changes: 7 additions & 1 deletion scripts/docsascode/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
#! /bin/bash
# set -xe

declare -a generatedFiles

case $1 in
build) shift
# init list of generated files
# launch build of files
source buildDoc.sh $*
# return generated files list
# echo ${generatedFiles[@]}
;;
check) shift
source checkDoc.sh $*
;;
assemble) shift
source assembleDoc.sh $*
;;
*) echo "usage : build sourcefiles\n check sourcefiles";;
*) printf "usage : build sourcefiles\n check sourcefiles\nassemble pdfFiles\n";;
esac
4 changes: 2 additions & 2 deletions scripts/docsascode/meta_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metaFile=/tmp/meta.yml

function initMeta {
if [ "$#" -ne 1 ]; then
echo "Illegal number of parameters"
printf "Illegal number of parameters\n"
exit -1
fi

Expand Down Expand Up @@ -34,7 +34,7 @@ function initMeta {
;;

*)
echo "extension not supported. only rst,md, adoc."
printf "extension not supported. only rst,md, adoc.\n"
exit -1
;;
esac
Expand Down
12 changes: 6 additions & 6 deletions scripts/docsascode/yq_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ function testreadVarInYml {
printf "a:\n b: c\n e: ~\n" > $ymlFile

cat $ymlFile
if [ "$(readVarInYml a.b D)" != 'c' ]; then echo "exit 1: $(readVarInYml a.b D)"; fi
if [ "$(readVarInYml a.b)" != 'c' ]; then echo "exit 2: $(readVarInYml a.b)"; fi
if [ "$(readVarInYml a.c D)" != 'D' ]; then echo "exit 3: $(readVarInYml a.c D)"; fi
if [ "$(readVarInYml a.c)" != '' ]; then echo "exit 4: $(readVarInYml a.c)"; fi
if [ "$(readVarInYml a.e D)" != 'D' ]; then echo "exit 5: $(readVarInYml a.e D)"; fi
if [ "$(readVarInYml a.e)" != '' ]; then echo "exit 6: $(readVarInYml a.e)"; fi
if [ "$(readVarInYml a.b D)" != 'c' ]; then printf "exit 1: $(readVarInYml a.b D)\n"; fi
if [ "$(readVarInYml a.b)" != 'c' ]; then printf "exit 2: $(readVarInYml a.b)\n"; fi
if [ "$(readVarInYml a.c D)" != 'D' ]; then printf "exit 3: $(readVarInYml a.c D)\n"; fi
if [ "$(readVarInYml a.c)" != '' ]; then printf "exit 4: $(readVarInYml a.c)\n"; fi
if [ "$(readVarInYml a.e D)" != 'D' ]; then printf "exit 5: $(readVarInYml a.e D)\n"; fi
if [ "$(readVarInYml a.e)" != '' ]; then printf "exit 6: $(readVarInYml a.e)\n"; fi

rm -rf /tmp/test.yml
ymlFile=$tmpYmlFile
Expand Down

0 comments on commit 0eed8a6

Please sign in to comment.