Closed sachahu1 closed 1 week ago
This behaviour seems correct to me. If you don't want to have to change the path depending on the nesting, then you can prepend the path with a /
to use a path relative to the documentation source directory (the one with the conf.py).
.. image:: /_static/img/an_image.png
:scale: 50 %
See https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#images
@AWhetter You're absolutely right, my mistake!
I believe the
html_static_path
variable isn't working as expected on sphinx-autoapi. Sphinx copies the_static
folders correctly into the build but the RST structure generated by autoapi is nested and paths aren't automatically adjusted to match that. This results in the_static
paths needing to be modified for any file to be imported correctly.For instance, the following example doesn't import the image correctly withou manual modifications:
doc_package.cli
It generates the following RST:
autoapi/doc_package/cli/index.rst
Given that
_static
is several directories higher, for the image to import properly, it would need to be../../../_static/img/an_image.png
.