def small_doc(obj, indent="", max_width=80):
  """
  Finds a useful small doc representation of an object.

  Parameters
  ----------
  obj :
    Any object, which the documentation representation should be taken from.
  indent :
    Result indentation string to be insert in front of all lines.
  max_width :
    Each line of the result may have at most this length.

  Returns
  -------
  For classes, modules, functions, methods, properties and StrategyDict
  instances, returns the first paragraph in the doctring of the given object,
  as a list of strings, stripped at right and with indent at left.
  For other inputs, it will use themselves cast to string as their docstring.

  """
  if not getattr(obj, "__doc__", False):
    data = [el.strip() for el in str(obj).splitlines()]
    if len(data) == 1:
      if data[0].startswith("<audiolazy.lazy_"): # Instance
        data = data[0].split("0x", -1)[0] + "0x...>" # Hide its address
      else:
        data = "".join(["``", data[0], "``"])
    else:
      data = " ".join(data)

  # No docstring
  elif (not obj.__doc__) or (obj.__doc__.strip() == ""):
    data = "\ * * * * ...no docstring... * * * * \ "

  # Docstring
  else:
    data = (el.strip() for el in obj.__doc__.strip().splitlines())
    data = " ".join(it.takewhile(lambda el: el != "", data))

  # Ensure max_width (word wrap)
  max_width -= len(indent)
  result = []
  for word in data.split():
    if len(word) <= max_width:
      if result:
        if len(result[-1]) + len(word) + 1 <= max_width:
          word = " ".join([result.pop(), word])
        result.append(word)
      else:
        result = [word]
    else: # Splits big words
      result.extend("".join(w) for w in blocks(word, max_width, padval=""))

  # Apply indentation and finishes
  return [indent + el for el in result]
def small_doc ( obj , indent = "" , max_width = 80 ) : if not getattr ( obj , "__doc__" , False ) : data = [ el . strip ( ) for el in str ( obj ) . splitlines ( ) ] if len ( data ) == 1 : if data [ 0 ] . startswith ( "<audiolazy.lazy_" ) : data = data [ 0 ] . split ( "0x" , - 1 ) [ 0 ] + "0x...>" else : data = "" . join ( [ "``" , data [ 0 ] , "``" ] ) else : data = " " . join ( data ) elif ( not obj . __doc__ ) or ( obj . __doc__ . strip ( ) == "" ) : data = "\ * * * * ...no docstring... * * * * \ " else : data = ( el . strip ( ) for el in obj . __doc__ . strip ( ) . splitlines ( ) ) data = " " . join ( it . takewhile ( lambda el : el != "" , data ) ) max_width -= len ( indent ) result = [ ] for word in data . split ( ) : if len ( word ) <= max_width : if result : if len ( result [ - 1 ] ) + len ( word ) + 1 <= max_width : word = " " . join ( [ result . pop ( ) , word ] ) result . append ( word ) else : result = [ word ] else : result . extend ( "" . join ( w ) for w in blocks ( word , max_width , padval = "" ) ) return [ indent + el for el in result ]
Finds a useful small doc representation of an object.

  Parameters
  ----------
  obj :
    Any object, which the documentation representation should be taken from.
  indent :
    Result indentation string to be insert in front of all lines.
  max_width :
    Each line of the result may have at most this length.

  Returns
  -------
  For classes, modules, functions, methods, properties and StrategyDict
  instances, returns the first paragraph in the doctring of the given object,
  as a list of strings, stripped at right and with indent at left.
  For other inputs, it will use themselves cast to string as their docstring.