.
This commit is contained in:
294
Toolbox/docs/examples/workflow-demo.sh
Executable file
294
Toolbox/docs/examples/workflow-demo.sh
Executable file
@@ -0,0 +1,294 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# workflow-demo.sh - Demonstration script for common documentation workflows
|
||||
# Shows how to use the container with various example files
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Configuration
|
||||
IMAGE_NAME="tsysdevstack-toolboxes-docs"
|
||||
EXAMPLES_DIR="examples"
|
||||
OUTPUT_DIR="output/demo"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Function to print colored output
|
||||
print_status() {
|
||||
echo -e "${BLUE}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
print_success() {
|
||||
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
||||
}
|
||||
|
||||
print_warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
print_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# Function to check if container exists
|
||||
check_container() {
|
||||
if ! docker images | grep -q "$IMAGE_NAME"; then
|
||||
print_error "Container image '$IMAGE_NAME' not found. Please build it first:"
|
||||
echo " ./output/build.sh"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to create output directory
|
||||
setup_output() {
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
print_status "Created output directory: $OUTPUT_DIR"
|
||||
}
|
||||
|
||||
# Function to demonstrate resume generation
|
||||
demo_resume() {
|
||||
print_status "📄 Demonstrating resume generation..."
|
||||
|
||||
if docker run --rm \
|
||||
-v "$(pwd)/$EXAMPLES_DIR:/home/tsysdevstack/examples:ro" \
|
||||
-v "$(pwd)/$OUTPUT_DIR:/home/tsysdevstack/output" \
|
||||
"$IMAGE_NAME" \
|
||||
pandoc /home/tsysdevstack/examples/resume-sample.md \
|
||||
-o /home/tsysdevstack/output/resume.pdf \
|
||||
--pdf-engine=xelatex; then
|
||||
print_success "Resume generated: $OUTPUT_DIR/resume.pdf"
|
||||
else
|
||||
print_error "Failed to generate resume"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to demonstrate project documentation
|
||||
demo_project_docs() {
|
||||
print_status "📚 Demonstrating project documentation..."
|
||||
|
||||
if docker run --rm \
|
||||
-v "$(pwd)/$EXAMPLES_DIR:/home/tsysdevstack/examples:ro" \
|
||||
-v "$(pwd)/$OUTPUT_DIR:/home/tsysdevstack/output" \
|
||||
"$IMAGE_NAME" \
|
||||
pandoc /home/tsysdevstack/examples/project-plan.md \
|
||||
-o /home/tsysdevstack/output/project-plan.html \
|
||||
--standalone; then
|
||||
print_success "Project documentation generated: $OUTPUT_DIR/project-plan.html"
|
||||
else
|
||||
print_error "Failed to generate project documentation"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to demonstrate mdbook
|
||||
demo_mdbook() {
|
||||
print_status "📖 Demonstrating mdbook generation..."
|
||||
|
||||
if docker run --rm \
|
||||
-v "$(pwd)/$EXAMPLES_DIR:/home/tsysdevstack/examples:ro" \
|
||||
-v "$(pwd)/$OUTPUT_DIR:/home/tsysdevstack/output" \
|
||||
"$IMAGE_NAME" \
|
||||
bash -c "cd /home/tsysdevstack/examples/mdbook-sample && mdbook build -d /home/tsysdevstack/output/mdbook-demo"; then
|
||||
print_success "mdbook generated: $OUTPUT_DIR/mdbook-demo/"
|
||||
else
|
||||
print_error "Failed to generate mdbook"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to demonstrate typst
|
||||
demo_typst() {
|
||||
print_status "🎨 Demonstrating typst compilation..."
|
||||
|
||||
if docker run --rm \
|
||||
-v "$(pwd)/$EXAMPLES_DIR:/home/tsysdevstack/examples:ro" \
|
||||
-v "$(pwd)/$OUTPUT_DIR:/home/tsysdevstack/output" \
|
||||
"$IMAGE_NAME" \
|
||||
typst compile /home/tsysdevstack/examples/sample-typst.typ \
|
||||
/home/tsysdevstack/output/typst-demo.pdf; then
|
||||
print_success "Typst document generated: $OUTPUT_DIR/typst-demo.pdf"
|
||||
else
|
||||
print_error "Failed to compile typst document"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to demonstrate presentation
|
||||
demo_presentation() {
|
||||
print_status "🎯 Demonstrating presentation generation..."
|
||||
|
||||
if docker run --rm \
|
||||
-v "$(pwd)/$EXAMPLES_DIR:/home/tsysdevstack/examples:ro" \
|
||||
-v "$(pwd)/$OUTPUT_DIR:/home/tsysdevstack/output" \
|
||||
"$IMAGE_NAME" \
|
||||
bash -c "npx --package @marp-team/marp-cli marp /home/tsysdevstack/examples/sample-presentation.md -o /home/tsysdevstack/output/presentation.pdf"; then
|
||||
print_success "Presentation generated: $OUTPUT_DIR/presentation.pdf"
|
||||
else
|
||||
print_error "Failed to generate presentation"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to demonstrate quarto
|
||||
demo_quarto() {
|
||||
print_status "🔬 Demonstrating quarto rendering..."
|
||||
|
||||
if docker run --rm \
|
||||
-v "$(pwd)/$EXAMPLES_DIR:/home/tsysdevstack/examples:ro" \
|
||||
-v "$(pwd)/$OUTPUT_DIR:/home/tsysdevstack/output" \
|
||||
"$IMAGE_NAME" \
|
||||
quarto render /home/tsysdevstack/examples/sample-report.qmd \
|
||||
--output /home/tsysdevstack/output/quarto-report.html; then
|
||||
print_success "Quarto report generated: $OUTPUT_DIR/quarto-report.html"
|
||||
else
|
||||
print_error "Failed to render quarto report"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to demonstrate Joplin note conversion
|
||||
demo_joplin() {
|
||||
print_status "📝 Demonstrating Joplin note conversion..."
|
||||
|
||||
if docker run --rm \
|
||||
-v "$(pwd)/$EXAMPLES_DIR:/home/tsysdevstack/examples:ro" \
|
||||
-v "$(pwd)/$OUTPUT_DIR:/home/tsysdevstack/output" \
|
||||
"$IMAGE_NAME" \
|
||||
pandoc /home/tsysdevstack/examples/joplin-note-sample.md \
|
||||
-o /home/tsysdevstack/output/joplin-note.pdf \
|
||||
--pdf-engine=xelatex; then
|
||||
print_success "Joplin note converted: $OUTPUT_DIR/joplin-note.pdf"
|
||||
else
|
||||
print_error "Failed to convert Joplin note"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to demonstrate bibliography management
|
||||
demo_bibliography() {
|
||||
print_status "📚 Demonstrating bibliography management..."
|
||||
|
||||
if docker run --rm \
|
||||
-v "$(pwd)/$EXAMPLES_DIR:/home/tsysdevstack/examples:ro" \
|
||||
-v "$(pwd)/$OUTPUT_DIR:/home/tsysdevstack/output" \
|
||||
"$IMAGE_NAME" \
|
||||
bibtool -s /home/tsysdevstack/examples/sample-bibliography.bib > "$OUTPUT_DIR/cleaned-bibliography.bib"; then
|
||||
print_success "Bibliography processed: $OUTPUT_DIR/cleaned-bibliography.bib"
|
||||
else
|
||||
print_error "Failed to process bibliography"
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to show generated files
|
||||
show_results() {
|
||||
print_status "📋 Generated files:"
|
||||
if [[ -d "$OUTPUT_DIR" ]]; then
|
||||
ls -la "$OUTPUT_DIR/" || true
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to print usage
|
||||
print_usage() {
|
||||
echo "Usage: $0 [OPTIONS] [WORKFLOW...]"
|
||||
echo ""
|
||||
echo "Demonstration script for documentation workflows."
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --help, -h Show this help message"
|
||||
echo " --all Run all demonstrations (default)"
|
||||
echo " --clean Clean output directory before running"
|
||||
echo ""
|
||||
echo "Available workflows:"
|
||||
echo " resume Generate resume from markdown"
|
||||
echo " project Generate project documentation"
|
||||
echo " mdbook Generate mdbook documentation"
|
||||
echo " typst Compile typst document"
|
||||
echo " presentation Generate presentation"
|
||||
echo " quarto Render quarto report"
|
||||
echo " joplin Convert Joplin note"
|
||||
echo " bibliography Process bibliography"
|
||||
echo ""
|
||||
echo "Examples:"
|
||||
echo " $0 --all # Run all demonstrations"
|
||||
echo " $0 resume presentation # Run specific workflows"
|
||||
echo " $0 --clean mdbook # Clean and run mdbook demo"
|
||||
}
|
||||
|
||||
# Main execution
|
||||
main() {
|
||||
local run_all=true
|
||||
local clean_output=false
|
||||
local workflows=()
|
||||
|
||||
# Parse command line arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--help|-h)
|
||||
print_usage
|
||||
exit 0
|
||||
;;
|
||||
--all)
|
||||
run_all=true
|
||||
shift
|
||||
;;
|
||||
--clean)
|
||||
clean_output=true
|
||||
shift
|
||||
;;
|
||||
resume|project|mdbook|typst|presentation|quarto|joplin|bibliography)
|
||||
run_all=false
|
||||
workflows+=("$1")
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
print_error "Unknown option: $1"
|
||||
print_usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
print_status "🚀 Starting documentation workflow demonstrations..."
|
||||
|
||||
# Check prerequisites
|
||||
check_container
|
||||
|
||||
# Setup
|
||||
if [[ "$clean_output" == true ]]; then
|
||||
rm -rf "$OUTPUT_DIR"
|
||||
print_status "Cleaned output directory"
|
||||
fi
|
||||
setup_output
|
||||
|
||||
# Run workflows
|
||||
if [[ "$run_all" == true ]]; then
|
||||
demo_resume
|
||||
demo_project_docs
|
||||
demo_mdbook
|
||||
demo_typst
|
||||
demo_presentation
|
||||
demo_quarto
|
||||
demo_joplin
|
||||
demo_bibliography
|
||||
else
|
||||
for workflow in "${workflows[@]}"; do
|
||||
case $workflow in
|
||||
resume) demo_resume ;;
|
||||
project) demo_project_docs ;;
|
||||
mdbook) demo_mdbook ;;
|
||||
typst) demo_typst ;;
|
||||
presentation) demo_presentation ;;
|
||||
quarto) demo_quarto ;;
|
||||
joplin) demo_joplin ;;
|
||||
bibliography) demo_bibliography ;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
# Show results
|
||||
show_results
|
||||
|
||||
print_success "✅ All demonstrations completed successfully!"
|
||||
print_status "Check the '$OUTPUT_DIR' directory for generated files."
|
||||
}
|
||||
|
||||
# Run main function with all arguments
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user