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

Dynamic function cannot access needservice need types #1203

Open
jumbo172 opened this issue Jul 4, 2024 · 0 comments
Open

Dynamic function cannot access needservice need types #1203

jumbo172 opened this issue Jul 4, 2024 · 0 comments

Comments

@jumbo172
Copy link

jumbo172 commented Jul 4, 2024

I have a custom needservice that mines JIRA tickets and writes data to each requirement need.
I have a dynamic function that manipulates data of the 'components' option of each requirement need and updates the need 'in place'.
This ensures that the data for needs has been processed inside conf.py and is not reliant on any dynamic functions called from directives inside rst within the document.

The dynamic function is called like this:

needs_global_options = { 
   'components': ('[[convert_jira_components_to_list()]]'),
}

And is registered like this:

def setup(app):
    add_dynamic_function(app, convert_jira_components_to_list)

The issue is that when the dynamic function is called using global options:

needs_global_options = { 
'components': ('[[convert_jira_components_to_list()]]', 'type=="requirement"'),
}

The requirement needs generated by the needservice are unavailable in each need variable. I have other requirements not generated by needservice and these are available in each need variable.

So the workaround is to use the needs variable in the dynamic function. I can then loop over each need of the needs variable.
The problem with this is that the dynamic function is called for every need type in the filter, so it executes multiple times. I have to put in extra code to restrict the function to only execute once.

This works, but it's ugly for 2 reasons. Firsty the execute once restriction, secondly I am using needs_global_options to return values to the 'components' option, but I am not returning anything and updating the need in place.

Is there a reason why needservice needs are not available in each need variable inside dynamic functions, but other needs are?
Is there some way to ensure that a dynamic function gets called just once, not for every need?

Thanks

@jumbo172 jumbo172 changed the title Dynamic function Dynamic function cannot access needservice need types Jul 4, 2024
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

1 participant