Open ckrauterlovescoffee opened 5 months ago
Here is what I've settled on for now,
# What I run
tsuml2 --outFile ./docs/uml.svg --outMermaidDsl ./docs/mermaid.dsl --glob './src/**/*.ts' --glob './examples/**/*.ts' --memberAssociations && ./scripts/add_mermaid_to_readme.sh
#!/bin/bash
# This script injects the content of 'mermaid.dsl' into the README.md under the 'Diagram' section.
MERMAID_FILE="./docs/mermaid.dsl"
README_FILE="./README.md"
TEMP_FILE="./docs/temp_readme.md"
GREEN="\033[1;32m"
RESET="\033[0m"
cp $README_FILE $TEMP_FILE
if ! grep -q '## Architecture' $TEMP_FILE; then
echo "\n\n## Architecture" >> $TEMP_FILE
fi
sed -i '' '/## Architecture/,$d' $TEMP_FILE
echo -e '\n\n## Architecture' >> $TEMP_FILE
echo -e '\n\nThis is an auto-generated diagram per the [add_mermaid_to_readme.sh](./scripts/add_mermaid_to_readme.sh) script. The section must be the last section in this file. Any subsequent sections will be destroyed!' >> $TEMP_FILE
echo -e '\n\n```mermaid' >> $TEMP_FILE
cat $MERMAID_FILE >> $TEMP_FILE
echo -e '\n```\n' >> $TEMP_FILE
cp $TEMP_FILE $README_FILE
echo -e "${GREEN}Update complete: README.md has been updated with the contents of $MERMAID_FILE.${RESET}"
rm $TEMP_FILE
rm $MERMAID_FILE
@ckrauterlovescoffee I think it would be easier with the public parseProject
getMermaidDSL
functions
You can read the markdown file and replace a specified placeholder with the generated mermaid dsl
It would be neat to be able to specify an output for a markdown file that gets filled with the mermaid diagram.