widdershins icon indicating copy to clipboard operation
widdershins copied to clipboard

Allow reusing instance to convert multiple documents

Open DavidBiesack opened this issue 5 years ago • 4 comments

I'm running widdershins from a node app, converting a set of openapi definition documents (about 16 documents) into markdown (to feed into shins). I don't see how to reuse the instance effectively. As is, I run

        converter.convert(openapiObj, options, function (err, markdownString) { ... }

inside a loop, and this ends up reading/parsing all the templates on each OpenAPI definition.

Describe the solution you'd like Provide access to the instance after initializing it, i.e.

    converter.load(options);  // or converter.initialize()

which can then be reused to convert multiple documents.

(Note: for my use case, all documents use the same set of options.)

Alternatively, let converter retain state, so it does not have to reparse everything each time convert is called.

DavidBiesack avatar Jan 07 '19 19:01 DavidBiesack

Is this just a performance / efficiency enhancement? I think parsing the templates probably takes less time than formatting the actual output of each input document...

MikeRalphson avatar Jan 08 '19 15:01 MikeRalphson

It's minor. The processing log gets swamped by all the repeated lines about loading all the template files and is thus harder to view or track.

DavidBiesack avatar Jan 09 '19 00:01 DavidBiesack

Note: should only be happening if options.user_templates is set...

MikeRalphson avatar Jul 22 '19 10:07 MikeRalphson

yes, I'm using user_templates...

DavidBiesack avatar Jul 25 '19 01:07 DavidBiesack