Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #1565

Needly formatted list of functions

From Cecil Westerhof <Cecil@decebal.nl>
Newsgroups comp.lang.postscript
Subject Needly formatted list of functions
Organization Decebal Computing
Date 2013-08-02 17:21 +0200
Message-ID <87haf86ru8.fsf@Aspire.decebal.nl> (permalink)

Show all headers | View raw


When you are commenting your fumctions in the following way: 
     % input parameters 2 spaces function name 2 spaces output 
     parameters 
 
Then I have a nice function to display the list of functions in a 
nicely formatted way: 
    #!/usr/bin/env bash
    
    set -o errexit
    set -o nounset
    
    declare    INPUT_FILE
    declare -r SCRIPT_NAME=$(basename ${0})
    
    if [[ ${#} -ne 1 ]] ; then
        printf "ERROR: ${SCRIPT_NAME} postscriptFile\n"
        exit 1
    fi
    INPUT_FILE=${1}; shift
    readonly INPUT_FILE
    
    awk '
        BEGIN {
            count       = 0
            maxCmdLen   = 0
            maxInputLen = 0
        }
    
        END {
            format = sprintf("%%-%ds: %%-%ds ===> %%s\n", 
            maxCmdLen, maxInputLen)
            for (i = 1; i <= count; ++i) {
                printf(format, commandAr[i], inputAr[i], 
                outputAr[i])
            }
            print ""
            printf("Extracted %d commands\n", count)
        }
    
        /^% (.*)[^ ]  ([^ ]*)  [^ ](.*)$/ {
            if (match($0, "  (.*)  ")) {
                ++count
                cmdStart = RSTART + 2
                cmdLen   = RLENGTH - 4
                if (cmdLen > maxCmdLen) {
                    maxCmdLen = cmdLen
                }
                inputStart = 3
                inputLen   = RSTART - 3
                if (inputLen > maxInputLen) {
                    maxInputLen = inputLen
                }
                outputStart      = RSTART + RLENGTH
                command          = substr($0, cmdStart,   cmdLen)
                input            = substr($0, inputStart, 
                inputLen)
                output           = substr($0, outputStart)
                commandAr[count] = command
                inputAr[count]   = input
                outputAr[count]  = output
            }
        }
    ' <${INPUT_FILE}

This gives on a certain postscriptfile:
    arrow             : tailx taily tipx tipy thickness 
    headthickness headlength ===> -
    borderCircles     : left bottom right top scaleFactor 
    ===> -
    borderLines       : left bottom right top step endVal 
    ===> -
    borderRectangles  : left bottom right top scaleFactor 
    ===> -
    centerString      : msg [gray] x y 
    ===> -
    displayArray      : array nrOfLines x_mid x_max y lineHeight 
    ===> -
    doShow            : msg gray 
    ===> -
    drawLeftRightLines: startVal step endVal left right 
    ===> -
    drawUpDownLines   : startVal step endVal up down 
    ===> -
    drawUpDownTubes   : startVal step endVal up down width 
    ===> -
    endProgram        : shoul be empty 
    ===> -
    fatalError        : errorMessage [surpressStack] 
    ===> -
    fileToArray       : inputFile 
    ===> lineArray nrOfLines
    findhalfAngle     : string 
    ===> halfAngle
    fontToLatin       : fontname 
    ===> -
    getDictValues     : dictionary nameArray 
    ===> --
    getRescaleFont    : array lineLen 
    ===> scaleFactor
    gradient          : left bottom right top startColor endColor 
    ===> -
    grayBackground    : gray 
    ===> -
    insidecircletext  : string ptSize centerAngle radius 
    ===> -
    line              : left bottom right top 
    ===> -
    numToString       : number 
    ===> string
    logoCW            : hasBorder x y 
    ===> -
    logoDC            : hasBorder x y 
    ===> -
    logoMF            : hasBorder x y 
    ===> -
    logoPR            : hasBorder x y 
    ===> -
    outsidecircletext : string ptSize centerAngle radius 
    ===> -
    rectangle         : left bottom right top 
    ===> -
    rectangleWithText : grey text left bottom right top 
    ===> -
    rightString       : msg [gray] x y 
    ===> -
    setColourScheme   : colourScheme 
    ===> -
    showString        : string [gray] x y 
    ===> -
    stringAddNum      : string1 number 
    ===> string
    stringCat         : string1 string2 
    ===> string
    textheight        : - 
    ===> textHeight
    wedge             : msg isDownward 
    ===> -

    Extracted 36 commands

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Back to comp.lang.postscript | Previous | Next | Find similar | Unroll thread


Thread

Needly formatted list of functions Cecil Westerhof <Cecil@decebal.nl> - 2013-08-02 17:21 +0200

csiph-web