Closed Florian-Schoenherr closed 3 years ago
Hi @Florian-Schoenherr, can you please describe in detail what you do and what you get? I'm not understand what you mean... The parser failed when works with files ended by empty line at the end, or you propose to add new empty lines to all source files in the code of parser?
Oh, sorry, I just mean after parsing there is no final newline in the generated json. We are doing this:
async function generateJSON(filename) {
const doc = await sveltedoc.parse({ filename, ...defaults });
const name = basename(filename, '.svelte');
await writeFile(`./src/${name}.json`, fmt(doc, format), (err) => {
if (err) throw err;
console.log(`${name}.json has been saved`);
});
}
It could also be a fault of json-format.
Ok, thanks! The parser just provide structured object with all metadata that can be parsed. And then you can do with that anything.
You need to check your fmt
method to ensure that it works correctly. This issue is not related to the parser.
But, anyway thanks for using it and thanks for a question!
Ah so it is a js object but when writing to a file it doesn't have a last new line. Thank you!
Either we have implemented something wrong or the parser doesn't spit out a final newline (in the generated json). If it's on your end, it would be nice to have. (But I actually don't know if that final newline is needed, just know it's best practice because unix)