'Transform a single field list *node*.'

def transform(self, node):

    typemap = self.typemap
    entries = []
    groupindices = {}
    types = {}
    for field in node:
        (fieldname, fieldbody) = field
        try:
            (fieldtype, fieldarg) = fieldname.astext().split(None, 1)
        except ValueError:
            (fieldtype, fieldarg) = (fieldname.astext(), '')
        (typedesc, is_typefield) = typemap.get(fieldtype, (None, None))
        if ((typedesc is None) or (typedesc.has_arg != bool(fieldarg))):
            new_fieldname = (fieldtype[0:1].upper() + fieldtype[1:])
            if fieldarg:
                new_fieldname += ('    ' + fieldarg)
            fieldname[0] = nodes.Text(new_fieldname)
            entries.append(field)
            continue
        typename = typedesc.name
        if _is_single_paragraph(fieldbody):
            content = fieldbody.children[0].children
        else:
            content = fieldbody.children
        if is_typefield:
            content = [n for n in content if (isinstance(n, nodes.Inline) or isinstance(n, nodes.Text))]
            if content:
                types.setdefault(typename, {})[fieldarg] = content
            continue
        if typedesc.is_typed:
            try:
                (argtype, argname) = fieldarg.split(None, 1)
            except ValueError:
                pass
            else:
                types.setdefault(typename, {})[argname] = [nodes.Text(argtype)]
                fieldarg = argname
        translatable_content = nodes.inline(fieldbody.rawsource, translatable=True)
        translatable_content.document = fieldbody.parent.document
        translatable_content.source = fieldbody.parent.source
        translatable_content.line = fieldbody.parent.line
        translatable_content += content
        if typedesc.is_grouped:
            if (typename in groupindices):
                group = entries[groupindices[typename]]
            else:
                groupindices[typename] = len(entries)
                group = [typedesc, []]
                entries.append(group)
            entry = typedesc.make_entry(fieldarg, [translatable_content])
            group[1].append(entry)
        else:
            entry = typedesc.make_entry(fieldarg, [translatable_content])
            entries.append([typedesc, entry])
    new_list = nodes.field_list()
    for entry in entries:
        if isinstance(entry, nodes.field):
            new_list += entry
        else:
            (fieldtype, content) = entry
            fieldtypes = types.get(fieldtype.name, {})
            env = self.directive.state.document.settings.env
            new_list += fieldtype.make_field(fieldtypes, self.directive.domain, content, env=env)
    node.replace_self(new_list)
