sphinx-needs
sphinx-needs copied to clipboard
Defining Snippet templates for different need types
Issue moved from https://github.com/open-needs/open-needs-ide/issues/69.
Sure this makes sense to move it here
Hi @MohSam1,
Regarding to your question, the use case you mentioned has been supported in the directive snippet feature.
@MohSam1 do you want to define these Snippets on your own?
Or do you need just the predefined snippets, which are available per need-type?
The preference is to get an option to define a snippet on my own per need type
@danwos @haiyangToAI
I would like to know a bit more on this snippet feature.
The current snippet feature is useful only to know which need-types (directives) are available. The snippet that is created has only the mandatory extra_options
(id
and status
), which is not often useful in projects with several types and internally defined "mandatory" extra_options
and extra_links
.
We therefore use the VSCode snippet feature to create complete snippets for each need-type. This is however a duplication of need definition in conf.py within VSCode snippet and hard to maintain. We are therefore creating an alternate need definition possibility using json-schema or RDF (instead of conf.py
), so that more useful snippets can be created out of these. We will be using the json-schema/RDF for several other usecases as well.
Is this task addressing these current limitations in some way? Thats is,
- Have need definition only once
- Use this definition to auto-create snippets
No, the problem of defining something multiple times is not addressed by this. Also, there is no automation of snippet-creation/definition planned.
So it provides the user only the possibility to define the snipper per hand for each need-type.
Example (not a spec ;) ):
needs_ide_snippets = {
'req':
""".. req:: Example
:id:
:status:
:custom_1:
""",
'test':
""".. test:: Test Case 1
:id:
:custom_1:
:custom_2:
"""
}
Maybe this definition does support Jinja in the future, so that it can provide jinja-functions for ID-Generation or other magic.
The key (like req
) could also be a regex, to address multiple need-types with one definition.
Thanks for the clarification @danwos.
This means that the need-definitions and needs_ide_snippets
needs to be kept in sync manually.
I find this better than keeping it in sync with VsCode snipprts. Atleast both are in conf.py
.
Also we can then auto-create needs_ide_snippets
from our json-schema/rdf solution which is also good.
@StephanKuempel fyi
@danwos : Any rough idea when this issue is planned to implemented ?
Looks like this feature is now implemented, can we close the issue?