Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dashes in Need IDs Not Supported by needflow #61

Closed
tlovett opened this issue Jul 11, 2018 · 1 comment
Closed

Dashes in Need IDs Not Supported by needflow #61

tlovett opened this issue Jul 11, 2018 · 1 comment

Comments

@tlovett
Copy link
Contributor

tlovett commented Jul 11, 2018

If a need has an ID that has a dash in it, then needflow will not be able to render the diagram. This is because PlantUML does not support dashes in entity names.

Example:

TEST DOCUMENT
=============

.. req:: Log out (open)
    :id: A-001
    :status: open
    :tags: user;authentication

    The user should be able to log out

.. req:: Authenticate user
    :id: A-002
    :status: open
    :tags: user;login
    :links: A-001

    The user must be authenticated

.. needflow::

Would result in error like this:

image

I have a fix for this, and I'll provide a Pull Request later today. The fix is simply to transform the entity names in the diagram definition to replace dashes with underscores. This doesn't affect how the diagram is displayed as the text used in the diagram node does not have a restriction on dashes - only the entity names in the diagram definition.

tlovett added a commit to tlovett/sphinxcontrib-needs that referenced this issue Jul 11, 2018
…rscores

in entity names in PlantUML diagram definitions
tlovett added a commit to tlovett/sphinxcontrib-needs that referenced this issue Jul 11, 2018
…rscores

in entity names in PlantUML diagram definitions
danwos pushed a commit that referenced this issue Jul 12, 2018
in entity names in PlantUML diagram definitions
@danwos danwos closed this as completed Jul 12, 2018
@danieleades
Copy link
Contributor

the test case for this is failing for me when I run it locally.

it looks like this -

@with_app(buildername='html', srcdir='doc_test/doc_github_issue_61')
def test_doc_github_61(app, status, warning):
   """
   Test for https://github.com/useblocks/sphinxcontrib-needs/issues/61
   """
   # PlantUML doesn't support entity names with dashes in them, and Needs uses
   # the IDs as entity names, and IDs could have dashes.  To avoid this limitation,
   # Entity names are transformed to replace the dashes with underscores in the entity
   # names.
   # Even if there's an error creating the diagram, there's no way to tell since the
   # error message is embedded in the image itself. The best we can do is make sure
   # the transformed entity names are in the alt text of the image.
   app.build()
   html = Path(app.outdir, 'index.html').read_text()
   alt_text = re.findall('<img.*?alt=(.*?)>', html, re.MULTILINE + re.DOTALL)
   assert len(alt_text) == 5
   assert "A-001" in alt_text[4]
   assert "A-002" in alt_text[4]
   assert "A_001" in alt_text[4]
   assert "A_002" in alt_text[4]

this line causes the issue - assert len(alt_text) == 5. If i debug it, I can see the len(alt_text) is in fact 4.

Probably worth mentioning that i can't run your Tox test suite on my machine, so i'm using the Poetry + Nox version i've cobbled together for #154. I don't think that should matter (and certainly it would be very interesting if it did!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants