From c011e9a870fbc4b6a1aefa015b767dbaea5bd08a Mon Sep 17 00:00:00 2001
From: Bernd Flemisch <bernd@iws.uni-stuttgart.de>
Date: Wed, 31 Jul 2019 15:41:38 +0200
Subject: [PATCH] [doc] add script for converting commented c++ files to
 markdown with code blocks

---
 bin/doc/cpp_to_md.sh | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 bin/doc/cpp_to_md.sh

diff --git a/bin/doc/cpp_to_md.sh b/bin/doc/cpp_to_md.sh
new file mode 100644
index 0000000000..c9f6dc98f6
--- /dev/null
+++ b/bin/doc/cpp_to_md.sh
@@ -0,0 +1,32 @@
+#!/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
-- 
GitLab