Skip to content

Commit 520d460

Browse files
committed
fix(docs[aafig]): use builder target URI for image paths (dirhtml compat)
why: The aafig extension computed image paths using the raw docname instead of the builder's target URI. With dirhtml, this produces ../_images/ instead of ../../_images/ because dirhtml outputs files one directory deeper (page/index.html vs page.html). what: - Change relative_uri(docname, "_images") to relative_uri(get_target_uri(docname), "_images") - Matches how Sphinx itself computes image paths (sphinx/builders/html/__init__.py:655)
1 parent 6dd0024 commit 520d460

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

docs/_ext/aafig.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ def render_aafigure(
176176
fname = "{}.{}".format(get_basename(text, options), options["format"])
177177
if app.builder.format == "html":
178178
# HTML
179-
imgpath = relative_uri(app.builder.env.docname, "_images")
179+
target_uri = app.builder.get_target_uri(app.builder.env.docname)
180+
imgpath = relative_uri(target_uri, "_images")
180181
relfn = posixpath.join(imgpath, fname)
181182
outfn = path.join(app.builder.outdir, "_images", fname)
182183
else:

0 commit comments

Comments
 (0)