Skip to content
Snippets Groups Projects
Commit c011e9a8 authored by Bernd Flemisch's avatar Bernd Flemisch
Browse files

[doc] add script for converting commented c++ files to markdown with code blocks

parent d9efb9d8
No related branches found
No related tags found
1 merge request!1683Automatically create READMEs for examples
#!/bin/sh
if [[ ${1: -3} == ".hh" ]]; then
sed '1,/define/d' $1 >tmpfile
else
sed '1,/\*\*\*\*\*/d' $1 >tmpfile
fi
insidecodeblock=false
while IFS= read -r line
do
strippedline=$(echo $line | sed "s/^[ \t]*//")
if [[ ${strippedline:0:2} == "//" ]]; then
if [[ $insidecodeblock == true ]]; then
echo "\`\`\`"
insidecodeblock=false
fi
echo "${strippedline:2}"
else
if [[ $insidecodeblock == false ]]; then
echo "\`\`\`cpp"
insidecodeblock=true
fi
echo "$line"
fi
done < tmpfile
if [[ $insidecodeblock == true ]]; then
echo "\`\`\`"
insidecodeblock=false
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment