-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f44b232
commit c5b8d97
Showing
6 changed files
with
66 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,3 @@ Ansys Sphinx Theme documentation |version| | |
|
||
getting_started/index.rst | ||
user_guide/index.rst | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,28 +33,29 @@ your ``conf.py`` file: | |
"notfound.extension", | ||
] | ||
# Add a contact mail to the theme options | ||
html_theme_options = { | ||
..., | ||
"contact_mail": "[email protected]", | ||
} | ||
Configure your 404 page | ||
----------------------- | ||
You can use the default 404 page that the ``ansys-sphinx-theme`` package supplies | ||
or create and use a custom 404 page. | ||
or create and use a custom 404 page. | ||
|
||
Use the default 404 page | ||
~~~~~~~~~~~~~~~~~~~~~~~~ | ||
To use the default 404 page, add the following lines in the ``conf.py`` file: | ||
To use the default 404 page, you can use the ``generate_404`` function in the | ||
``ansys_sphinx_theme`` module to create and use a custom cover page: | ||
|
||
.. code-block:: | ||
.. code-block:: python | ||
from ansys_sphinx_theme import page_404 | ||
from ansys_sphinx_theme import generate_404 | ||
# Configure sphinx-notfound-page | ||
notfound_template = page_404 | ||
notfound_context = { | ||
'body': generate_404(<organisation_which_the_project_belongs_to>, | ||
<name_of_the_project>, | ||
<mail_id_for_the_project>, | ||
<name_of_team_managing_the_project> | ||
) | ||
} | ||
.. _sphinx-notfound-page: https://sphinx-notfound-page.readthedocs.io/en/latest/index.html | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% block content %}<h1>Page Not Found</h1> | ||
<p>Sorry, we couldn't find that page. Error code 404. </p> | ||
<p>You can try using the search box above or check our menu on the left hand side of this page.</p> | ||
<p>If neither of those options work, please create a Github issue ticket in <a href="{{issue_page}}">{{project_name}}.</a></p> | ||
<p>Or try sending a mail to <a href="mailto:{{mail_id}}">{{team_name}}</a></p>.{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
LATEX_SUBPKG = Path(os.path.dirname(os.path.realpath(__file__))) | ||
COVER_TEX = LATEX_SUBPKG / "cover.tex" | ||
PAGE_404 = LATEX_SUBPKG / "404.html" | ||
|
||
|
||
def generate_preamble(title, watermark="watermark", date=None): | ||
|
@@ -46,3 +47,37 @@ def generate_preamble(title, watermark="watermark", date=None): | |
) | ||
template = latex_jinja_env.get_template(".") | ||
return template.render(variables) | ||
|
||
|
||
def generate_404( | ||
owner="ansys", | ||
project_name="ansys-sphinx-theme", | ||
mail_id="[email protected]", | ||
team_name="PyAnsys", | ||
): | ||
"""Generate the html body for 404 page. | ||
Parameters | ||
---------- | ||
owner : str, default: "ansys" | ||
GitHub organisation in which the project belongs to. | ||
project_name : str, default: "ansys-sphinx-theme" | ||
Name of the project. | ||
mail_id : str, default: "[email protected]" | ||
E-mail address to contact. | ||
team_name : str, default: "PyAnsys" | ||
Name of the team. | ||
Returns | ||
------- | ||
str | ||
A string representing the html source code for the 404 page. | ||
""" | ||
issue_page = f"https://github.com/{owner}/{project_name}/issues/" | ||
variables = dict( | ||
issue_page=issue_page, project_name=project_name, mail_id=mail_id, team_name=team_name | ||
) | ||
html_env = jinja2.Environment(loader=jinja2.FileSystemLoader(PAGE_404)) | ||
template = html_env.get_template(".") | ||
return template.render(variables) |