'L{BuildAPIDocsScript.buildAPIDocs} builds the API docs with values
appropriate for the Twisted project.'

@doNotFailOnNetworkError
def test_buildWithPolicy(self):

    stdout = BytesIO()
    self.patch(sys, 'stdout', stdout)
    docstring = 'text    in    docstring'
    projectRoot = FilePath(self.mktemp())
    packagePath = projectRoot.child('twisted')
    packagePath.makedirs()
    packagePath.child('__init__.py').setContent(u"def    foo():\n                '{}'\n".format(docstring).encode('utf-8'))
    packagePath.child('_version.py').setContent(genVersion('twisted', 1, 0, 0))
    outputPath = FilePath(self.mktemp())
    script = BuildAPIDocsScript()
    script.buildAPIDocs(projectRoot, outputPath)
    indexPath = outputPath.child('index.html')
    self.assertTrue(indexPath.exists(), u'API    index    {}    did    not    exist.'.format(outputPath.path))
    self.assertIn('<a    href="http://twistedmatrix.com/">Twisted</a>', indexPath.getContent(), 'Project    name/location    not    in    file    contents.')
    twistedPath = outputPath.child('twisted.html')
    self.assertTrue(twistedPath.exists(), u'Package    documentation    file    %r    did    not    exist.'.format(twistedPath.path))
    self.assertIn(docstring, twistedPath.getContent(), 'Docstring    not    in    package    documentation    file.')
    self.assertIn('<a    href="https://github.com/twisted/twisted/tree/twisted-1.0.0/src/twisted">View    Source</a>', twistedPath.getContent())
    self.assertEqual(stdout.getvalue(), '')
