-
Notifications
You must be signed in to change notification settings - Fork 8
Confusing/inconsistent behavior in enforcing requirement for File/LibFile block at file start. #19
Description
Summary
Currently, the docs state that all files must have a File: or LibFile: block at the start of the file
. However, the parser does not explicitly enforce this. Instead, if either of those blocks have not been previously encountered, it'll automatically inject a LibFile block upon first encountering one of a handful of other blocks (e.g. Section, Includes, etc.).
This issue is further compounded when a File/LibFile block is inadvertently added after one of the blocks which results in an automatically generated LibFile block. This causes an error to be displayed without a clear indication that one had automatically been generated.
I ran into this issue when I accidentally created a File block after a FileGroup block and couldn't understand how to resolve the issue until I reviewed the source to determine how the application was behaving behind the scenes.
Steps to reproduce
- Create a file,
test.scad, with the following content
// FileGroup: Test Library
// File: test.scad
- Execute
openscad-docsgen <path to test.scad>Expected behavior
Either
- Explicitly provide an error when a
File/LibFileblock is not the first block of a file. (To be consistent with the docs)- Effectively strict by default
or
- Print a warning to console to indicate that a
Fileblock has been auto-generated in the absence of one - Ignore subsequent
Fileblocks or overwrite existingFileblock in the parser if they're encountered (providing a warning when doing so)
Actual behavior
The application displays an error indicating that a File/LibFile block has already been specified, when it has not.
Output:
Parsing...
test.scad
!! ERROR at test.scad:2: File/Libfile block already specified, while declaring block: "File"