Skip to content

Commit c5b8d97

Browse files
Bump version 0.7.1
1 parent f44b232 commit c5b8d97

File tree

6 files changed

+66
-15
lines changed

6 files changed

+66
-15
lines changed

doc/source/conf.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
ansys_logo_black,
1212
ansys_logo_white,
1313
ansys_logo_white_cropped,
14+
generate_404,
1415
latex,
15-
page_404,
1616
watermark,
1717
)
1818

@@ -33,6 +33,12 @@
3333
"additional_breadcrumbs": [
3434
("Ansys Internal Developer Portal", "https://dev.docs.ansys.com"),
3535
],
36+
"external_links": [
37+
{
38+
"url": "https://github.com/ansys/ansys-sphinx-theme/releases",
39+
"name": "Changelog",
40+
},
41+
],
3642
}
3743

3844
html_short_title = html_title = "Ansys Sphinx Theme"
@@ -104,4 +110,7 @@
104110
latex_elements = {"preamble": latex.generate_preamble(html_title)}
105111

106112
# Not found page
107-
notfound_template = page_404
113+
notfound_context = {
114+
"body": generate_404(),
115+
}
116+
notfound_no_urls_prefix = True

doc/source/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ Ansys Sphinx Theme documentation |version|
1111

1212
getting_started/index.rst
1313
user_guide/index.rst
14-

doc/source/user_guide/404_page.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,28 +33,29 @@ your ``conf.py`` file:
3333
"notfound.extension",
3434
]
3535
36-
# Add a contact mail to the theme options
37-
html_theme_options = {
38-
...,
39-
"contact_mail": "[email protected]",
40-
}
41-
4236
Configure your 404 page
4337
-----------------------
4438
You can use the default 404 page that the ``ansys-sphinx-theme`` package supplies
45-
or create and use a custom 404 page.
39+
or create and use a custom 404 page.
4640

4741
Use the default 404 page
4842
~~~~~~~~~~~~~~~~~~~~~~~~
49-
To use the default 404 page, add the following lines in the ``conf.py`` file:
43+
To use the default 404 page, you can use the ``generate_404`` function in the
44+
``ansys_sphinx_theme`` module to create and use a custom cover page:
5045

51-
.. code-block::
46+
.. code-block:: python
5247
53-
from ansys_sphinx_theme import page_404
48+
from ansys_sphinx_theme import generate_404
5449
5550
5651
# Configure sphinx-notfound-page
57-
notfound_template = page_404
52+
notfound_context = {
53+
'body': generate_404(<organisation_which_the_project_belongs_to>,
54+
<name_of_the_project>,
55+
<mail_id_for_the_project>,
56+
<name_of_team_managing_the_project>
57+
)
58+
}
5859
5960
.. _sphinx-notfound-page: https://sphinx-notfound-page.readthedocs.io/en/latest/index.html
6061

src/ansys_sphinx_theme/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
import os
33
from pathlib import Path
44

5-
__version__ = "0.7.0"
5+
from ansys_sphinx_theme.latex import generate_404 # noqa: F401
6+
7+
__version__ = "0.7.1"
68

79
# get location of this directory
810
_this_path = os.path.dirname(os.path.realpath(__file__))

src/ansys_sphinx_theme/latex/404.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% block content %}<h1>Page Not Found</h1>
2+
<p>Sorry, we couldn't find that page. Error code 404. </p>
3+
<p>You can try using the search box above or check our menu on the left hand side of this page.</p>
4+
<p>If neither of those options work, please create a Github issue ticket in <a href="{{issue_page}}">{{project_name}}.</a></p>
5+
<p>Or try sending a mail to <a href="mailto:{{mail_id}}">{{team_name}}</a></p>.{% endblock %}

src/ansys_sphinx_theme/latex/__init__.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
LATEX_SUBPKG = Path(os.path.dirname(os.path.realpath(__file__)))
99
COVER_TEX = LATEX_SUBPKG / "cover.tex"
10+
PAGE_404 = LATEX_SUBPKG / "404.html"
1011

1112

1213
def generate_preamble(title, watermark="watermark", date=None):
@@ -46,3 +47,37 @@ def generate_preamble(title, watermark="watermark", date=None):
4647
)
4748
template = latex_jinja_env.get_template(".")
4849
return template.render(variables)
50+
51+
52+
def generate_404(
53+
owner="ansys",
54+
project_name="ansys-sphinx-theme",
55+
mail_id="[email protected]",
56+
team_name="PyAnsys",
57+
):
58+
"""Generate the html body for 404 page.
59+
60+
Parameters
61+
----------
62+
owner : str, default: "ansys"
63+
GitHub organisation in which the project belongs to.
64+
project_name : str, default: "ansys-sphinx-theme"
65+
Name of the project.
66+
mail_id : str, default: "[email protected]"
67+
E-mail address to contact.
68+
team_name : str, default: "PyAnsys"
69+
Name of the team.
70+
71+
Returns
72+
-------
73+
str
74+
A string representing the html source code for the 404 page.
75+
76+
"""
77+
issue_page = f"https://github.com/{owner}/{project_name}/issues/"
78+
variables = dict(
79+
issue_page=issue_page, project_name=project_name, mail_id=mail_id, team_name=team_name
80+
)
81+
html_env = jinja2.Environment(loader=jinja2.FileSystemLoader(PAGE_404))
82+
template = html_env.get_template(".")
83+
return template.render(variables)

0 commit comments

Comments
 (0)