From 5c3487dc8adef05ed842bcc752baf5eb62cd4005 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 30 Dec 2017 19:25:17 +0100 Subject: [PATCH] Move error messages into docstrings --- compiler/error/compiler.py | 4 ++-- compiler/error/template/class.txt | 4 +++- compiler/error/template/sub_class.txt | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/compiler/error/compiler.py b/compiler/error/compiler.py index 49f3359b..ac475da9 100644 --- a/compiler/error/compiler.py +++ b/compiler/error/compiler.py @@ -108,12 +108,12 @@ def start(): notice=notice, super_class=super_class, code=code, - name="\"{}\"".format(name), + docstring='"""{}"""'.format(name), sub_classes="".join([sub_class_template.format( sub_class=k[0], super_class=super_class, id="\"{}\"".format(k[1]), - message="\"{}\"".format(k[2]) + docstring='"""{}"""'.format(k[2]) ) for k in sub_classes]) ) diff --git a/compiler/error/template/class.txt b/compiler/error/template/class.txt index 0c729eb7..fd240f4b 100644 --- a/compiler/error/template/class.txt +++ b/compiler/error/template/class.txt @@ -4,8 +4,10 @@ from ..error import Error class {super_class}(Error): + {docstring} CODE = {code} - NAME = {name} + """:obj:`int`: Error Code""" + NAME = __doc__ {sub_classes} \ No newline at end of file diff --git a/compiler/error/template/sub_class.txt b/compiler/error/template/sub_class.txt index bc163407..a33503ec 100644 --- a/compiler/error/template/sub_class.txt +++ b/compiler/error/template/sub_class.txt @@ -1,5 +1,7 @@ class {sub_class}({super_class}): + {docstring} ID = {id} - MESSAGE = {message} + """:obj:`str`: Error ID""" + MESSAGE = __doc__