From 95b4c58ecdd53035cb50020742ebe8252e7efaa2 Mon Sep 17 00:00:00 2001 From: Griatch Date: Fri, 28 Feb 2020 23:41:57 +0100 Subject: [PATCH] Make child command class correctly pick up parent docstring if it's missing --- evennia/commands/command.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/evennia/commands/command.py b/evennia/commands/command.py index 8110a9ecb3..dba035b481 100644 --- a/evennia/commands/command.py +++ b/evennia/commands/command.py @@ -6,6 +6,7 @@ All commands in Evennia inherit from the 'Command' class in this module. """ import re import math +import inspect from django.conf import settings @@ -74,6 +75,13 @@ def _init_command(cls, **kwargs): cls.is_exit = False if not hasattr(cls, "help_category"): cls.help_category = "general" + # make sure to pick up the parent's docstring if the child class is + # missing one (important for auto-help) + if cls.__doc__ is None: + for parent_class in inspect.getmro(cls): + if parent_class.__doc__ is not None: + cls.__doc__ = parent_class.__doc__ + break cls.help_category = cls.help_category.lower()