Created
March 1, 2019 18:09
-
-
Save brandones/da0c8a81555b9873f1b275136a851401 to your computer and use it in GitHub Desktop.
Appends Roxygen @Package docstring to README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Extracts the Roxygen package documentation from each script file in the | |
# package root directory and appends it to README.md | |
# | |
# Documentation that you want included should start on the second line of the script | |
OUTFILE="README.md" | |
r_files=( *.R ) | |
echo >>${OUTFILE} | |
echo '## Script Documentation' >>${OUTFILE} | |
echo >>${OUTFILE} | |
for file in "${r_files[@]}" | |
do | |
echo '### '${file} >>${OUTFILE} | |
cat ${file} | \ | |
grep "@docType package" -B100 | \ | |
grep -v "@docType package" | \ | |
sed "s/^.\{0,3\}//" | \ | |
tail -n +2 \ | |
>> ${OUTFILE} | |
echo >>${OUTFILE} | |
cat ${file} | \ | |
grep "OUTPUT_PATH = " | \ | |
sed "s/.*/- \`&\`/" \ | |
>> ${OUTFILE} | |
echo >>${OUTFILE} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment