'Add a title node to the document (just copy the first section title),
and store that title in the environment.'

def process_doc(self, app, doctree):

    titlenode = nodes.title()
    longtitlenode = titlenode
    if ('title' in doctree):
        longtitlenode = nodes.title()
        longtitlenode += nodes.Text(doctree['title'])
    for node in doctree.traverse(nodes.section):
        visitor = SphinxContentsFilter(doctree)
        node[0].walkabout(visitor)
        titlenode += visitor.get_entry_text()
        break
    else:
        titlenode += nodes.Text('<no    title>')
    app.env.titles[app.env.docname] = titlenode
    app.env.longtitles[app.env.docname] = longtitlenode
