3.5 (documenta utils)

This module defines helper procedures that didn’t quite fit anywhere else.

This module provides the following interface.

3.5.1 Procedures

Procedure: min-indent string

Return the shorter number of spaces used for indentation in the given string.

This procedure assumes indentation is space-based, not tab-based.

string (string): The text to inspect.

Return value (integer): The number of spaces representing the shorter indentation.

Procedure: tabs->spaces string OPT: tabsize

Convert tabs to spaces in the given string.

string (string): The original text.

tabsize (integer): Optional. The number of spaces that will replace a single tab. If not provided, DEFAULT_SPACE_INDENT_SIZE is used.

Return value (string): A new string where all tabs are replaced by spaces.

Procedure: trim string spaces

Trim off the given number of spaces at the beginning of the string.

string (string): The original text.

spaces (integer): The number of spaces to trim off.

Return value (string): A new string with the exact number of spaces removed, if they exist. Otherwise, the original string is returned.

Procedure: unindent docstring

Remove unwanted indentation from the given documentation string.

’Unwanted’ indentation is what results, for example, from aligning documentation lines to the first line of the documentation string so that they look aesthetic in the source code.

docstring (string): A string that documents a procedure or any other object.

Return value (string): A new string with the undesired indentation removed.

3.5.2 Variables

Variable: DEFAULT_SPACE_INDENT_SIZE
2