from textwrap import dedent


def map_strings_to_line_numbers(module):
    """
    Walk ``module.ast``, looking at all string literals.  Return a map from
    string literals to line numbers (1-index).

    :rtype:
      ``dict`` from ``str`` to (``int``, ``str``)
    """
    d = {}
    for field in module.block.string_literals():
        # Dedent because epydoc dedents strings and we need to look up by
        # those.  But keep track of original version because we need to count
        # exact line numbers.
        s = dedent(field.s).strip()
        start_lineno = field.startpos.lineno
        d[s] = (start_lineno, field.s)
    return d