Skip to content

Commit

Permalink
chore: Clean up the tools parse.sh script (#361)
Browse files Browse the repository at this point in the history
Generates the same documentation, less code.

Signed-off-by: Terry Howe <[email protected]>
  • Loading branch information
Terry Howe authored Jul 9, 2024
1 parent 1fcaf86 commit c15bdfe
Showing 1 changed file with 3 additions and 24 deletions.
27 changes: 3 additions & 24 deletions tools/parse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ ${ORAS} help ${COMMAND} >${TEMPFILE}

IFS=''
STATE=Introduction
EXAMPLES=""
PREFIX="Example - "
>${EXAMPLES_FILE}
cat ${TEMPFILE} | while read -r LINE
do
Expand All @@ -43,25 +41,22 @@ do
fi
STATE=Examples
echo >>${EXAMPLES_FILE}
echo "${LINE#"$PREFIX"}" >>${EXAMPLES_FILE}
echo "${LINE}" | sed -e 's/Example - //' >>${EXAMPLES_FILE}
echo >>${EXAMPLES_FILE}
echo '```bash' >>${EXAMPLES_FILE}
continue
fi
if [[ "${LINE}" == Usage* ]]
then
if [ "${STATE}" == "Examples" ]
then
echo '```' >>${EXAMPLES_FILE}
echo >>${EXAMPLES_FILE}
fi
STATE=Usage
continue
fi
if [[ "${LINE}" == Flags* ]]
then
if [ -s $EXAMPLES_FILE ]
then
echo '```' >>${EXAMPLES_FILE}
echo >>${EXAMPLES_FILE}
echo '## Examples'
cat $EXAMPLES_FILE
>$EXAMPLES_FILE
Expand All @@ -74,25 +69,9 @@ do
fi
case "${STATE}" in
Introduction)
if [[ "${LINE}" == Flags* ]]
then
echo '## Options'
echo
echo '```'
STATE=Flags
continue
fi
echo "${LINE}"
;;
Alias)
if [[ "${LINE}" == Flags* ]]
then
echo '## Options'
echo
echo '```'
STATE=Flags
continue
fi
;;
Examples)
echo "${LINE}" | sed -e 's/^[[:space:]]*//' >>${EXAMPLES_FILE}
Expand Down

0 comments on commit c15bdfe

Please sign in to comment.