dmd icon indicating copy to clipboard operation
dmd copied to clipboard

Plugins should be able to set default values for any setting

Open DarrenPaulWright opened this issue 6 years ago • 5 comments

I own the plugin https://github.com/DarrenPaulWright/dmd-readable where I remove the global index partial because I don't need it, but I would prefer to just change the default for global-index-format to "none" so other users can override it. If this is possible now, I couldn't find any documentation on it. Thanks!

DarrenPaulWright avatar Oct 08 '19 03:10 DarrenPaulWright

Hi, apologies for the lack of docs on this subject.. in dmd, there is a helper called optionSet. In your plugin partials you can use the helper to force a particular option, like this:

{{optionSet "global-index-format" "none"~}}

See here for an example of optionSet usage in the jsdoc2md testbed. See here for the output.

75lb avatar Oct 08 '19 20:10 75lb

Ok, I got that to work by adding {{optionSet "global-index-format" "none"~}} to main.hbs, but how would users of my plugin override this setting? Would they have to provide their own main.hbs with a different setting? I tried setting -g table in an npm script and it didn't work.

DarrenPaulWright avatar Oct 09 '19 04:10 DarrenPaulWright

I moved the setting to template.hbs, so that should work for now, but I still feel like a setting passed in through the cli should win over anything set with optionSet in any of the templates.

DarrenPaulWright avatar Oct 09 '19 05:10 DarrenPaulWright

I still feel like a setting passed in through the cli should win

It should, and usually does. I think what you need is a means for plugin authors to set their own default values. I'll look into this, thanks for the input.

75lb avatar Oct 09 '19 14:10 75lb

Thanks!

DarrenPaulWright avatar Oct 09 '19 16:10 DarrenPaulWright