+doc fails fast when includecode has no content

This commit is contained in:
Konrad Malawski 2015-10-08 11:00:01 +02:00
parent 0756a2ff68
commit 608ca9d67e
4 changed files with 8 additions and 3 deletions

View file

@ -109,6 +109,12 @@ class IncludeCode(Directive):
return count
nonempty = filter(lambda l: l.strip(), lines)
if not nonempty:
return [document.reporter.error(
"Snippet ({}#{}) not found!".format(filename, section),
line=self.lineno
)]
tabcounts = map(lambda l: countwhile(lambda c: c == ' ', l), nonempty)
tabshift = min(tabcounts) if tabcounts else 0

View file

@ -98,6 +98,7 @@ class IncludeCode2(Directive):
text = ''.join(res)
if text == "":
# in includecode2 it indeed is a warning, an empty code block will be inserted
return [document.reporter.warning('Snippet "' + snippet + '" not found!', line=self.lineno)]
retnode = nodes.literal_block(text, text, source=fn)

View file

@ -8,8 +8,6 @@ Applies the given authorization check to the request.
Signature
---------
.. includecode:: /../../akka-http/src/main/scala/akka/http/scaladsl/server/directives/SecurityDirectives.scala#authorize
.. includecode2:: /../../akka-http/src/main/scala/akka/http/scaladsl/server/directives/SecurityDirectives.scala
:snippet: authorize

View file

@ -91,7 +91,7 @@ with HTTP response parts or rejections. Sometimes, however, you will want to ver
:ref:`Rejections` to HTTP responses in the way you expect.
You do this by wrapping your route with the ``akka.http.scaladsl.server.Route.seal``.
The ``seal`` wrapper applies the logic of the in-scope :ref:`ExceptionHandler <Exception Handling>` and
The ``seal`` wrapper applies the logic of the in-scope :ref:`ExceptionHandler <exception-handling-scala>` and
:ref:`RejectionHandler <The RejectionHandler>` to all exceptions and rejections coming back from the route,
and translates them to the respective ``HttpResponse``.