"""
List all argkeys for human inspection. The purpose is to check every argkey
and manually link proper documentations to them.

"""
import csv
from itertools import imap

from codemend.docstring_parse.elemdoc import ElemDoc
from codemend import relative_path

with open(relative_path(
      'docstring_parse/doc_polished/elem_docs.csv'
      # this file is generated by docstring_parse/polish.py
      ), 'rb') as csvfile:
  reader = csv.reader(csvfile)

  columns = tuple(next(reader))
  assert ElemDoc._fields == columns

  outset = set()
  for elem in imap(ElemDoc._make, reader):
    elem_id = elem.elem_id

    if elem.type == 'argkey':

      fields = elem_id.split('@')
      key = '@'.join(fields[:2])
      outset.add(key)

  for x in sorted(outset):
    print x
  print len(outset)
