#NEWLINE# def public_factory( target , location ) : #NEWLINE# #INDENT# 'Produce a wrapping function for the given cls or classmethod.\n\n    Rationale here is so that the __init__ method of the\n    class can serve as documentation for the function.\n\n    ' #NEWLINE# if isinstance ( target , type ) : #NEWLINE# #INDENT# fn = target . __init__ #NEWLINE# callable_ = target #NEWLINE# doc = ( 'Construct a new :class:`.%s` object. \n\nThis constructor is mirrored as a public API function; see :func:`~%s` for a full usage and argument description.' % ( target . __name__ , code ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# fn = callable_ = target #NEWLINE# doc = ( 'This function is mirrored; see :func:`~%s` for a description of arguments.' % location ) #NEWLINE# #UNINDENT# location_name = location . split ( '.' ) [ ( - 1 ) ] #NEWLINE# spec = compat . inspect_getfullargspec ( fn ) #NEWLINE# del spec [ 0 ] [ 0 ] #NEWLINE# metadata = format_argspec_plus ( spec , grouped = False ) #NEWLINE# metadata [ 'name' ] = location_name #NEWLINE# code = ( 'def %(name)s(%(args)s):\n    return cls(%(apply_kw)s)\n' % metadata ) #NEWLINE# env = { #NEWLINE# #INDENT# 'cls' : callable_ , #NEWLINE# 'symbol' : symbol , #NEWLINE# #UNINDENT# } #NEWLINE# exec ( code , env ) #NEWLINE# decorated = env [ location_name ] #NEWLINE# decorated . __doc__ = fn . __doc__ #NEWLINE# if ( compat . py2k or hasattr ( fn , '__func__' ) ) : #NEWLINE# #INDENT# fn . __func__ . __doc__ = doc #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# fn . __doc__ = doc #NEWLINE# #UNINDENT# return decorated