Use pathlib in examples

This commit is contained in:
Adam Turner committed 2024-11-03 17:26:39 +00:00
1 parent 1094556afb
commit a6559d496b
2 files changed
+5 -5

No files matched your search

+2 -2
View File
@@ -203,10 +203,10 @@ using the :meth:`~sphinx.application.Sphinx.add_html_theme` API:
.. code-block:: python
# your_theme_package.py
from os import path
from pathlib import Path
def setup(app):
app.add_html_theme('name_of_theme', path.abspath(path.dirname(__file__)))
app.add_html_theme('name_of_theme', Path(__file__).resolve().parent)
If your theme package contains two or more themes, please call
``add_html_theme()`` twice or more.
+3 -3
View File
@@ -184,7 +184,7 @@ def get_translation(catalog: str, namespace: str = 'general') -> Callable[[str],
The extension can use this API to translate the messages on the
extension::
import os
from pathlib import Path
from sphinx.locale import get_translation
MESSAGE_CATALOG_NAME = 'myextension' # name of *.pot, *.po and *.mo files
@@ -193,8 +193,8 @@ def get_translation(catalog: str, namespace: str = 'general') -> Callable[[str],
def setup(app):
package_dir = os.path.abspath(os.path.dirname(__file__))
locale_dir = os.path.join(package_dir, 'locales')
package_dir = Path(__file__).resolve().parent
locale_dir = package_dir / 'locales'
app.add_message_catalog(MESSAGE_CATALOG_NAME, locale_dir)
With this code, sphinx searches a message catalog from