From 27b4e2d891a198fcb179d6d649d938d2f613cf84 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Fri, 16 Nov 2018 09:57:05 +0000 Subject: [PATCH] [Docs] Fix formatting of exported docstrings --- deluge/core/core.py | 1 - deluge/core/rpcserver.py | 17 +++++++++++++---- deluge/ui/console/modes/basemode.py | 2 +- docs/source/conf.py | 3 +++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/deluge/core/core.py b/deluge/core/core.py index 47717f5c6..91f9b8a38 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -472,7 +472,6 @@ class Core(component.Component): Returns: str: The torrent_id or None. - """ try: filedump = b64decode(filedump) diff --git a/deluge/core/rpcserver.py b/deluge/core/rpcserver.py index 07e6f1531..adb521901 100644 --- a/deluge/core/rpcserver.py +++ b/deluge/core/rpcserver.py @@ -62,10 +62,19 @@ def export(auth_level=AUTH_LEVEL_DEFAULT): def wrap(func, *args, **kwargs): func._rpcserver_export = True func._rpcserver_auth_level = auth_level - doc = func.__doc__ - func.__doc__ = '**RPC Exported Function** (*Auth Level: %s*)\n\n' % auth_level - if doc: - func.__doc__ += doc + + rpc_text = '**RPC exported method** (*Auth level: %s*)' % auth_level + + # Append the RPC text while ensuring correct docstring formatting. + if func.__doc__: + if func.__doc__.endswith(' '): + indent = func.__doc__.split('\n')[-1] + func.__doc__ += '\n{}'.format(indent) + else: + func.__doc__ += '\n\n' + func.__doc__ += rpc_text + else: + func.__doc__ = rpc_text return func diff --git a/deluge/ui/console/modes/basemode.py b/deluge/ui/console/modes/basemode.py index 6d9d847d4..dd3681f5b 100644 --- a/deluge/ui/console/modes/basemode.py +++ b/deluge/ui/console/modes/basemode.py @@ -109,7 +109,7 @@ class BaseMode(CursesStdIO, component.Component): do_read(self) - Handle user input refresh(self) - draw the mode to the screen add_string(self, row, string) - add a string of text to be displayed. - see method for detailed info + see method for detailed info The init method of a subclass *must* call BaseMode.__init__ diff --git a/docs/source/conf.py b/docs/source/conf.py index e7c28cc7b..78377f5c0 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -125,6 +125,9 @@ extensions = [ 'sphinx.ext.coverage', ] +napoleon_include_init_with_doc = True +napoleon_use_rtype = False + # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates']