Exception thrown for Option Conversion Functions
See original GitHub issueIf an Option Conversion Function is used and the validation fails, a warning is thrown as expected. For example,
invalid option value: (option: "relates"; value: '')
invalid literal for int() with base 10: ''.
This is however followed by an exception.
Extension error (sphinxcontrib.needs.directives.need):
Handler <function process_need_nodes at 0x7fc72d597ee0> for event 'doctree-resolved' threw an exception (exception: '{need_id}')
How to reproduce
In conf.py
create
needs_extra_options = {
"link": directives.nonnegative_int
}
Create a need with
.. need::
:id: my_need_id
:link: hugo
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
boost::program_option::store throws exception when option ...
actually works fine, it is the boost::program_options::store() function that fails to convert string in utf-8 back to wstring.
Read more >C++ Exceptions Support - Emscripten
This option leverages a new feature that brings built-in instructions for throwing and catching exceptions to WebAssembly. As a result, it can reduce...
Read more >Functional Exceptions In Java - 8th Light
So, what happens when an exception-throwing method is called in a lambda? ... use Optional to convert the nullable return value into a...
Read more >Exception Clause - Apache Camel
You can use the Exception Clause in the Java DSL to specify the error handling you require on a per exception type basis...
Read more >4 Errors and Exception Handling
An exception is a PL/SQL error that is raised during program execution, either implicitly by TimesTen or explicitly by your program. Handle an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No, your way is the correct one. Layout & Style feature cares about the final representation (e.g. showing a link instead of a normal string).
Right now there is no way in Sphinx-Needs to modify an option value, when it gets read in. And I’m not sure if there is a real use case for it, because this would then affected also filter-string and the representation in tables and co. (e.g. given ‘259’ for option `related-link*, should be stored as 'my-server.com/259).
Maybe there is a way to skip creating an extra data element and a dynamic function. You used it to calculate the link target url only. If this calculation could be done in the layout, you would only need the
relates
field and store the number.One solution could be to use your own idea, before you switched to using
<<link()>>
😃 :Another one to enhance the
link()
function to use placeholders in the url part:If we touch the
<<link()>>
function, we maybe should also think about supporting lists of values. E.g.relates
could contain 3 ids like259,341; 231
and the need should show 3 related links.I guess we discussed too many unrelated issues here. The original issue could probably be rejected, as such a usage will anyway affect incremental build. https://sphinxcontrib-needs.readthedocs.io/en/latest/configuration.html#incremental-build-support
The hint on Option Conversion Function here https://sphinxcontrib-needs.readthedocs.io/en/latest/configuration.html#needs-extra-options could be removed as well as it was confusing and made me feel that Option Conversion Function could be used in this way.
The future enhancement related to
link
could be a separate issue.