Skip to content

Commit

Permalink
use pathlib path in sitemap plugin for sphinx compatibility (#4215)
Browse files Browse the repository at this point in the history
* use pathlib paths for sphinx compatibility

* conditionally use pathlib if sphinx >=7

(cherry picked from commit 3ec513d)
  • Loading branch information
ottojo authored and mergify[bot] committed Mar 13, 2024
1 parent d60d236 commit 9f85fed
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion plugins/sphinx_sitemap_ros.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
from multiprocessing import Manager
from typing import Any, Dict, List, Optional
from xml.etree import ElementTree
from pathlib import Path

import sphinx
from sphinx.application import Sphinx
from sphinx.util.logging import getLogger

Expand Down Expand Up @@ -225,7 +227,11 @@ def create_sitemap(app: Sphinx, exception):
href=site_url + scheme.format(lang=lang, version=version, link=link),
)

filename = app.outdir + "/" + app.config.sitemap_filename
if sphinx.version_info[0] >= 7:
filename = Path.joinpath(app.outdir, app.config.sitemap_filename)
else:
filename = app.outdir + "/" + app.config.sitemap_filename

ElementTree.ElementTree(root).write(
filename, xml_declaration=True, encoding="utf-8", method="xml"
)
Expand Down

0 comments on commit 9f85fed

Please sign in to comment.