Created
April 4, 2018 22:34
-
-
Save rcurtin/c1cb5ef47abed9e9a8a21f5d9701eb0f to your computer and use it in GitHub Desktop.
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
diff --git a/CMake/exec2man.sh b/CMake/exec2man.sh | |
index b0807fc61..debff99c6 100755 | |
--- a/CMake/exec2man.sh | |
+++ b/CMake/exec2man.sh | |
@@ -1,5 +1,5 @@ | |
#!/bin/bash | |
-# Convert the output of an MLPACK executable into a man page. This assumes that | |
+# Convert the output of an mlpack executable into a man page. This assumes that | |
# the CLI subsystem is used to output help, that the executable is properly | |
# documented, and that the program is run in the directory that the executable | |
# is in. Usually, this is used by CMake on Linux/UNIX systems to generate the | |
@@ -17,7 +17,7 @@ output="$2" | |
# Generate the synopsis. | |
# First, required options. | |
reqoptions=`./"$name" -h | \ | |
- awk '/Required options:/,/Options:/' | \ | |
+ awk '/Required input options:/,/Optional input options:/' | \ | |
grep '^ --' | \ | |
sed 's/^ --/--/' | \ | |
sed 's/^--[A-Za-z0-9_-]* (\(-[A-Za-z0-9]\))/\1/' | \ | |
@@ -31,7 +31,7 @@ reqoptions=`./"$name" -h | \ | |
# Then, regular options. | |
options=`./"$name" -h | \ | |
- awk '/Options:/,/For further information,/' | \ | |
+ awk '/Optional input options:/,/For further information,/' | \ | |
grep '^ --' | \ | |
sed 's/^ --/--/' | \ | |
grep -v -- '--help' | \ | |
@@ -50,7 +50,7 @@ options=`./"$name" -h | \ | |
sed 's/\(-[A-Za-z0-9] [a-z]*\) /\[\1\] /g' | \ | |
sed 's/\(--[A-Za-z0-9_-]* [a-z]*\) /\[\1\] /g'` | |
-synopsis="$name [-h] [-v] $reqoptions $options"; | |
+synopsis="$name $reqoptions $options [-h -v]"; | |
# Preview the whole thing first. | |
#./$name -h | \ | |
@@ -68,13 +68,12 @@ synopsis="$name [-h] [-v] $reqoptions $options"; | |
./"$name" -h | \ | |
sed 's/^For further information/Additional Information\n\n For further information/' | \ | |
sed 's/^consult the documentation/ consult the documentation/' | \ | |
- sed 's/^distribution of MLPACK./ distribution of MLPACK./' | \ | |
+ sed 's/^distribution of mlpack./ distribution of mlpack./' | \ | |
awk -v syn="$synopsis" \ | |
'{ if (NR == 1) print "NAME\n '"$name"' - "tolower($0)"\nSYNOPSIS\n "syn" \nDESCRIPTION\n" ; else print } ' | \ | |
sed '/^[^ ]/ y/qwertyuiopasdfghjklzxcvbnm:/QWERTYUIOPASDFGHJKLZXCVBNM /' | \ | |
sed 's/ / /g' | \ | |
- awk '/NAME/,/REQUIRED OPTIONS/ { print; } /ADDITIONAL INFORMATION/,0 { print; } /REQUIRED OPTIONS/,/ADDITIONAL INFORMATION/ { if (!/REQUIRED_OPTIONS/ && !/OPTIONS/ && !/ADDITIONAL INFORMATION/) { if (/ --/) { printf "\n" } sub(/^[ | |
]*/, ""); sub(/ [ ]*/, " "); printf "%s ", $0; } else { if (!/REQUIRED OPTIONS/ && !/ADDITIONAL INFORMATION/) { print "\n"$0; } } }' | \ | |
+ awk '/NAME/,/.*OPTIONS/ { if (!/.*OPTIONS/) { print; } } /ADDITIONAL INFORMATION/,0 { print; } /.*OPTIONS/,/ADDITIONAL INFORMATION/ { if (!/REQUIRED INPUT OPTIONS/ && !/OPTIONAL INPUT OPTIONS/ && !/OPTIONAL OUTPUT OPTIONS/ && !/AD | |
DITIONAL INFORMATION/) { if (/ --/) { printf "\n" } sub(/^[ ]*/, ""); sub(/ [ ]*/, " "); printf "%s ", $0; } else { if (!/ADDITIONAL INFORMATION/) { print "\n"$0; } } }' | \ | |
sed 's/ ADDITIONAL INFORMATION/\n\nADDITIONAL INFORMATION/' | \ | |
txt2man -P mlpack -t "$name" -d 1 | \ | |
sed "s/^'/\\\\(aq/" > "$output" | |
- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment