#!/bin/bash

shopt -s expand_aliases

alias ~=”:«’~bash’”

:«’~~~bash’

Usage

./buildDoc.md

Introduction

Generate the github pages documentation for this project. The documentation for core/Rearrangement is generated by doxygen. bash shells are transformed to executable markdown by the track at here. awk and perl scripts are wrapped by the corresponding code block in markdown.

Source

add_header()
{
    title=$1
    permalink=$2
    sed "1i ---\ntitle: \"$title\"\npermalink: $permalink\ntoc: true\n---\n"
}

wrap_script()
{
    script_type=$1
    sed -e "1i ~~~$script_type" -e '$a~~~'
}

# Failure stop the execution.
set -e

add_header "Quick start" "/quick-start/" < README.md > docs/_docs/README.md

add_header "Remove duplicates" "/core/remove-duplicates/" < core/removeDuplicates.md > docs/_docs/removeDuplicates.md

add_header "Demultiplex" "/core/demultiplex/" < core/demultiplex/demultiplex.md > docs/_docs/demultiplex.md
wrap_script awk < core/demultiplex/getAlignPos.awk | add_header "Get alignment position" "/core/demultiplex/get-alignment-position/" > docs/_docs/getAlignPos.awk.md

add_header "Chimeric alignment" "/core/rearr/" < core/Rearrangement/rearr.md > docs/_docs/rearr.md
wrap_script awk < core/Rearrangement/correct_micro_homology.awk | add_header "Correct micro-homology" "/core/rearr/correct-micro-homology/" > docs/_docs/correct_micro_homology.awk.md
mkdir -p docs/core/rearr
cd core/Rearrangement
doxygen
cd -

add_header "Shi Xing extract spliter" "/sx/sx-extract-spliter/" < sx/sxExtractSpliter.md > docs/_docs/sxExtractSpliter.md

add_header "Shi Xing post-process from demultiplex to rearr" "/sx/sx-cut-r2-adapter-filter-cumulate/" < sx/sxCutR2AdapterFilterCumulate/sxCutR2AdapterFilterCumulate.md > docs/_docs/sxCutR2AdapterFilterCumulate.md
wrap_script awk < sx/sxCutR2AdapterFilterCumulate/sxCumulateToMapCutAdaptSpliter.awk | add_header "Accumulate adjacent duplicated queries" "/sx/sx-cut-r2-adapter-filter-cumulate/sx-cumulate-to-map-cut-adapt-spliter/" > docs/_docs/sxCumulateToMapCutAdaptSpliter.awk.md

add_header "Get Shi Xing csvfile reference" "/sx/get-sx-csvfile-ref/" < sx/getSxCsvFileRef/getSxCsvFileRef.md > docs/_docs/getSxCsvFileRef.md
wrap_script perl < sx/getSxCsvFileRef/getSxCsvFileTarget.pl | add_header "Get Shi Xing csvfile target" "/sx/get-sx-csvfile-ref/get-sx-csvfile-target/" > docs/_docs/getSxCsvFileTarget.pl.md
wrap_script awk < sx/getSxCsvFileRef/sxTargetSam2Bed.awk | add_header "Shi Xing target sam to bed" "/sx/get-sx-csvfile-ref/sx-target-sam-2-bed/" > docs/_docs/sxTargetSam2Bed.awk.md
wrap_script perl < sx/getSxCsvFileRef/getSxRefFile.pl | add_header "Get Shi Xing reference file" "/sx/get-sx-csvfile-ref/get-sx-ref-file/" > docs/_docs/getSxRefFile.pl.md

add_header "Build documentation" "/others/build-doc/" < buildDoc.md > docs/_docs/buildDoc.md

add_header "Compose script" "/others/compose/" < compose.md > docs/_docs/compose.md
wrap_script yaml < compose.yaml | add_header "Compose yaml" "/others/compose/yaml" > docs/_docs/compose.yaml.md

add_header "Install" "/others/install/" < install.md > docs/_docs/install.md

add_header "Login worker" "/other/login-worker/" < loginWorker.md > docs/_docs/loginWorker.md

add_header "Run work flow" "/other/run-work-flow/" < runWorkFlow.md > docs/_docs/runWorkFlow.md
wrap_script makefile < workFlow.mak | add_header "Work flow" "/other/run-work-flow/work-flow/" > docs/_docs/workFlow.mak.md
alias ~~~=":" # This suppresses a warning and is not part of source.