Skip to content

Commit

Permalink
Bump version 0.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Revathyvenugopal162 committed Nov 14, 2022
1 parent f44b232 commit c5b8d97
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 15 deletions.
13 changes: 11 additions & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
ansys_logo_black,
ansys_logo_white,
ansys_logo_white_cropped,
generate_404,
latex,
page_404,
watermark,
)

Expand All @@ -33,6 +33,12 @@
"additional_breadcrumbs": [
("Ansys Internal Developer Portal", "https://dev.docs.ansys.com"),
],
"external_links": [
{
"url": "https://github.com/ansys/ansys-sphinx-theme/releases",
"name": "Changelog",
},
],
}

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

# Not found page
notfound_template = page_404
notfound_context = {
"body": generate_404(),
}
notfound_no_urls_prefix = True
1 change: 0 additions & 1 deletion doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ Ansys Sphinx Theme documentation |version|

getting_started/index.rst
user_guide/index.rst

23 changes: 12 additions & 11 deletions doc/source/user_guide/404_page.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion src/ansys_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
import os
from pathlib import Path

__version__ = "0.7.0"
from ansys_sphinx_theme.latex import generate_404 # noqa: F401

__version__ = "0.7.1"

# get location of this directory
_this_path = os.path.dirname(os.path.realpath(__file__))
Expand Down
5 changes: 5 additions & 0 deletions src/ansys_sphinx_theme/latex/404.html
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 %}
35 changes: 35 additions & 0 deletions src/ansys_sphinx_theme/latex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)

0 comments on commit c5b8d97

Please sign in to comment.