Skip to content

Instantly share code, notes, and snippets.

@wernsey
Created July 2, 2022 16:17
Show Gist options
  • Save wernsey/de253d42a8df6f3b21358e4b5422b955 to your computer and use it in GitHub Desktop.
Save wernsey/de253d42a8df6f3b21358e4b5422b955 to your computer and use it in GitHub Desktop.
Awk script to generate Markdeep documentation from source code
#! /usr/bin/awk -f
BEGIN { print "<meta charset=\"utf-8\">" }
/\/\*\*/ {
sub(/^.*\/\*/,"");
incomment=1;
}
incomment && /\*\// {
incomment=0;
sub(/[[:space:]]*\*\/.*/,"");
sub(/^[[:space:]]*\*[[:space:]]?/,"");
print
}
incomment && /^[[:space:]]*\*/ {
sub(/^[[:space:]]*\*[[:space:]]?/,"");
print
}
!incomment && /\/\/\// {
sub(/.*\/\/\/[[:space:]]?/,"");
print
}
END {
print "<!-- Markdeep: -->";
print "<style class=\"fallback\">body{visibility:hidden;white-space:pre;font-family:monospace}</style>";
print "<script>markdeepOptions={tocStyle:\"auto\"};</script>";
print "<script src=\"https://morgan3d.github.io/markdeep/latest/markdeep.min.js\" charset=\"utf-8\"></script>";
print "<script>window.alreadyProcessedMarkdeep||(document.body.style.visibility=\"visible\")</script>"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment