Needextract does not work with images
See original GitHub issueDescribe the bug
We want to add images to the content of need
s and reference these need
s with needextract
. Unfortunately, the images are not correctly parsed when extracting the need.
I assume it is related to https://github.com/useblocks/sphinx-needs/pull/794. However, the PR only solves the problem if images are located in source/_images
. Where the images will also be located in build
.
To Reproduce Steps to reproduce the behavior:
- Create
projectA
:
I choose to separate source and build folder during the build, i.e.,mkdir projectA cd projectA sphinx-quickstart
Separate source and build directories (y/n) [n]: y
- Configure
projectA
by adding the following lines toprojectA/source/conf.py
:extensions = ["sphinx_needs"]
- Add an image to the source folder, i.e…
projectA/source/image.png
. - Create a requirement by adding the following lines in
projectA/source/index.rst
:.. need:: NeedA :id: NEEDA
- Link the image with
needextract
:.. needextract:: NEEDA
Expected behavior
The requirement NEEDA
appears twice and contains the used image twice.
Actual behaviour
For the first need
, displays the image, the second need
displays the path in source/index.rst
Before using the most recent sphinx-needs
release, the path was _images/image.png
, i.e., the image copy in build
. This broken as soon as the rst file was not on the source
level but in a subfolder.
Setup
We are using python Python 3.8.13
. And the following version of sphinx/sphinx-needs:
sphinx-needs 1.1.0
Sphinx 5.3.0
I hope the description helps to reproduce the issue 😃
The issue template was copied from labs-zola.
Issue Analytics
- State:
- Created 10 months ago
- Comments:11 (5 by maintainers)
Top GitHub Comments
@iSOLveIT okay, maybe I broke down the example to far and it works now… I was quite sure it did not work on my end. But you are right. That was my fault.
Let me give it another try, this time defining and linking the need in different files, as I actually want to use it and there it breaks on my end:
To Reproduce Steps to reproduce the behavior:
projectA
: I choose to separate source and build folder during the build, i.e.,Separate source and build directories (y/n) [n]: y
projectA
by adding the following lines toprojectA/source/conf.py
:projectA/source
.image.png
.source
contain a file for the need definitionsubfolder/image_need.rst
and add the following content :needextract
in `index.rst:Expected behavior The requirement
NEEDA
appears in both files and each contains the used image.Actual behaviour For the first
need
, displays the image, the secondneed
displays the path insubfolder/image_need.html
In
index.html
the image link is broken:Setup We are using python Python
3.8.13
or3.9.13
. And the following version of sphinx/sphinx-needs:Thanks all for testing and the detailed error reports.
I found a fix and integrated it already into PR #825. Most important part is this one, which recalls Sphinx internal Transformators for need-content copied by
needextract
. https://github.com/useblocks/sphinx-needs/blob/869e6c2330a5482e0291a4ca57fdfe64dcfa3bb3/sphinx_needs/layout.py#L68-L71This fixes also the multiple reference problem reported shortly by @lehaas.
Haven’t found the time to clean the PR and finalize the tests, but will do it soon.
Any tests with your projects are welcome 😉