mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Added DocumentNotFoundError
This commit is contained in:
parent
f014641405
commit
846ab3a743
@ -22,6 +22,7 @@ from sphinx.application import Sphinx
|
|||||||
from sphinx.util.osutil import ensuredir
|
from sphinx.util.osutil import ensuredir
|
||||||
from sphinx.websupport.search import BaseSearch, search_adapters
|
from sphinx.websupport.search import BaseSearch, search_adapters
|
||||||
from sphinx.websupport.comments import StorageBackend
|
from sphinx.websupport.comments import StorageBackend
|
||||||
|
from sphinx.websupport.errors import DocumentNotFoundError
|
||||||
|
|
||||||
class WebSupportApp(Sphinx):
|
class WebSupportApp(Sphinx):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@ -126,7 +127,13 @@ class WebSupport(object):
|
|||||||
:param docname: the name of the document to load.
|
:param docname: the name of the document to load.
|
||||||
"""
|
"""
|
||||||
infilename = path.join(self.outdir, docname + '.fpickle')
|
infilename = path.join(self.outdir, docname + '.fpickle')
|
||||||
f = open(infilename, 'rb')
|
|
||||||
|
try:
|
||||||
|
f = open(infilename, 'rb')
|
||||||
|
except IOError:
|
||||||
|
raise DocumentNotFoundError(
|
||||||
|
'The document "%s" could not be found' % docname)
|
||||||
|
|
||||||
document = pickle.load(f)
|
document = pickle.load(f)
|
||||||
return document
|
return document
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import os
|
|||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
|
|
||||||
from sphinx.websupport import WebSupport
|
from sphinx.websupport import WebSupport
|
||||||
|
from sphinx.websupport.errors import DocumentNotFoundError
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
@ -44,4 +45,5 @@ def with_support(*args, **kwargs):
|
|||||||
@with_support()
|
@with_support()
|
||||||
def test_build(support):
|
def test_build(support):
|
||||||
support.build()
|
support.build()
|
||||||
|
raises(DocumentNotFoundError, support.get_document, 'nonexisting')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user