Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create new tag for customising the existing section Description? #1087

Closed
ramiromagno opened this issue Apr 29, 2020 · 1 comment
Closed

Comments

@ramiromagno
Copy link

ramiromagno commented Apr 29, 2020

Here is an example of what I am trying to achieve.

Here is a snippet of an roxygen comment block:

#' Rf_mkCharLenCE
#'
#' @description
#'
#' \Sexpr[results=rd, stage=render]{c3po:::badge('fnp')} \Sexpr[results=rd, stage=render]{c3po:::badge('c2r')} \Sexpr[results=rd, stage=render]{c3po:::badge('prot')}
#'
#' TODO
#'
#' @section Declaration:
#' ```
#' SEXP Rf_mkCharLenCE(const char *name, int len, cetype_t enc);
#' ```

Now, you see those three \Sexpr commands? They are analogous to those used, e.g., in rlang:

https://github.com/r-lib/rlang/blob/a90b04b9d6a17f1aabadaed357784efc22116d2a/R/eval-tidy.R#L1-L6

I use them to generate nice looking svg badges in my documentation.

snap

My question is: would it be possible to generate a new tag, say, @badge that accepts keywords and acts on them by generating the corresponding code described above? I mean something like:

#' @badge fnp c2r prot

in context:

#' Rf_mkCharLenCE
#'
#' @description
#'
#' @badge fnp c2r prot
#'
#' TODO
#'
#' @section Declaration:
#' ```
#' SEXP Rf_mkCharLenCE(const char *name, int len, cetype_t enc);
#' ```

From what I have read from the docs, creating a new tag creates a new section, so it would not apply to my case here because I need to edit an existing section, i.e., Description. So it seems to me that creating a new roclet is the way to go but I am not sure still if I can use that approach to change an existing section such as Description... I am sorry if I sound confusing, it could be because I am confused :) See also my other question about what is a roclet: #1086.

@hadley
Copy link
Member

hadley commented May 1, 2020

You could use inline R code.

@hadley hadley closed this as completed May 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants