Improve removing arguments from documentation

Examples of issues where user used arguments which should not be present in 
documentation, but actually were present: #1699 (cpu_load_percent: 
shutdown_event), #1700 (weather: key, after_update, shutdown_event).
This commit is contained in:
Foo 2017-01-06 21:23:42 +03:00
parent b7d030a72a
commit 12bd79729e
4 changed files with 18 additions and 11 deletions

View File

@ -158,17 +158,16 @@ class ThreadedSegment(Segment, MultiRunnedThread):
def additional_args(self):
return (('interval', self.interval),)
_omitted_args = {
'render': (0,),
'set_state': ('shutdown_event',),
}
def omitted_args(self, name, method):
ret = self._omitted_args.get(name, ())
if isinstance(getattr(self, name, None), MethodType):
omitted_indexes = (0,)
else:
omitted_indexes = ()
if name.startswith('render'):
if omitted_indexes:
omitted_indexes += (1,)
else:
omitted_indexes = (0,)
return omitted_indexes
ret = tuple((i + 1 if isinstance(i, int) else i for i in ret))
return ret
class KwThreadedSegment(ThreadedSegment):
@ -255,3 +254,9 @@ class KwThreadedSegment(ThreadedSegment):
@staticmethod
def render_one(update_state, **kwargs):
return update_state
_omitted_args = {
'render': ('update_value', 'key', 'after_update'),
'set_state': ('shutdown_event',),
'render_one': (0,),
}

View File

@ -39,7 +39,9 @@ def getconfigargspec(obj):
for i, arg in enumerate(reversed(argspec.args)):
if (
largs - (i + 1) in omitted_args
or arg in omitted_args
or arg == 'pl'
or arg == 'self'
or (arg == 'create_watcher' and requires_filesystem_watcher)
or (arg == 'segment_info' and requires_segment_info)
):

View File

@ -44,7 +44,7 @@ class CwdSegment(Segment):
def omitted_args(self, name, method):
if method is self.get_shortened_path:
return (0, 1, 2)
return ()
else:
return super(CwdSegment, self).omitted_args(name, method)

View File

@ -62,7 +62,7 @@ class PlayerSegment(Segment):
yield 'get_player_status', self.get_player_status
def omitted_args(self, name, method):
return (0,)
return ()
_common_args = '''