Skip to content

Commit

Permalink
List renderers without active device & dynamic doc
Browse files Browse the repository at this point in the history
  • Loading branch information
nx10 committed Mar 1, 2022
1 parent befb427 commit f344f00
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 27 deletions.
4 changes: 2 additions & 2 deletions R/cpp11.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ httpgd_info_ <- function(devnum) {
.Call(`_httpgd_httpgd_info_`, devnum)
}

httpgd_renderers_ <- function(devnum) {
.Call(`_httpgd_httpgd_renderers_`, devnum)
httpgd_renderers_ <- function() {
.Call(`_httpgd_httpgd_renderers_`)
}

httpgd_random_token_ <- function(len) {
Expand Down
8 changes: 2 additions & 6 deletions R/httpgd.R
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,8 @@ hgd_info <- function(which = dev.cur()) {
#'
#' dev.off()
#' }
hgd_renderers <- function(which = dev.cur()) {
if (names(which) != "httpgd") {
stop("Device is not of type httpgd. (Start a device by calling: `hgd()`)")
} else {
return(httpgd_renderers_(which))
}
hgd_renderers <- function() {
httpgd_renderers_()
}

#' Query httpgd plot IDs
Expand Down
2 changes: 1 addition & 1 deletion man/hgd_renderers.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/Httpgd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,8 @@ cpp11::list httpgd_info_(int devnum)
}

[[cpp11::register]]
cpp11::data_frame httpgd_renderers_(int devnum)
cpp11::data_frame httpgd_renderers_()
{

using namespace cpp11::literals;

const auto &renderers = httpgd::RendererManager::defaults();
Expand Down
8 changes: 4 additions & 4 deletions src/cpp11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ extern "C" SEXP _httpgd_httpgd_info_(SEXP devnum) {
END_CPP11
}
// Httpgd.cpp
cpp11::data_frame httpgd_renderers_(int devnum);
extern "C" SEXP _httpgd_httpgd_renderers_(SEXP devnum) {
cpp11::data_frame httpgd_renderers_();
extern "C" SEXP _httpgd_httpgd_renderers_() {
BEGIN_CPP11
return cpp11::as_sexp(httpgd_renderers_(cpp11::as_cpp<cpp11::decay_t<int>>(devnum)));
return cpp11::as_sexp(httpgd_renderers_());
END_CPP11
}
// Httpgd.cpp
Expand Down Expand Up @@ -136,7 +136,7 @@ static const R_CallMethodDef CallEntries[] = {
{"_httpgd_httpgd_remove_id_", (DL_FUNC) &_httpgd_httpgd_remove_id_, 2},
{"_httpgd_httpgd_renderer_is_raw_", (DL_FUNC) &_httpgd_httpgd_renderer_is_raw_, 1},
{"_httpgd_httpgd_renderer_is_str_", (DL_FUNC) &_httpgd_httpgd_renderer_is_str_, 1},
{"_httpgd_httpgd_renderers_", (DL_FUNC) &_httpgd_httpgd_renderers_, 1},
{"_httpgd_httpgd_renderers_", (DL_FUNC) &_httpgd_httpgd_renderers_, 0},
{"_httpgd_httpgd_state_", (DL_FUNC) &_httpgd_httpgd_state_, 1},
{NULL, NULL, 0}
};
Expand Down
22 changes: 10 additions & 12 deletions vignettes/c01_httpgd-api.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,16 @@ httpgd includes multiple renderers that can dynamically render plots to differen

The following is a complete list of renderers.

| ID | Mime-Type | Renderer | Format | Depends |
| --------- | ------------------------ | -------------------------------------------------------- | ------ | ------- |
| `svg` | `image/svg+xml` | Scalable Vector Graphics (SVG). | string | |
| `svgp` | `image/svg+xml` | Version of the SVG renderer that produces portable SVGs. | string | |
| `json` | `application/json` | Plot data serialized to JSON format. | string | |
| `png` | `image/png` | Portable Network Graphics (PNG). | binary | Cairo |
| `pdf` | `application/pdf` | Adobe Portable Document Format (PDF). | binary | Cairo |
| `ps` | `application/postscript` | PostScript (PS). | string | Cairo |
| `eps` | `application/postscript` | Encapsulated PostScript (EPS). | string | Cairo |
| `tikz` | `text/plain` | LaTeX TikZ code. | string | |
| `strings` | `text/plain` | List of plot strings. | string | |
| `meta` | `application/json` | Plot meta information. | string | |
```{r echo=FALSE}
df <- httpgd::hgd_renderers()
df <- df[order(df$id),]
knitr::kable(data.frame(
sprintf("`%s`", df$id),
sprintf("`%s`", df$mime),
df$descr,
ifelse(df$bin, "Binary", "Text")
), col.names = c("ID", "Mime-Type", "Renderer", "Format"))
```


### From R
Expand Down

0 comments on commit f344f00

Please sign in to comment.