_docsweeper.result_handler#

Result handlers for docstring analysis results.

Provides result handlers that write the results of a token analysis into some output stream, like stdout.

class _docsweeper.result_handler.AbstractResultHandler#

Bases: ABC

Result handler that is agnostic as to how the handled entries are formatted.

Subclasses must implement _format_result() so that entries are formatted, or inherit from a class that already provides such a formatter.

Output streams can be added to the result handler by calling add_stream().

__init__()#

Instantiate the result handler.

Return type

None

abstract _format_result(file_name, token, history)#

Format the analysis data.

Parameters
Return type

str

add_stream(stream)#

Append stream to the streams that this result handler outputs to.

Parameters

stream (TextIO) – the stream

Return type

None

handle_result(file_name, token, history)#

Pass the result of the token analysis to the underlying output stream.

Performs the necessary formatting of input variables and writes the result entry to and output stream.

Parameters
Return type

None

class _docsweeper.result_handler.HumanReadableStringResultHandler#

Bases: AbstractResultHandler

Formats values in relatively verbose human-readable strings.

Suited for output in a console terminal.

class _docsweeper.result_handler.ClickResultHandler#

Bases: HumanReadableStringResultHandler

Handle results using click.echo().

add_stream(stream)#

Not implemented for this result handler.

Parameters

stream (TextIO) – the stream to be added

Raises

NotImplementedError – when called

Return type

None

handle_result(file_name, token, history)#

Write result to standard output using click.echo().

Parameters
Return type

None

class _docsweeper.result_handler.StdOutResultHandler#

Bases: HumanReadableStringResultHandler

A result handler that outputs to standard output.

__init__()#

Instantiate the result handler.

Adds the standard output stream to its output stream.

Return type

None