Repository: useblocks/sphinx-needs (python)

Issue:
Get warning, if I try to configure `post_template` with `needs_global_options`
if I try to configure `post_template` with `needs_global_options`, I do get following Warning:
`WARNING: needs_global_options 'post_template' must also exist in needs_extra_options, needs_extra_links, or ['constraints', 'layout', 'status', 'style', 'tags']`

I believe `NeedsCoreFields` in `sphinx_needs.data` is to [restricted](https://github.com/useblocks/sphinx-needs/blob/490603d833bafcd87383ec2de88fab0066b01558/sphinx_needs/data.py#L83C1-L83C16).

I would want to change at least the options: collapse, hide, template, pre_template, post_template, type_color, type_style

My workaround in `conf.py`
```
from sphinx_needs.data import NeedsCoreFields
patched_options = [
    ('collapse', 'bool'), ('hide', 'bool'),
    ('template', 'str'), ('pre_template', 'str'), ('post_template', 'str'),
    ('type_color', 'str'), ('type_style', 'str'),
]

for po_name, po_type in patched_options:
    NeedsCoreFields[po_name]["allow_default"] = po_type
```

Pull request:
🔧 Allow pre/post template `global_options`
Even though these template are an awful design decision in sphinx-needs (hint, you don't jinja when you have a fully expressive restructuredtext syntax), let's add them back in for now for back-compatibility

closes #1420 

Patch:
diff --git a/sphinx_needs/data.py b/sphinx_needs/data.py
index 7411515e..bfe2ca4b 100644
--- a/sphinx_needs/data.py
+++ b/sphinx_needs/data.py
@@ -280,11 +280,13 @@ NeedsCoreFields: Final[Mapping[str, CoreFieldParameters]] = {
         "description": "Pre-template of the need.",
         "schema": {"type": ["string", "null"], "default": None},
         "exclude_external": True,
+        "allow_default": "str",
     },
     "post_template": {
         "description": "Post-template of the need.",
         "schema": {"type": ["string", "null"], "default": None},
         "exclude_external": True,
+        "allow_default": "str",
     },
     "content": {
         "description": "Content of the need.",


Test patch:
diff --git a/tests/test_global_options.py b/tests/test_global_options.py
index 2046e6f8..96e2698c 100644
--- a/tests/test_global_options.py
+++ b/tests/test_global_options.py
@@ -31,7 +31,7 @@ def test_doc_global_option_old(test_app, snapshot):
         "WARNING: needs_global_options 'link3' has a default value that is not of type 'str_list' [needs.config]",
         "WARNING: needs_global_options 'bad_value_type' has a default value that is not of type 'str' [needs.config]",
         "WARNING: needs_global_options 'too_many_params' has an unknown value format [needs.config]",
-        "WARNING: needs_global_options 'unknown' must also exist in needs_extra_options, needs_extra_links, or ['constraints', 'layout', 'status', 'style', 'tags'] [needs.config]",
+        "WARNING: needs_global_options 'unknown' must also exist in needs_extra_options, needs_extra_links, or ['constraints', 'layout', 'post_template', 'pre_template', 'status', 'style', 'tags'] [needs.config]",
         "WARNING: needs_global_options uses old, non-dict, format. please update to new format: {'layout': {'default': 'clean_l'}, 'option_1': {'default': 'test_global'}, 'option_2': {'default': \"[[copy('id')]]\"}, 'option_3': {'predicates': [('status == \"implemented\"', 'STATUS_IMPL')]}, 'option_4': {'predicates': [('status == \"closed\"', 'STATUS_CLOSED')], 'default': 'STATUS_UNKNOWN'}, 'option_5': {'predicates': [('status == \"implemented\"', 'STATUS_IMPL'), ('status == \"closed\"', 'STATUS_CLOSED')], 'default': 'final'}, 'link1': {'default': ['SPEC_1']}, 'link2': {'predicates': [('status == \"implemented\"', ['SPEC_2', \"[[copy('link1')]]\"]), ('status == \"closed\"', ['SPEC_3'])], 'default': ['SPEC_1']}, 'tags': {'predicates': [('status == \"implemented\"', ['a', 'b']), ('status == \"closed\"', ['c'])], 'default': ['d']}} [needs.deprecated]",
     ]
 
@@ -65,7 +65,7 @@ def test_doc_global_option(test_app, snapshot):
         "WARNING: needs_global_options 'link3' has a default value that is not of type 'str_list' [needs.config]",
         "WARNING: needs_global_options 'bad_value_type' has a default value that is not of type 'str' [needs.config]",
         "WARNING: needs_global_options 'too_many_params', 'predicates', must be a list of (filter string, value) pairs [needs.config]",
-        "WARNING: needs_global_options 'unknown' must also exist in needs_extra_options, needs_extra_links, or ['constraints', 'layout', 'status', 'style', 'tags'] [needs.config]",
+        "WARNING: needs_global_options 'unknown' must also exist in needs_extra_options, needs_extra_links, or ['constraints', 'layout', 'post_template', 'pre_template', 'status', 'style', 'tags'] [needs.config]",
     ]
 
     needs_config = NeedsSphinxConfig(test_app.config)