Skip to content

Investigate: Extract plugin definitions #1

@bentsherman

Description

@bentsherman

It should be possible to add a build step that scans the plugin extension points for definitions (config options, function, operators, channel factories). For example, you can use the Groovy compiler to parse these classes enough to get the AST and extract the annotations from there.

These definitions should be saved to a JSON file or API that can be queried by the language server.

For example, the JSON for nf-boost would look something like this:

{
  "configuration": {
    "boost": {
      "description": "The `boost` scope allows you to configure the `nf-boost` plugin.",
      "options": {
        "cleanup": {
          "description": "Set to `true` to enable automatic cleanup (default: `false`). Temporary files will be automatically deleted as soon as they are no longer needed.\n\nCan also be `'v1'` or `'v2'` to use an implementation that works with publishDir or the workflow output definition, respectively. Setting to `true` is equivalent to `'v1'`.",
          "type": "String"
        },
        "cleanupInterval": {
          "description": "Specify how often to scan for cleanup (default: `'60s'`).",
          "type": "Duration"
        }
      }
    }
  },
  "factories": [],
  "functions": [
    {
      "name": "fromJson",
      "arguments": [
        {
          "name": "source",
          "type": "Path"
        }
      ],
      "returnType": "Object"
    },
    {
      "name": "fromJson",
      "arguments": [
        {
          "name": "text",
          "type": "String"
        }
      ],
      "returnType": "Object"
    },
    {
      "name": "toJson",
      "arguments": [
        {
          "name": "value",
          "type": "Object"
        },
        {
          "name": "value",
          "type": "boolean",
          "defaultValue": false
        }
      ],
      "returnType": "String"
    },
    // ...
  ],
  "operators": [
    {
      "name": "scan",
      "arguments": [
        {
          "name": "seed",
          "defaultValue": null
        },
        {
          "name": "accumulator",
          "type": "Closure"
        }
      ]
    },
    // ...
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions