ffig icon indicating copy to clipboard operation
ffig copied to clipboard

Provide a mechanism to list the available generators / templates

Open ajbennieston opened this issue 6 years ago • 1 comments

It would be useful to be able to do something like python -m ffig --list-generators to obtain a list of the registered generators, templates and template aliases.

This would be useful in a number of situations, including

  • new users exploring the capabilities of FFIG.
  • the ffig-explorer REST API providing a way to query the generator names available.
  • developers who want to check that their generator or template has been properly detected by FFIG.

In order to support these use cases, in particular the REST API, the functionality to implement this should be exposed as a Python function in the ffig package, as well as via a command-line argument when FFIG is invoked as the main executable.

Some complications:

  • Not all templates represent complete binding generation; e.g. the support for Go bindings is split across two templates.
  • Some templates are used by a generator (Go, Python). As we move more logic into generators, the proportion of these will increase.
  • Some templates have aliases, e.g. ruby is an aliased generator for rb.tmpl.
  • Templates, and, in some cases, generators, don't always have very meaningful names. This suggests we should add a description field, at least for the generators, which can be set when a generator registers itself.

Sub-tasks

  • [ ] Add a description field for generator registration and to all existing generators (PR #403).
  • [ ] Add a FFIG.py function to expose the list of generators & descriptions.
  • [ ] Add a --list-generators cmdline option.
  • [ ] Extend to support template files that are not registered as part of a generator or an alias.

ajbennieston avatar Apr 13 '18 19:04 ajbennieston

PR #403 includes support for descriptions for generators and a list function within the GeneratorContext class.

ajbennieston avatar Apr 13 '18 22:04 ajbennieston