Skip to content

Commit

Permalink
Merge pull request #2071 from sopel-irc/clean-in-trim_docstring
Browse files Browse the repository at this point in the history
loader: use `inspect` to make callable docs consistent
  • Loading branch information
dgw authored May 26, 2021
2 parents 88c16f7 + a70b1e6 commit b6fb3b3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions sopel/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
"""
from __future__ import absolute_import, division, print_function, unicode_literals

import inspect
import logging
import re
import sys

from sopel.config.core_section import COMMAND_DEFAULT_HELP_PREFIX
from sopel.tools import itervalues
from sopel.tools import deprecated, itervalues


if sys.version_info.major >= 3:
Expand All @@ -27,6 +28,11 @@
LOGGER = logging.getLogger(__name__)


@deprecated(
reason="Replaced by simple logic using inspect.getdoc()",
version='7.1',
removed_in='8.0',
)
def trim_docstring(doc):
"""Get the docstring as a series of lines that can be sent.
Expand Down Expand Up @@ -71,9 +77,13 @@ def clean_callable(func, config):
nick = config.core.nick
help_prefix = config.core.help_prefix
func._docs = {}
doc = trim_docstring(func.__doc__)
doc = []
examples = []

docstring = inspect.getdoc(func)
if docstring:
doc = docstring.splitlines()

func.thread = getattr(func, 'thread', True)

if is_limitable(func):
Expand Down

0 comments on commit b6fb3b3

Please sign in to comment.