Open chrisjsewell opened 1 year ago
I do not understand,if the issue only want to change the needs.json output or even the internal representation. Any way: it is cool that the needs.json has the same structure as the internal. So a needs.json can be used as blue print for implementation of filter and functions or even extensions. If you try to overcome clashs, we do need name spaces even in rst. And i belive this is verbose for the author of a rst file.
What do you think?
Any way: it is cool that the needs.json has the same structure as the internal.
Heya, The problem is that there is no structure 😅 The information stored in the needs info, mixes static (known a priori) and dynamic (set by the user) data fields, in a manner that makes it very difficult to work with programmatically and prone to bugs, due to their being no type safety of the data (see for example #995)
we do need name spaces even in rst. And i belive this is verbose for the author of a rst file.
This is not the case, the data is already "naturally" name-spaced. No change is required for user input
Happy to talk offline with you about this @PhilipPartsch In the mean time you may want to check out https://github.com/useblocks/sphinx-needs/blob/64ce426fa60543b388196a349bbf1d4d99d15c86/sphinx_needs/data.py#L80 which I painstakingly deciphered from the current code 😅
My question would be, could you now (without the schema) actually look at the ~85 fields in the above example, and tell me what they all mean and where they come from? I think currently the data.json (and internal representation) is very difficult to understand in its entirety, particularly for new users and developers. Having a clear schema will make this much more accessible
During work on #987, and in particular defining the
NeedsInfoType
schema, it wasTake for example the first need generated in the
needs.json
.As shown in the second example, it would be much clearer to namespace the dynamic values.
Note, for back-compatibility, one may want to "collapse" the namespaces when using them as a context in https://github.com/useblocks/sphinx-needs/blob/a16fb72d44b2c9f65c4065e386e2ad37d0a25870/sphinx_needs/filter_common.py#L280
It is also of note, that currently unset fields are given defaults. It would reduce the memory footprint of the needs data greatly, if unset fields were simply omitted. This work require work in the code base to account for missing keys.