'Prepare the text of the html file
This only works on machines that have the html files for the projects
checked out.'

def prepare_text(self, obj):

    from pyquery import PyQuery
    full_path = obj.project.rtd_build_path()
    file_path = os.path.join(full_path, obj.path.lstrip('/'))
    try:
        with codecs.open(file_path, encoding='utf-8', mode='r') as f:
            content = f.read()
    except IOError as e:
        log.info('(Search    Index)    Unable    to    index    file:    %s,    error    :%s', file_path, e)
        return
    log.debug('(Search    Index)    Indexing    %s:%s', obj.project, obj.path)
    document_pyquery_path = getattr(settings, 'DOCUMENT_PYQUERY_PATH', 'div.document')
    try:
        to_index = strip_tags(PyQuery(content)(document_pyquery_path).html()).replace(u'\xb6', '')
    except ValueError:
        return
    if (not to_index):
        log.info('(Search    Index)    Unable    to    index    file:    %s:%s,    empty    file', obj.project, file_path)
    else:
        log.debug('(Search    Index)    %s:%s    length:    %s', obj.project, file_path, len(to_index))
    return to_index
