|
17 | 17 | import concept_utils |
18 | 18 | import file_utils |
19 | 19 | import plain_spec |
20 | | -from plain2code_exceptions import ModuleDoesNotExistError, PlainSyntaxError, UnsupportedBase64Content |
| 20 | +from plain2code_exceptions import ( |
| 21 | + MissingFunctionalitiesError, |
| 22 | + ModuleDoesNotExistError, |
| 23 | + PlainSyntaxError, |
| 24 | + UnsupportedBase64Content, |
| 25 | +) |
21 | 26 | from plain2code_nodes import Plain2CodeIncludeTag, Plain2CodeLoaderMixin |
22 | 27 | from plain2code_utils import find_large_base64_blob |
23 | 28 |
|
@@ -726,11 +731,25 @@ def plain_file_parser( # noqa: C901 |
726 | 731 | f"Plain syntax error: Not all required concepts were defined. {missing_required_concepts_msg}." |
727 | 732 | ) |
728 | 733 |
|
729 | | - if not check_if_functional_requirements_are_specified(plain_file_parse_result.plain_source, []): |
| 734 | + fr_section = plain_file_parse_result.plain_source.get(plain_spec.FUNCTIONAL_REQUIREMENTS) |
| 735 | + |
| 736 | + if fr_section is None: |
| 737 | + # Case 1: no ***functional specs*** header at all. Not a syntax error. |
| 738 | + raise MissingFunctionalitiesError( |
| 739 | + f"Module {module_name} does not have any functionality specified. " |
| 740 | + f"At least one functionality is required for rendering." |
| 741 | + ) |
| 742 | + |
| 743 | + if len(fr_section.children) == 0: |
| 744 | + # Case 2: ***functional specs*** header present but empty. Treated as a syntax error. |
730 | 745 | raise PlainSyntaxError( |
731 | | - f"Plain syntax error: Module '{module_name}' was required but does not contain functional requirements." |
| 746 | + f"Plain syntax error: Module '{module_name}' has an empty " |
| 747 | + f"'{plain_spec.FUNCTIONAL_REQUIREMENTS}' section. At least one functionality must be specified." |
732 | 748 | ) |
733 | 749 |
|
| 750 | + # Functionalities exist: keep the existing "functionality with no implementation reqs specified" check. |
| 751 | + check_if_functional_requirements_are_specified(plain_file_parse_result.plain_source, []) |
| 752 | + |
734 | 753 | exported_definitions = process_required_modules( |
735 | 754 | plain_file_parse_result.required_modules, |
736 | 755 | code_variables={}, |
|
0 commit comments