Skip to content

Commit ac1c493

Browse files
committed
correct @return parsing
1 parent 598b4ef commit ac1c493

31 files changed

+115
-64
lines changed

R/register.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#' Generates wrappers for registered C++ functions
1+
#' @title Generates wrappers for registered C++ functions
22
#'
3-
#' Functions decorated with `[[cpp4r::register]]` in files ending in `.cc`,
3+
#' @description Functions decorated with `[[cpp4r::register]]` in files ending in `.cc`,
44
#' `.cpp`, `.h` or `.hpp` will be wrapped in generated code and registered to
55
#' be called from R.
66
#'
@@ -9,7 +9,8 @@
99
#'
1010
#' In order to use `register()` the `cli`, `decor`, `desc`, `glue`,
1111
#' `tibble` and `vctrs` packages must also be installed.
12-
#' @param path The path to the package root directory. The default is \code{NULL},
12+
#'
13+
#' @param path The path to the package root directory. The default is `NULL`,
1314
#' @param quiet If `TRUE` suppresses output from this function
1415
#' @param extension The file extension to use for the generated src/cpp4r file.
1516
#' `.cpp` by default, but `.cc` is also supported.

R/template.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# The function itself just echos its inputs and outputs to a file called INDEX,
22
# which is then opened by RStudio when the new project is opened.
3-
#' Start a new project with the cpp4r package template
3+
4+
#' @title Start a new project with the cpp4r package template
5+
#'
6+
#' @description This function copies a package template into a new directory.
7+
#' The template includes a DESCRIPTION file, a minimal R/ directory and placeholders
8+
#' with instructions. You can then edit these files to customize your new package.
9+
#'
410
#' @param path Path to the new project
511
#' @param pkgname Name of the new package
612
#' @return The file path to the copied template (invisibly).

R/unvendor.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#' This function removes the vendored cpp4r headers from your package by
44
#' automatically finding the vendored headers.
55
#'
6-
#' @param path The directory with the vendored headers. It is recommended to use \code{"./src/vendor"}.
7-
#' The default is \code{NULL}.
6+
#' @param path The directory with the vendored headers. It is recommended to use `"./src/vendor"`.
7+
#' The default is `NULL`.
88
#' @return The path to the unvendored code (invisibly).
99
#' @export
1010
#' @examples

R/vendor.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#' Vendor the cpp4r headers
1+
#' @title Vendor the cpp4r headers
22
#'
3-
#' Vendoring is the act of making your own copy of the 3rd party packages your
3+
#' @description Vendoring is the act of making your own copy of the 3rd party packages your
44
#' project is using. It is often used in the go language community.
55
#'
66
#' This function vendors cpp4r into your package by copying the cpp4r

docs/content.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,3 +437,18 @@ mjx-container[jax="SVG"]:not([display="true"]) {
437437
margin: 0;
438438
color: #dc3545;
439439
}
440+
441+
/* References section styling */
442+
#refs.references {
443+
margin-bottom: 2em;
444+
}
445+
446+
#refs.references .csl-entry {
447+
margin-bottom: 1em;
448+
padding-bottom: 0.5em;
449+
}
450+
451+
/* Add extra spacing for the last reference entry */
452+
#refs.references .csl-entry:last-child {
453+
margin-bottom: 1.5em;
454+
}

docs/index.html

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,22 @@
7373
<div id="content">
7474
<div class="content-wrapper">
7575
<div class="content-main">
76-
<p># cpp4r</p>
7776

78-
<p><a href="https://lifecycle.r-lib.org/articles/stages.html#stable"><img src="https://img.shields.io/badge/lifecycle-stable-brightgreen.svg" alt="Lifecycle:
77+
<!-- README.md is generated from README.Rmd. Please edit that file -->
78+
79+
<h1>cpp4r</h1>
80+
81+
<!-- badges: start -->
82+
83+
<a href="https://lifecycle.r-lib.org/articles/stages.html#stable"><img src="https://img.shields.io/badge/lifecycle-stable-brightgreen.svg" alt="Lifecycle:
7984
stable"></a>
8085
<a href="https://github.com/pachadotdev/cpp4r/actions/workflows/R-CMD-check.yaml"><img src="https://github.com/pachadotdev/cpp4r/actions/workflows/R-CMD-check.yaml/badge.svg" alt="R-CMD-check"></a>
8186
<a href="https://CRAN.R-project.org/package=cpp4r"><img src="https://www.r-pkg.org/badges/version/cpp4r" alt="CRAN
8287
status"></a>
8388
<a href="https://github.com/pachadotdev/cpp4r/actions/workflows/test-coverage.yaml"><img src="https://raw.githubusercontent.com/pachadotdev/cpp4r/coverage/badges/coverage.svg" alt="Test
8489
coverage"></a>
8590
<a href="https://buymeacoffee.com/pacha"><img src="https://raw.githubusercontent.com/pachadotdev/buymeacoffee-badges/main/bmc-yellow.svg" alt="BuyMeACoffee"></a>
86-
<!-- badges: end --></p>
91+
<!-- badges: end -->
8792

8893
<p>cpp4r helps you to interact with R objects using C++ code. It is a fork
8994
of the <a href="https://cran.r-project.org/package=cpp11">cpp11</a> package with
@@ -109,13 +114,12 @@
109114
<li><input type="checkbox" checked disabled> Support bidirectional passing of complex numbers/vectors.</li>
110115
<li><input type="checkbox" checked disabled> Provide flexibility with data types (e.g., cpp4r’s <code>as_integers()</code> and <code>as_doubles()</code> accept logical inputs while cpp11’s do not).</li>
111116
<li><input type="checkbox" checked disabled> Some internal optimizations for better speed (e.g., <a href="https://github.com/r-lib/cpp11/pull/463">https://github.com/r-lib/cpp11/pull/463</a> and <a href="https://github.com/r-lib/cpp11/pull/430">https://github.com/r-lib/cpp11/pull/430</a>).</li>
112-
</ul>
113-
## Getting started
117+
</ul><h2>Getting started</h2>
114118

115119
<p>Check the <a href="https://cpp4r.org/">documentation</a> to get started using cpp4r
116120
in your scripts, particularly if you are new to C++ programming.</p>
117121

118-
<p>## Using cpp4r in a package</p>
122+
<h2>Using cpp4r in a package</h2>
119123

120124
<p>Create a new package with <code>cpp4r::pkg_template("~/path/to/mypkg")</code> and
121125
then edit the generated files.</p>
@@ -138,7 +142,7 @@
138142
use a shared library. It is straightforward and reliable to use in
139143
packages without fear of compile-time and run-time mismatches.</p>
140144

141-
<p>## Vendoring</p>
145+
<h2>Vendoring</h2>
142146

143147
<p>You can <a href="https://cpp4r.org/articles/01-motivations.html">vendor</a> the
144148
current installed version of cpp4r headers into your package with
@@ -154,24 +158,24 @@
154158
that you will not get bug fixes and new features unless you update the
155159
vendored headers.</p>
156160

157-
<p>## Getting help</p>
161+
<h2>Getting help</h2>
158162

159163
<p>Please open an issue or email me. I will do my best to respond before 48
160164
hours.</p>
161165

162-
<p>## Contributing</p>
166+
<h2>Contributing</h2>
163167

164168
<p>Contributions are welcome! Please see the <a href="https://cpp4r.org/articles/15-internals.html">internals
165169
vignette</a> for details
166170
about design choices and coding style.</p>
167171

168-
<p>## Code of Conduct</p>
172+
<h2>Code of Conduct</h2>
169173

170174
<p>Please note that the cpp4r project is released with a <a href="https://cpp4r.org/CODE_OF_CONDUCT.html">Contributor Code
171175
of Conduct</a>. By contributing to
172176
this project, you agree to abide by its terms.</p>
173177
</div>
174-
<footer><p>Last updated: 2025-10-12 19:45:53</p>
178+
<footer><p>Last updated: 2025-10-12 22:30:17</p>
175179
</footer><script>
176180
document.addEventListener('DOMContentLoaded', function() {
177181
// Theme toggle functionality

docs/news/index.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,21 @@
7474
<div class="content-wrapper">
7575
<div class="content-main">
7676
<h1>Changelog</h1>
77-
<p># cpp4r 0.3.0</p>
77+
<h1>cpp4r 0.3.0</h1>
7878

7979
<ul><li>Added <code>as_logicals()</code> and <code>as_strings()</code> in the same style of <code>as_doubles()</code> and <code>as_integers()</code></li>
8080
<li>Improved memory management for <code>r_vector</code> iterators</li>
8181
<li>Slightly faster than <code>cpp11</code></li>
8282
<li><code>vendor()</code> and <code>unvendor()</code> use <code>path = NULL</code> as default to adhere to CRAN policies.</li>
83-
</ul>
84-
# cpp4r 0.2.0
83+
</ul><h1>cpp4r 0.2.0</h1>
8584

8685
<ul><li>Reduced dependencies on R side</li>
8786
<li>The vignettes are rendered only for the package site to keep the CRAN build minimal</li>
88-
</ul>
89-
# cpp4r 0.1.0
87+
</ul><h1>cpp4r 0.1.0</h1>
9088

9189
<ul><li>Initial release</li>
9290
</ul></div>
93-
<footer><p>Last updated: 2025-10-12 19:46:01</p>
91+
<footer><p>Last updated: 2025-10-12 22:30:25</p>
9492
</footer><script>
9593
document.addEventListener('DOMContentLoaded', function() {
9694
// Theme toggle functionality

docs/reference/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ <h1>Function Reference</h1>
7878
<li><a href="pkg_template.html">pkg_template</a></li>
7979
<li><a href="unvendor.html">unvendor</a></li>
8080
<li><a href="vendor.html">vendor</a></li></ul></div>
81-
<footer><p>Last updated: 2025-10-12 19:45:53</p>
81+
<footer><p>Last updated: 2025-10-12 22:30:17</p>
8282
</footer><script>
8383
document.addEventListener('DOMContentLoaded', function() {
8484
// Theme toggle functionality

docs/reference/pkg_template.html

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,23 @@
7373
<div id="content">
7474
<div class="content-wrapper">
7575
<div class="content-main">
76-
<h1></h1>
76+
<h1>Start a new project with the cpp4r package template </h1>
77+
<h2>Description</h2>
78+
<p>The template includes a DESCRIPTION file, a minimal R/ directory and placeholders
79+
with instructions. You can then edit these files to customize your new package.</p>
7780
<h2>Arguments</h2>
78-
<table class="ref-arguments"><tbody><tr><td><strong>path</strong></td><td>Path to the new project</td></tr><tr><td><strong>pkgname</strong></td><td>Name of the new package</td></tr></tbody></table><h2>Examples</h2>
81+
<table class="ref-arguments"><tbody><tr><td><strong>path</strong></td><td>Path to the new project</td></tr><tr><td><strong>pkgname</strong></td><td>Name of the new package</td></tr></tbody></table><h2>Return</h2>
82+
<p>The file path to the copied template (invisibly).</p>
83+
<h2>Examples</h2>
7984
<div class="sourceCode"><pre><code># create a new directory
8085
dir &lt;- tempdir()
8186
dir.create(dir)</code></pre></div>
8287
<div class="output"><pre><code>## [1] FALSE</code></pre></div>
8388
<div class="sourceCode"><pre><code># copy the package template into the directory
8489
pkg_template(dir, "mynewpkg")</code></pre></div>
85-
<div class="output"><pre><code>## [1] "/tmp/RtmpD7okxS"</code></pre></div>
90+
<div class="output"><pre><code>## [1] "/tmp/RtmpXU10wP"</code></pre></div>
8691
</div>
87-
<footer><p>Last updated: 2025-10-12 19:45:53</p>
92+
<footer><p>Last updated: 2025-10-12 22:30:18</p>
8893
</footer><script>
8994
document.addEventListener('DOMContentLoaded', function() {
9095
// Theme toggle functionality

docs/reference/register.html

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,18 @@
7373
<div id="content">
7474
<div class="content-wrapper">
7575
<div class="content-main">
76-
<h1></h1>
76+
<h1>Generates wrappers for registered C++ functions </h1>
77+
<h2>Description</h2>
78+
<code>.cpp</code>, <code>.h</code> or <code>.hpp</code> will be wrapped in generated code and registered to
79+
be called from R.
80+
<p>Note registered functions will not be *exported* from your package unless
81+
you also add a <code>@export</code> roxygen2 directive for them.</p>
82+
<p>In order to use <code>register()</code> the <code>cli</code>, <code>decor</code>, <code>desc</code>, <code>glue</code>,
83+
<code>tibble</code> and <code>vctrs</code> packages must also be installed.</p>
7784
<h2>Arguments</h2>
78-
<table class="ref-arguments"><tbody><tr><td><strong>path</strong></td><td>The path to the package root directory. The default is \code{NULL},</td></tr><tr><td><strong>quiet</strong></td><td>If <code>TRUE</code> suppresses output from this function</td></tr><tr><td><strong>extension</strong></td><td>The file extension to use for the generated src/cpp4r file.</td></tr></tbody></table><h2>Examples</h2>
85+
<table class="ref-arguments"><tbody><tr><td><strong>path</strong></td><td>The path to the package root directory. The default is <code>NULL</code>,</td></tr><tr><td><strong>quiet</strong></td><td>If <code>TRUE</code> suppresses output from this function</td></tr><tr><td><strong>extension</strong></td><td>The file extension to use for the generated src/cpp4r file. <code>.cpp</code> by default, but <code>.cc</code> is also supported.</td></tr></tbody></table><h2>Return</h2>
86+
<p>The paths to the generated R and C++ source files (in that order).</p>
87+
<h2>Examples</h2>
7988
<div class="sourceCode"><pre><code># create a minimal package
8089
dir &lt;- tempfile()
8190
dir.create(dir)</code></pre></div>
@@ -87,8 +96,8 @@ <h2>Arguments</h2>
8796
writeLines("[[cpp4r::register]] int one() { return 1; }", file.path(dir, "src", "one.cpp"))</code></pre></div>
8897
<div class="sourceCode"><pre><code># register the functions in the package
8998
register(dir)</code></pre></div>
90-
<div class="output"><pre><code>## [1] "/tmp/RtmpD7okxS/file7aa8f1fd38b08/R/cpp4r.R"
91-
## [2] "/tmp/RtmpD7okxS/file7aa8f1fd38b08/src/cpp4r.cpp"</code></pre></div>
99+
<div class="output"><pre><code>## [1] "/tmp/RtmpXU10wP/file9555e5f74611a/R/cpp4r.R"
100+
## [2] "/tmp/RtmpXU10wP/file9555e5f74611a/src/cpp4r.cpp"</code></pre></div>
92101
<div class="sourceCode"><pre><code># Files generated by registration
93102
file.exists(file.path(dir, "R", "cpp4r.R"))
94103
file.exists(file.path(dir, "src", "cpp4r.cpp"))</code></pre></div>
@@ -97,7 +106,7 @@ <h2>Arguments</h2>
97106
unlink(dir, recursive = TRUE)</code></pre></div>
98107
<div class="output"><pre><code>## [1] 0</code></pre></div>
99108
</div>
100-
<footer><p>Last updated: 2025-10-12 19:45:53</p>
109+
<footer><p>Last updated: 2025-10-12 22:30:17</p>
101110
</footer><script>
102111
document.addEventListener('DOMContentLoaded', function() {
103112
// Theme toggle functionality

0 commit comments

Comments
 (0)