Skip to content

Commit 48a1f55

Browse files
committed
Use sphinx-notfound-page by default to create a generic 404 page
We use the sphinx-notfound-page extension to create a generic page for each project. By default we use the same Maze Found ASCII art, but the user can customize it by defining specific configs from the sphinx-notfound-page.
1 parent d2214bd commit 48a1f55

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

readthedocs/doc_builder/python_environments.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ def install_core_requirements(self):
278278
),
279279
'sphinx-rtd-theme<0.5',
280280
'readthedocs-sphinx-ext<0.6'
281+
'sphinx-notfound-page',
281282
])
282283

283284
cmd = copy.copy(pip_install_cmd)
@@ -383,7 +384,10 @@ def install_core_requirements(self):
383384
if self.config.doctype == 'mkdocs':
384385
pip_requirements.append('mkdocs')
385386
else:
386-
pip_requirements.append('readthedocs-sphinx-ext')
387+
pip_requirements.extend([
388+
'readthedocs-sphinx-ext',
389+
'sphinx-notfound-page',
390+
])
387391
requirements.extend(['sphinx', 'sphinx_rtd_theme'])
388392

389393
cmd = [
@@ -397,7 +401,7 @@ def install_core_requirements(self):
397401
cmd.extend(requirements)
398402
self.build_env.run(
399403
*cmd,
400-
cwd=self.checkout_path # noqa - no comma here in py27 :/
404+
cwd=self.checkout_path,
401405
)
402406

403407
pip_cmd = [

readthedocs/doc_builder/templates/doc_builder/conf.py.tmpl

+32
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,35 @@ if 'extensions' in globals():
133133
extensions.insert(0, "readthedocs_ext.readthedocs")
134134
else:
135135
extensions = ["readthedocs_ext.readthedocs"]
136+
137+
138+
# Define default 404 page body
139+
if 'notfound_context' not in globals():
140+
notfound_context = {
141+
'body': '''
142+
<pre style="line-height: 1.25; white-space: pre;">
143+
\ SORRY /
144+
\ /
145+
\ This page does /
146+
] not exist yet. [ ,'|
147+
] [ / |
148+
]___ ___[ ,' |
149+
] ]\ /[ [ |: |
150+
] ] \ / [ [ |: |
151+
] ] ] [ [ [ |: |
152+
] ] ]__ __[ [ [ |: |
153+
] ] ] ]\ _ /[ [ [ [ |: |
154+
] ] ] ] (#) [ [ [ [ :===='
155+
] ] ]_].nHn.[_[ [ [
156+
] ] ] HHHHH. [ [ [
157+
] ] / `HH("N \ [ [
158+
]__]/ HHH " \[__[
159+
] NNN [
160+
] N/" [
161+
] N H [
162+
/ N \
163+
/ q, \
164+
/ \
165+
</pre>
166+
'''
167+
}

0 commit comments

Comments
 (0)