klmr / box

Write reusable, composable and modular R code
https://klmr.me/box/
MIT License
833 stars 47 forks source link

Support Markdown in documentation #256

Open mbojan opened 2 years ago

mbojan commented 2 years ago

Currently box does not render Markdown markup in the documentation, which would be very convenient. It seems to be hackable though with:

use::box(m = a/module)
old <- roxygen2:::roxy_meta_set("markdown", TRUE)
box::help(m$some_function) # Markdown is rendered
roxygen2:::roxy_meta_set("markdown", old)

It is hacky because roxy_meta_set() is not exported by roxygen2. Perhaps there is another way (I don't see it)? Or roxygen2 developers could be convinced to expose this functionality in some way.

klmr commented 2 years ago

Since I don’t use Markdown in ‘roxygen2’ documentation myself I’m not very familiar with it.

As far as I can see, a proper solution would require the possibility for the user to somehow opt into Markdown for their module, right? Using @md inside a documentation comment already works. If I understand this feature request correctly, what’s missing is some way of enabling Markdown markup for all ‘roxygen2’ comments inside a module, correct?

Since ‘box’ modules currently don’t have an equivalent of a DESCRIPTION file, the best way of implementing this would probably be via a new, custom ‘royxgen2’ tag that would be used at the beginning of a module; something like @mdAll maybe?

mbojan commented 2 years ago

A tag @mdAll sounds good.

Alternatively the example in the vignette uses __init__.r for some "global" code, so I guess a call to a function enabling that could perhaps work too, although the tag sounds simpler.