From 5a91386fce9fabab1d195d7943e6ee197a11ff9c Mon Sep 17 00:00:00 2001 From: Kazuya Takei Date: Sun, 24 Mar 2024 04:02:37 +0900 Subject: [PATCH] fix: Support path-type outdir - This is for Sphinx>=7.2 --- src/atsphinx/mini18n/__init__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/atsphinx/mini18n/__init__.py b/src/atsphinx/mini18n/__init__.py index d5bd354..965c237 100644 --- a/src/atsphinx/mini18n/__init__.py +++ b/src/atsphinx/mini18n/__init__.py @@ -41,14 +41,23 @@ def build_heading_content(self): ctx = { "config": self.app.config, } - out_index = self.app.outdir + "/index.html" out_template = Path(__file__).parent / "templates" / "mini18n" / "index.html" template = Template(out_template.read_text()) + out_index = ( + Path("/".join([self.app.outdir, "index.html"])) + if isinstance(self.app.outdir, str) + else self.app.outdir / "index.html" + ) Path(out_index).write_text(template.render(ctx)) def build_i18_contents(args: BuildArgs): """Run build for coufigured language.""" + lang_out_dir = ( + "/".join([args.app.outdir, args.lang]) + if isinstance(args.app.outdir, str) + else args.app.outdir / args.lang + ) cmd = [ "sphinx-build", "-b", @@ -56,7 +65,7 @@ def build_i18_contents(args: BuildArgs): "-d", args.app.doctreedir, args.app.srcdir, - "/".join([args.app.outdir, args.lang]), + lang_out_dir, "-D", f"language={args.lang}", ]