Mermade / widdershins

OpenAPI / Swagger, AsyncAPI & Semoasa definitions to (re)Slate compatible markdown
https://mermade.github.io/reslate
MIT License
1.48k stars 321 forks source link

Error picking up user templates #560

Open MikeAdamsMews opened 7 months ago

MikeAdamsMews commented 7 months ago

Describe the bug I cannot get Widdershins to pick up and use my custom template. I'm sure I must be doing something wrong, but it's hard to diagnose when there is no apparent confirmation or otherwise that it is picking up a user template, because the default behavior is to use the standard template.

I'm running Widdershins CLI on Mac with variations of this command:

widdershins 'swagger.yaml' -o 'openapi.md' -u 'mytemplates'

I've tried './mytemplates' instead of 'mytemplates', as well as trying the absolute path obtained through $realpath, but it makes no difference.

I have a sub-directory called mytemplates and in that I have copied the contents of openapi3 from the Widdershins template sub-directory and I've edited the main.dot file with a simple edit to test if it's picking up this version and not the default version. My change is to remove the following line of Markdown which appears in the header of the output file.

> Scroll down for {{? data.header.language_tabs.length}}code samples, {{?}}example requests and responses.{{? data.header.language_tabs.length}} Select a language for code samples from the tabs above or the mobile navigation menu.{{?}}

When I run the command, the deleted Markdown still appears in the output file, indicating that it is not processing my custom main.dot.

I have no indication of the cause of the error:

I am pretty sure this must be an error on my part and not in Widdershins, but I'm running out of ideas. And at the very least, it would be good to have some diagnostics support, e.g. if the -u option is used then it should report an error if it can't find or can't process the custom template.

To Reproduce Steps to reproduce the behavior:

  1. Command-line: widdershins 'swagger.yaml' -o 'openapi.md' -u 'mytemplates'
  2. My input file: (please link to a gist) swagger.yaml
  3. My user template is mytemplates/openapi3 with main.dot edited as described above.
  4. Output file openapi1.md still contains the Markdown "Scroll down for..." (as above)

Expected behavior Output file openapi1.md should not contain the Markdown "Scroll down for..." (as above)

Screenshots n/a

Versions:

Additional context n/a

MikeAdamsMews commented 7 months ago

I have resolved the issue by pointing to the openapi3 sub-directory, not the main templates directory, i.e. command-line should be as follows: widdershins 'swagger.yaml' -o 'openapi.md' -u 'mytemplates/openapi3' However, I think the issue I raised is still valid. A small change to the documentation could save users hours of lost time, and others might not be as persistent as me. Thks :-)