Skip to content

Commit 952b23b

Browse files
committed
Move logic to Operation.generate_sphinx()
1 parent 7c68e6a commit 952b23b

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

pyvips/voperation.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ def add_construct(self, pspec, argument_class,
9191
self.required_output = []
9292
self.optional_output = []
9393

94-
# same, but with deprecated and redundant args filtered out ... this is
95-
# the set we show in documentation
94+
# same, but with deprecated args filtered out ... this is the set we
95+
# show in documentation
9696
self.doc_optional_input = []
9797
self.doc_optional_output = []
9898

@@ -117,12 +117,7 @@ def add_construct(self, pspec, argument_class,
117117
(flags & _REQUIRED) == 0):
118118
self.optional_input.append(name)
119119

120-
# drop "revalidate" flag from buffer loaders and operations
121-
# marked "nocache" as they are already uncached
122-
if ((flags & _DEPRECATED) == 0 and
123-
(name != 'revalidate' or
124-
('_buffer' not in operation_name and
125-
(self.flags & _OPERATION_NOCACHE) == 0))):
120+
if (flags & _DEPRECATED) == 0:
126121
self.doc_optional_input.append(name)
127122

128123
if ((flags & _OUTPUT) != 0 and
@@ -423,14 +418,21 @@ def generate_sphinx(operation_name):
423418
raise Error('No such operator.',
424419
f'operator "{operation_name}" is deprecated')
425420

421+
# drop "revalidate" flag from buffer loaders and operations marked
422+
# "nocache" as they are already uncached
423+
doc_optional_input = [name for name in intro.doc_optional_input if
424+
name != 'revalidate' or
425+
('_buffer' not in operation_name and
426+
(intro.flags & _OPERATION_NOCACHE) == 0)]
427+
426428
if intro.member_x is not None:
427429
result = '.. method:: '
428430
else:
429431
result = '.. staticmethod:: '
430432
args = []
431433
args += intro.method_args
432434
args += [x + '=' + GValue.gtype_to_python(intro.details[x]['type'])
433-
for x in intro.doc_optional_input]
435+
for x in doc_optional_input]
434436
args += [x + '=bool'
435437
for x in intro.doc_optional_output]
436438
result += operation_name + '(' + ", ".join(args) + ')\n\n'
@@ -449,11 +451,11 @@ def generate_sphinx(operation_name):
449451
args = []
450452
args += intro.method_args
451453
args += [x + '=' + GValue.gtype_to_python(intro.details[x]['type'])
452-
for x in intro.doc_optional_input]
454+
for x in doc_optional_input]
453455
result += ', '.join(args)
454456
result += ')\n\n'
455457

456-
for name in intro.method_args + intro.doc_optional_input:
458+
for name in intro.method_args + doc_optional_input:
457459
details = intro.details[name]
458460
result += f':param {name}: {details["blurb"]}\n'
459461
result += (f':type {name}: '

0 commit comments

Comments
 (0)