-
Notifications
You must be signed in to change notification settings - Fork 8
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
Resolving xref issue 115-nyaml2nxdl-xref-edge-cases #116
Conversation
Thanks for fixing the original issue that I raised this morning. In the meantime, I also tested some more edges case and I am not sure that the behavior is the one we intended. For example, the following three xrefs would convert properly: NXarchive(NXobject):
(NXentry)entry:
\@index:
title:
experiment_identifier(NX_CHAR):
doc:
- |
Test doc.
- | # Example0
xref:
spec: spec0
term: term0
url: url0"
- | # Example1
" xref:
spec: spec1
term: term1
url: url1"
- | # Example2
spec: spec2
xref:
term: term2
url: url2" Especially the last one seems weird since - | # Example3
xref:
spec: spec3
term: term3
url: url3 I am therefore a bit confused as to what the rules are for using the xref feature. I thought the plan was to have it as described in example 3, i.e., you first check if xref is there and then if the other three keywords are present and properly indented. Can I just write the |
Thank you for creating such a variety of examples. here is the docs But the last one does not make any sense because xref should be in the upper hierarchy or administrative location. xref refers that it has some amount of reference information which are spec, term and URL probably more other info may be added later. But reshuffling in spec, term and URL makes sense. |
I agree that example 2 above does not make sense, but even this one converts to This concept is related to term `term2`_ of the spec2 standard.
.. _term2: url2 Wouldn't we want to catch that and prevent the user from writing the nyaml like this? |
your are absolutely right. In that case we should raise and error (this is your proposal, right). Thanks for bringing it. |
I am thinking that maybe it is a good idea to enforce a certain structure:
|
@RubelMozumder @lukaspie I made a suggestion for a new xref parsing function. Can you check and test it? Probably we need to add error catching when yaml cannot be parsed. Edit: I added an additional test where we can parametrise different inputs. Maybe we should have one for cases where we wan't it to fail, too. |
Thanks @domna. Exactly, what I wanted to say is that the xref part should be a valid yaml! This function works as expected for all of the examples outlined above. The tests also look good. My proposal for the suggested use in the documentation is to use 2-space indentation. Like this, you don't need to use doc:
- |
Test doc.
- |
xref:
spec: spec0
term: term0
url: url0 |
I agree, maybe we should even disallow the usage of 2-space indentation should work. As long as all the keys are lined up any indentation should work. However, we still have the problem if there are duplicate keys. While yaml says keys should be unique pyyaml just takes the last value. It's a known bug/feature yaml/pyyaml#165 (the community seems to not have agreed yet whether this is a bug or a feature). But I think we could add a simple check (split to lines and check if |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
I added some checks for edge cases. Should be all fine now (except that removing of Edit: I removed the support for it, because it also introduces artifact's for other docstrings. Starting and ending |
I see there are a few tests for indivisual correct and wrong one, thanks @domna. |
Sorry, before getting there you finished it. |
Doesn't matter for yaml as long as it's inside |
* Resolving xref issue 115-nyaml2nxdl-xref-edge-cases * Suggestion for new xref function * Remove unused re * Adds test for xref handling * Use strip short notation * Adds tests for invalid xref * update nyaml2nxdl readme * Add edge cases for xref * Re-introduce removal of starting " * Remove unused import * Remove support for " in xref docstring --------- Co-authored-by: domna <florian.dobener@physik.hu-berlin.de> Co-authored-by: Lukas Pielsticker <50139597+lukaspie@users.noreply.github.com> # Conflicts: # dev_tools/nyaml2nxdl/README.md # dev_tools/nyaml2nxdl/nyaml2nxdl_backward_tools.py # dev_tools/nyaml2nxdl/nyaml2nxdl_forward_tools.py # dev_tools/tests/test_nyaml2nxdl.py
* Resolving xref issue 115-nyaml2nxdl-xref-edge-cases * Suggestion for new xref function * Remove unused re * Adds test for xref handling * Use strip short notation * Adds tests for invalid xref * update nyaml2nxdl readme * Add edge cases for xref * Re-introduce removal of starting " * Remove unused import * Remove support for " in xref docstring --------- Co-authored-by: domna <florian.dobener@physik.hu-berlin.de> Co-authored-by: Lukas Pielsticker <50139597+lukaspie@users.noreply.github.com> # Conflicts: # dev_tools/nyaml2nxdl/README.md # dev_tools/nyaml2nxdl/nyaml2nxdl_backward_tools.py # dev_tools/nyaml2nxdl/nyaml2nxdl_forward_tools.py # dev_tools/tests/test_nyaml2nxdl.py
* Resolving xref issue 115-nyaml2nxdl-xref-edge-cases * Suggestion for new xref function * Remove unused re * Adds test for xref handling * Use strip short notation * Adds tests for invalid xref * update nyaml2nxdl readme * Add edge cases for xref * Re-introduce removal of starting " * Remove unused import * Remove support for " in xref docstring --------- Co-authored-by: domna <florian.dobener@physik.hu-berlin.de> Co-authored-by: Lukas Pielsticker <50139597+lukaspie@users.noreply.github.com> # Conflicts: # dev_tools/nyaml2nxdl/README.md # dev_tools/nyaml2nxdl/nyaml2nxdl_backward_tools.py # dev_tools/nyaml2nxdl/nyaml2nxdl_forward_tools.py # dev_tools/tests/test_nyaml2nxdl.py
Changes:
term
will be accept anything in-between aspace
andstandard
Fixes #115