Examples

Live demos

Class with members (regions + fold)

class api_demo_layout.LayoutDemo
class api_demo_layout.LayoutDemo

Bases: object

A class demonstrating all layout regions.

The class docstring forms the narrative region. The parameter field list below forms the fields region (folded if large enough). Nested methods form the members region.

Parameters (13)
Parameters:
  • host (str) – Server hostname.

  • port (int) – Server port number.

  • username (str) – Authentication username.

  • password (str) – Authentication password.

  • database (str) – Database name.

  • timeout (float) – Connection timeout in seconds.

  • retries (int) – Number of connection retries.

  • ssl (bool) – Enable SSL/TLS.

  • pool_size (int) – Connection pool size.

  • pool_timeout (float) – Pool checkout timeout.

  • echo (bool) – Log all SQL statements.

  • encoding (str) – Character encoding.

  • isolation_level (str) – Transaction isolation level.

The class above renders with:

  • narrative region (class docstring)

  • fields region with fold (13 parameters > threshold of 10)

  • members region (connect, execute, close methods)

Small function (no fold)

api_demo_layout.compact_function(name, value=0)
function[source]
function[source]
api_demo_layout.compact_function(name, value=0)

Format a name-value pair.

This should render without any fold – just a narrative region followed by a fields region.

Parameters:
  • name (str) – The item name.

  • value (int) – The item value.

Returns:

Formatted result.

Return type:

str