sphinx-needs icon indicating copy to clipboard operation
sphinx-needs copied to clipboard

Defining Snippet templates for different need types

Open haiyangToAI opened this issue 2 years ago • 9 comments

Issue moved from https://github.com/open-needs/open-needs-ide/issues/69.

haiyangToAI avatar Jul 08 '22 08:07 haiyangToAI

Sure this makes sense to move it here

MohSam1 avatar Jul 08 '22 09:07 MohSam1

Hi @MohSam1,

Regarding to your question, the use case you mentioned has been supported in the directive snippet feature.

haiyangToAI avatar Jul 11 '22 11:07 haiyangToAI

@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?

danwos avatar Jul 11 '22 15:07 danwos

The preference is to get an option to define a snippet on my own per need type

MohSam1 avatar Jul 11 '22 18:07 MohSam1

@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

twodrops avatar Aug 24 '22 10:08 twodrops

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.

danwos avatar Aug 24 '22 11:08 danwos

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

twodrops avatar Aug 24 '22 11:08 twodrops

@danwos : Any rough idea when this issue is planned to implemented ?

MohSam1 avatar Aug 30 '22 16:08 MohSam1

Looks like this feature is now implemented, can we close the issue?

MohSam1 avatar Sep 25 '22 18:09 MohSam1