alexprey / sveltedoc-parser

Generate a JSON documentation for a Svelte (https://github.com/sveltejs/svelte) component
https://www.npmjs.com/package/sveltedoc-parser
MIT License
90 stars 7 forks source link

(small) Add final newline? #59

Closed Florian-Schoenherr closed 3 years ago

Florian-Schoenherr commented 3 years ago

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)

alexprey commented 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?

Florian-Schoenherr commented 3 years ago

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.

alexprey commented 3 years ago

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!

Florian-Schoenherr commented 3 years ago

Ah so it is a js object but when writing to a file it doesn't have a last new line. Thank you!