summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-11-07 13:38:38 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2020-11-07 13:41:41 -0500
commit8e486fa565bb91e3a21176bb029253e5f5544da4 (patch)
tree3e4870a59a205df030b30a9ce2259a8ee6dc6b26 /lib/sqlalchemy
parentf5ed0f5d6e0526a4ee2f9f164b7da79de11a481e (diff)
downloadsqlalchemy-8e486fa565bb91e3a21176bb029253e5f5544da4.tar.gz
improve verbiage a bit for the public_factory
Change-Id: I52fb88f6d08333063e749857eb7d8edcebabd738
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/util/langhelpers.py35
1 files changed, 24 insertions, 11 deletions
diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py
index ce3a28499..bd10a33a6 100644
--- a/lib/sqlalchemy/util/langhelpers.py
+++ b/lib/sqlalchemy/util/langhelpers.py
@@ -221,22 +221,31 @@ def public_factory(target, location, class_location=None):
class can serve as documentation for the function.
"""
+
if isinstance(target, type):
fn = target.__init__
callable_ = target
doc = (
- "Construct a new :class:`.%s` object. \n\n"
+ "Construct a new :class:`%s` object. \n\n"
"This constructor is mirrored as a public API function; "
"see :func:`sqlalchemy%s` "
"for a full usage and argument description."
- % (target.__name__, location)
+ % (
+ class_location if class_location else ".%s" % target.__name__,
+ location,
+ )
)
+ linked_to_target = target
else:
fn = callable_ = target
doc = (
"This function is mirrored; see :func:`sqlalchemy%s` "
"for a description of arguments." % location
)
+ if compat.py2k or hasattr(fn, "__func__"):
+ linked_to_target = fn.__func__
+ else:
+ linked_to_target = fn
location_name = location.split(".")[-1]
spec = compat.inspect_getfullargspec(fn)
@@ -253,8 +262,9 @@ def %(name)s(%(args)s):
env = {"cls": callable_, "symbol": symbol}
exec(code, env)
decorated = env[location_name]
- if hasattr(fn, "_linked_to"):
- linked_to, linked_to_location = fn._linked_to
+
+ if hasattr(linked_to_target, "_linked_to"):
+ linked_to, linked_to_location = linked_to_target._linked_to
linked_to_doc = linked_to.__doc__
if class_location is None:
class_location = "%s.%s" % (target.__module__, target.__name__)
@@ -262,9 +272,11 @@ def %(name)s(%(args)s):
linked_to_doc = inject_docstring_text(
linked_to_doc,
".. container:: inherited_member\n\n "
- "Inherited from :func:`sqlalchemy%s`; this constructor "
- "creates a :class:`%s` object"
- % (linked_to_location, class_location),
+ "This documentation is inherited from :func:`sqlalchemy%s`; "
+ "this constructor, :func:`sqlalchemy%s`, "
+ "creates a :class:`sqlalchemy%s` object. See that class for "
+ "additional details describing this subclass."
+ % (linked_to_location, location, class_location),
1,
)
decorated.__doc__ = linked_to_doc
@@ -277,14 +289,15 @@ def %(name)s(%(args)s):
"public_factory location %s is not in sys.modules"
% (decorated.__module__,)
)
+
+ if not hasattr(linked_to_target, "_linked_to"):
+ linked_to_target._linked_to = (decorated, location)
+
if compat.py2k or hasattr(fn, "__func__"):
fn.__func__.__doc__ = doc
- if not hasattr(fn.__func__, "_linked_to"):
- fn.__func__._linked_to = (decorated, location)
else:
fn.__doc__ = doc
- if not hasattr(fn, "_linked_to"):
- fn._linked_to = (decorated, location)
+
return decorated