Skip to content

Add Gherkin (.feature) support — BDD spec files are currently invisible to the graph #2349

Open

Description

@asanko-nettle

Problem

.feature files (Gherkin — Cucumber, behave, SpecFlow, pytest-bdd) produce zero nodes. classify_file finds the extension in none of CODE_EXTENSIONS / DOC_EXTENSIONS / PAPER_EXTENSIONS / IMAGE_EXTENSIONS / OFFICE_EXTENSIONS / VIDEO_EXTENSIONS, so it returns None and the walker drops the file entirely.

Observed on 0.9.23 (detect.py, extension sets around lines 31-36, classify_file around 437-471). Line numbers may differ on the current development branch.

Why it matters

In a BDD codebase the .feature files are the executable specification — simultaneously the requirements document and the test suite. They are arguably the highest-value prose in the repo, and they are the one thing the graph cannot see. In our repo that is 131 files describing the contract the entire codebase implements; every one of them is absent from the graph.

This affects any Cucumber / behave / SpecFlow / pytest-bdd project, not just ours.

Why the one-line version isn't enough

Adding .feature to DOC_EXTENSIONS makes the files visible, but with no entry in the _DISPATCH table they get _get_extractor() == None and an empty structural pass — visible but with no captured structure, no better than unstructured text.

Proposed fix

Implement a real Gherkin extractor following the "Adding a new language extractor" checklist in ARCHITECTURE.md:

  1. extract_gherkin() in extractors/gherkin.py, parsing Feature / Background / Rule / Scenario / Scenario Outline / Examples / tags / Given-When-Then-And-But steps, plus docstrings and data tables.
  2. Register .feature in the _DISPATCH table.
  3. Add .feature to DOC_EXTENSIONS.
  4. Fixture + test following the existing tests/test_languages.py convention.

Gherkin's grammar is line-based and small, so this needs no tree-sitter grammar — scope should be comparable to the existing markdown extractor.

Offer

Happy to implement and submit this as a PR. Two questions before I start:

  • Is Gherkin support something you want in the project?
  • Which branch should a PR target? I see active development on v8 while PyPI is publishing 0.9.x.

Activity

  1. MohabMohie commented on Aug 18, 2026

    @MohabMohie

    SHAFT_ENGINE still needs .feature as deterministic CODE (ShaftHQ/SHAFT_ENGINE#5120). Tracking the extractor constraint with the other families in #2851.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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