def process_nodes(app, doctree, fromdocname):
    """Replaces all djangomodellist nodes with a list of the collected models.
    """

    env = app.builder.env
    content = []

    # generate representation
    if app.config.djmex_include_djangomodellists:

        for info in env.djmex_all_djangomodels:

            # title in the form
            # Table table_name (model_name)
            block = docutils.nodes.line_block()
            block.append(docutils.nodes.Text('Table '))
            block.append(docutils.nodes.strong(
                text=info['target']._meta.db_table))
            block.append(docutils.nodes.emphasis(
                text=' ({0})'.format(info['name'])))
            content.append(block)

            # add existing doc lines
            block = docutils.nodes.line_block()
            for l in info['lines']:
                para = docutils.nodes.paragraph()
                para.append(docutils.nodes.Text(l))
                block.append(para)
            content.append(block)

            # field list is represented as a single field containing a list
            field_list = docutils.nodes.field_list()
            field = docutils.nodes.field()
            field.append(docutils.nodes.field_name(text=_('Columns')))
            body = docutils.nodes.field_body()
            blist = docutils.nodes.bullet_list()
            body.append(blist)
            field.append(body)
            field_list.append(field)

            fields = info['target']._meta._fields()
            for field in fields:
                # adds field description in the form:
                # db_field_name (db_field_type[, django_field_type]) details
                # where details are: PK, Index, field.help_text
                db_column = field.db_column or field.name
                help_text = field.help_text or field.verbose_name
                help_text = ' ' + strip_tags(force_unicode(help_text))
                try:
                    db_type = field.db_type(connection)
                except:
                    db_type = 'Unknown'

                if app.config.djmex_show_django_field:
                    ftype = ', '.join([db_type, field.get_internal_type()])
                else:
                    ftype = db_type

                db_index = ' Index' if field.db_index else ''
                is_pk = ' PK' if field.primary_key else ''

                para = docutils.nodes.paragraph()
                para += docutils.nodes.strong(text=db_column)
                para += docutils.nodes.emphasis(text=' ({0}) '.format(ftype))

                details = [help_text, is_pk, db_index]
                for i, d in enumerate(details):
                    if d not in ["", None]:
                        if i > 0:
                            para += docutils.nodes.Text(', ', ', ')
                        para += docutils.nodes.Text(d, d)

                #name = docutils.nodes.field_name(text=db_column)
                li = docutils.nodes.list_item()
                li.append(para)
                blist.append(li)

            content.append(field_list)

    for node in doctree.traverse(djangomodellist):
        node.replace_self(content)
dataset/ETHPy150Open ipeirotis/Mturk-Tracker/doc/source/extensions/djmex.py/process_nodes/original