GovReady / hyperGRC

hyperGRC is a lightweight, in-browser tool for managing compliance-as-code repositories in OpenControl format.
GNU General Public License v3.0
22 stars 9 forks source link

Generate markdown docs of controls by family in one click #5

Open gregelin opened 5 years ago

gregelin commented 5 years ago

Request from @openprivacy to generate markdown docs of controls in a family.

openprivacy commented 5 years ago

Currently using this script:

#!/usr/bin/env bash

# Generate separate files for each family of controls and a table of contents.
# Requires: https://github.com/ekalinin/github-markdown-toc v0.5+
#      and: https://github.com/GovReady/hyperGRC

# This is dependant on location of hypergrc
export PYTHONPATH=../../govready/hypergrc/

TMP=$(mktemp)

# Add '-d' option for full RMF description.
python3 -m hypergrc.ssp . > $TMP
FAMILIES=$(egrep '^## ' $TMP | cut -d' ' -f2 | cut -d: -f1)

mkdir -p docs/controls

for FAM in $FAMILIES; do
  python3 -m hypergrc.ssp -d --family $FAM . > docs/controls/${FAM}.md
done

cd docs

DATE=`date "+%Y.%m.%d at %H%M"`

echo "# LINCS Controls (compiled: ${DATE})" > controls.md

gh-md-toc controls/* | sed '/^           /d' | sed '/^   \*/d' | sed 's/^      //' | \
  sed 's/^\(Created by \[gh-md-toc\].*$\)/<!-- \1 -->/' >> controls.md