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/LibFile block 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
File block has been auto-generated in the absence of one
- Ignore subsequent
File blocks or overwrite existing File block 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"
Summary
Currently, the docs state that all files must have a
File:orLibFile: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
LibFileblock upon first encountering one of a handful of other blocks (e.g.Section,Includes, etc.).This issue is further compounded when a
File/LibFileblock is inadvertently added after one of the blocks which results in an automatically generatedLibFileblock. 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
Fileblock after aFileGroupblock 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
test.scad, with the following contentopenscad-docsgen <path to test.scad>Expected behavior
Either
File/LibFileblock is not the first block of a file. (To be consistent with the docs)or
Fileblock has been auto-generated in the absence of oneFileblocks 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/LibFileblock has already been specified, when it has not.Output: