Use the right operand when documenting type variable inference.

The meaning of format.typevar_operand changes recently to be relative to
value operands only instead of all operands. The Sphinx cton domain
wasn't updated.
This commit is contained in:
Jakob Stoklund Olesen
2017-04-03 09:56:47 -07:00
parent 2e45365ee1
commit ec29283abb

View File

@@ -304,16 +304,17 @@ class InstDocumenter(sphinx.ext.autodoc.Documenter):
def add_content(self, more_content, no_docstring=False): def add_content(self, more_content, no_docstring=False):
super(InstDocumenter, self).add_content(more_content, no_docstring) super(InstDocumenter, self).add_content(more_content, no_docstring)
sourcename = self.get_sourcename() sourcename = self.get_sourcename()
inst = self.object
# Add inputs and outputs. # Add inputs and outputs.
for op in self.object.ins: for op in inst.ins:
if op.is_value(): if op.is_value():
typ = op.typevar typ = op.typevar
else: else:
typ = op.kind typ = op.kind
self.add_line(u':in {} {}: {}'.format( self.add_line(u':in {} {}: {}'.format(
typ, op.name, op.get_doc()), sourcename) typ, op.name, op.get_doc()), sourcename)
for op in self.object.outs: for op in inst.outs:
if op.is_value(): if op.is_value():
typ = op.typevar typ = op.typevar
else: else:
@@ -322,22 +323,22 @@ class InstDocumenter(sphinx.ext.autodoc.Documenter):
typ, op.name, op.get_doc()), sourcename) typ, op.name, op.get_doc()), sourcename)
# Document type inference for polymorphic instructions. # Document type inference for polymorphic instructions.
if self.object.is_polymorphic: if inst.is_polymorphic:
if self.object.ctrl_typevar is not None: if inst.ctrl_typevar is not None:
if self.object.use_typevar_operand: if inst.use_typevar_operand:
tvopnum = inst.value_opnums[inst.format.typevar_operand]
self.add_line( self.add_line(
u':typevar {}: inferred from {}' u':typevar {}: inferred from {}'
.format( .format(
self.object.ctrl_typevar.name, inst.ctrl_typevar.name,
self.object.ins[ inst.ins[tvopnum]),
self.object.format.typevar_operand]),
sourcename) sourcename)
else: else:
self.add_line( self.add_line(
u':typevar {}: explicitly provided' u':typevar {}: explicitly provided'
.format(self.object.ctrl_typevar.name), .format(inst.ctrl_typevar.name),
sourcename) sourcename)
for tv in self.object.other_typevars: for tv in inst.other_typevars:
self.add_line( self.add_line(
u':typevar {}: from input operand'.format(tv.name), u':typevar {}: from input operand'.format(tv.name),
sourcename) sourcename)