question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Needextract does not work with images

See original GitHub issue

Describe the bug We want to add images to the content of needs and reference these needs 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:

  1. Create projectA:
    mkdir projectA
    cd projectA
    sphinx-quickstart 
    
    I choose to separate source and build folder during the build, i.e., Separate source and build directories (y/n) [n]: y
  2. Configure projectA by adding the following lines to projectA/source/conf.py:
    extensions = ["sphinx_needs"]
    
  3. Add an image to the source folder, i.e… projectA/source/image.png.
  4. Create a requirement by adding the following lines in projectA/source/index.rst:
    .. need:: NeedA
       :id: NEEDA
    
  5. 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 image

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:closed
  • Created 10 months ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lehaascommented, Dec 2, 2022

@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:

  1. Create projectA:
    mkdir projectA
    cd projectA
    sphinx-quickstart 
    
    I choose to separate source and build folder during the build, i.e., Separate source and build directories (y/n) [n]: y
  2. Configure projectA by adding the following lines to projectA/source/conf.py:
    extensions = ["sphinx_needs"]
    
  3. Move to the projectA/source.
  4. Add an image to the source folder, let us call it image.png.
  5. Create a subfolder of source contain a file for the need definition subfolder/image_need.rst and add the following content :
Page
====

.. need:: NeedA
   :id: NEEDA

   .. image:: /image.png
  1. Link the image with needextract in `index.rst:
.. toctree::
   :maxdepth: 2
   :caption: Contents:

   subfolder/image_need.rst

.. needextract:: NEEDA

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 second need displays the path in subfolder/image_need.html grafik

In index.html the image link is broken: grafik

Setup We are using python Python 3.8.13 or 3.9.13. And the following version of sphinx/sphinx-needs:

sphinx-needs                  1.1.0
Sphinx                        5.3.0
0reactions
danwoscommented, Dec 12, 2022

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-L71

This 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 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Images and figures can't have absolute paths: leading slash is ...
Describe the bug Images and figures can't have absolute paths: leading slash is removed at build. To Reproduce Steps to reproduce the ...
Read more >
needextract - Sphinx-Needs 1.1.0 documentation
needextract generates copies of filtered needs with custom layout and style. ... Sphinx-Needs can request issues and other data from external services like ......
Read more >
Challenge 13 - Help - UiPath Community Forum
Basically I need extract what squares are checked per each line. ... The problem is that I then want to Find Image but...
Read more >
Is there a way to set the image scaling method in reST/Sphinx?
You can't do this with Sphinx. You need to preprocess the image with a graphic tool, not with a documentation tool.
Read more >
Classify satellite images using artificial neural network (ANN)
and regarding glcm i didnt know whether my extraction is right or not.. do we need extract the texture of preprocesssed image or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found