jolly-good-toolbelt / sphinx_gherkindoc

A tool to convert Gherkin into Sphinx documentation
https://jolly-good-toolbelt.github.io/sphinx_gherkindoc/
11 stars 10 forks source link

Cannot generate feature file with Rule: keyword #55

Open GuillaumeMorinQc opened 1 year ago

GuillaumeMorinQc commented 1 year ago

I cannot generate rst file from a feature file containing Rule: keyword . i'm using version 6.1.3 of sphinx_gherkindoc. Here an example :

Feature: Gherkin v6 Example -- with Rules
  Feature description line 1.

  Background: Feature.Background
    Given feature background step_1

  Rule: R1 (with Rule.Background)
    Rule R1 description line 1.

    Scenario: R1.Scenario_1
      When rule R1 scenario_1 step_1
      Then rule R1 scenario_1 step_2

The following error happened:

Traceback (most recent call last):
  File "/home/guimor1/repos/opflo/.venv/bin/sphinx-gherkindoc", line 8, in <module>
    sys.exit(main())
  File "/home/guimor1/repos/opflo/.venv/lib/python3.8/site-packages/sphinx_gherkindoc/cli.py", line 309, in main
    process_args(args, gherkin_path, output_path, args.doc_project)
  File "/home/guimor1/repos/opflo/.venv/lib/python3.8/site-packages/sphinx_gherkindoc/cli.py", line 105, in process_args
    feature_rst_file = feature_to_rst(
  File "/home/guimor1/repos/opflo/.venv/lib/python3.8/site-packages/sphinx_gherkindoc/writer.py", line 365, in feature_to_rst
    feature = feature_class(root_path, source_path)
  File "/home/guimor1/repos/opflo/.venv/lib/python3.8/site-packages/sphinx_gherkindoc/parsers/behave.py", line 39, in __init__
    self._data = behave.parser.parse_file(source_path)
  File "/home/guimor1/repos/opflo/.venv/lib/python3.8/site-packages/behave/parser.py", line 18, in parse_file
    return parse_feature(data, language, filename)
  File "/home/guimor1/repos/opflo/.venv/lib/python3.8/site-packages/behave/parser.py", line 26, in parse_feature
    result = Parser(language).parse(data, filename)
  File "/home/guimor1/repos/opflo/.venv/lib/python3.8/site-packages/behave/parser.py", line 148, in parse
    self.action(line)
  File "/home/guimor1/repos/opflo/.venv/lib/python3.8/site-packages/behave/parser.py", line 292, in action
    raise ParserError(msg, None, self.filename)
behave.parser.ParserError: Failed to parse "/home/guimor1/repos/opflo/src/OtdrOpflo/otdr_opflo_app/test/bdd/features/application/version6.feature":
Parser failure in state steps, at line 7: "Rule: R1 (with Rule.Background)"

Is it somethting specific to configure for it to work? I was assuming that since behave parser covers gherkin version 6 that this simple file should work

GuillaumeMorinQc commented 1 year ago

Fix the problem using a dev version(1.2.7.dev0) of behave parser. But now nothing is generated after i hit a rule in the gherkin.

Is some work has been done to convert rules in rst ?

dgou commented 1 year ago

I am not aware of any work to convert to support "Rule" at this time... A PR to does that would be happily reviewed and shepherded through to merge though!

Given the extra level of nesting, I don't have a feel for how much work this might be, but I'm not against supporting it.