mariotoffia / goasciidoc

Document your go code using asciidoc instead of godoc
Apache License 2.0
18 stars 0 forks source link

Support template directory #12

Closed ccremer closed 3 years ago

ccremer commented 3 years ago

Currently, each template override has to be explicitly configured with --overrides name=file, e.g.

go run github.com/mariotoffia/goasciidoc -o godoc.adoc -r import=docs/godoc-templates/import.tpl -r var=docs/godoc-templates/var.tpl

But it would be helpful if we can specify a template directory, and use the file basename as the name for *.tpl files, e.g.

$ ls docs/godoc-templates 
import.tpl  var.tpl

A file named var.tpl would provide a name for the var template (compare with var=... above)

go run github.com/mariotoffia/goasciidoc -o godoc.adoc --template-dir docs/godoc-templates

at the moment, I have to construct each individual argument like this:

$ for file in $(find docs/godoc-templates/*.tpl); do name="$(basename ${file%.*})" && printf "%s %s=%s" '-r' $name $file; done && printf '\n'
-r import=docs/godoc-templates/import.tpl -r var=docs/godoc-templates/var.tpl

which works, but isn't exactly pretty

mariotoffia commented 3 years ago

Hi @ccremer and thanks for the nice suggestion. I'll put it on my todo-list (if you don't want to do a PR and add this excellent idea!)

Cheers, Mario :)

mariotoffia commented 3 years ago

@ccremer I've added support for --templatedir in v0.4.0 (see release notes / README.md).

Cheers, Mario :)

ccremer commented 3 years ago

Cool, many thanks :) I'll try it out when I get some spare time.