Skip to content

Commit

Permalink
Merge simple-doc-build-fail-6980-2: fail on sphinx
Browse files Browse the repository at this point in the history
Author: glyph

Reviewer: adiroiban

Fixes: twisted#6980

Sphinx warnings will now cause build-docs to fail, since we should not
have warnings in our docs.

This change also therefore fixes our few lingering sphinx warnings, so
the buildbot will not fail when it lands.

git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/trunk@46174 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
  • Loading branch information
glyph committed Nov 13, 2015
1 parent 217e47d commit 786fd49
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
11 changes: 7 additions & 4 deletions docs/core/howto/logger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
:LastChangedBy: $LastChangedBy$


.. _core-howto-logger-main:

Logging with twisted.logger
==================================
.. _core-howto-logger-main
===========================


The Basics
Expand Down Expand Up @@ -280,8 +281,10 @@ Emitting applications should be cautious about inserting objects into event whic
While observers are called synchronously, it is possible that an observer will do something like queue up the event for later serialization, in which case the serialized object may be different than intended.


.. _core-howto-logger-saving-events-for-later: Saving events for later
---------------------------------------------------------------------------
.. _core-howto-logger-saving-events-for-later:

Saving events for later
-----------------------

For compatibility reasons, ``twistd`` will log to a text-based format by default.
However, it's much better to use a structured log file format which preserves information about the events being logged.
Expand Down
15 changes: 11 additions & 4 deletions twisted/python/_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,10 @@ def main(self, args):
Additional arguments will be ignored for compatibility with legacy
build infrastructure.
"""
self.build(FilePath(args[0]).child("docs"))
output = self.build(FilePath(args[0]).child("docs"))
if output:
sys.stdout.write("Unclean build:\n{}\n".format(output))
raise sys.exit(1)


def build(self, docDir, buildDir=None, version=''):
Expand All @@ -968,15 +971,18 @@ def build(self, docDir, buildDir=None, version=''):
@param version: The version of Twisted to set in the docs.
@type version: C{str}
@return: the output produced by running the command
@rtype: L{str}
"""
if buildDir is None:
buildDir = docDir.parent().child('doc')

doctreeDir = buildDir.child('doctrees')

runCommand(['sphinx-build', '-b', 'html',
'-d', doctreeDir.path, docDir.path,
buildDir.path])
output = runCommand(['sphinx-build', '-q', '-b', 'html',
'-d', doctreeDir.path, docDir.path,
buildDir.path])

# Delete the doctrees, as we don't want them after the docs are built
doctreeDir.remove()
Expand All @@ -990,6 +996,7 @@ def build(self, docDir, buildDir=None, version=''):
if not dest.parent().isdir():
dest.parent().makedirs()
path.copyTo(dest)
return output



Expand Down
19 changes: 19 additions & 0 deletions twisted/python/test/test_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,25 @@ def test_main(self):
self.verifyBuilt()


def test_warningsAreErrors(self):
"""
Creates and builds a fake Sphinx project as if via the command line,
failing if there are any warnings.
"""
output = StringIO()
self.patch(sys, "stdout", output)
self.createFakeSphinxProject()
with self.sphinxDir.child("index.rst").open("a") as f:
f.write("\n.. _malformed-link-target\n")
exception = self.assertRaises(
SystemExit,
self.builder.main, [self.sphinxDir.parent().path]
)
self.assertEqual(exception.code, 1)
self.assertIn("malformed hyperlink target", output.getvalue())
self.verifyBuilt()


def verifyBuilt(self):
"""
Verify that a sphinx project has been built.
Expand Down
Empty file added twisted/topfiles/6980.misc
Empty file.

0 comments on commit 786fd49

Please sign in to comment.