Home - nsrosenqvist/shocker GitHub Wiki

Shocker

take_if_higher()

take_if_higher() 

Used to find out the longest table cell

To get properly formatted tables, where all the cells are aligned, we have to find out what the maximum length is. We do that by passing both the old and new value to compare with and sets provided variable by using eval. That way we can loop easily and find it quickly.

Parameter Explanation
$1 (int) The currently highest value
$2 (int) The new value to compare with
$3 (string) The name of the variable to set, we use the variable name of the one we provide for $1.

author: Niklas Rosenqvist


pad_string()

pad_string() 

Pads string so that tables are properly formatted


repeat_character()

repeat_character() 

Repeat a character multiple a user set of times


trim_whitespace()

trim_whitespace() 

Simple sed command to remove trailing and leading whitespace


strip_multi_slash()

strip_multi_slash() 

Removes multiple slashes, used only to get proper paths for the table of contents


write()

write() 

A shorthand for writing to file

It uses the global variable OUTPUT to determine where stdout should be directed

Parameter Explanation
$1 (string) The line that should be written

author: Niklas Rosenqvist


write_block()

write_block() 

Write's a DocBlock to the output file

In addition to the parameters given, it also uses the global variables PARAMS and PROPERTIES, from which the data is extracted from.

Parameter Explanation
$1 (string) The function name
$2 (string) The summary describing the function
$3 (string) The longer explanation giving more information about the function's usage

return (int) - It only returns 0 if no errors hindered the execution

author: Niklas Rosenqvist


parse_file()

parse_file() 

Parses the file's comments to markdown

The function writes the content to OUTPUT which can be set by the -o flag. It can parse both single and multiline comments. A DocBlock comment is started and ended with the "#/" character combination

Parameter Explanation
$1 (string) The file that will be processed
$2 (string) An optional file heading. If not set then it will be extracted from the file name

return (int) - It only returns 0 if no errors hindered the execution

author: Niklas Rosenqvist