Skip to content

Commit 0472dae

Browse files
committed
use pkgsite with math rendering
1 parent 6913b0d commit 0472dae

37 files changed

+266
-466
lines changed

.github/workflows/test-coverage.yaml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,27 @@ jobs:
8282
run: |
8383
git config --local user.email "[email protected]"
8484
git config --local user.name "GitHub Action"
85+
86+
# Save the badge file before switching branches
87+
cp badges/coverage.svg /tmp/coverage.svg
88+
89+
# Create or switch to coverage branch
90+
git checkout -B coverage
91+
92+
# Remove everything except .git
93+
git rm -rf . || true
94+
95+
# Restore just the badge
96+
mkdir -p badges
97+
cp /tmp/coverage.svg badges/coverage.svg
8598
git add badges/coverage.svg
99+
86100
if ! git diff --staged --quiet; then
87-
# Amend the last commit to include the updated badge, preserving its message
88-
git commit --amend --no-edit
89-
# Safely update the remote with force-with-lease to avoid clobbering concurrent changes
90-
git push --force-with-lease origin main
101+
git commit -m "Update coverage badge"
102+
git push --force origin coverage
91103
else
92104
echo "No changes to commit"
93105
fi
106+
107+
# Switch back to main
108+
git checkout main

R/unvendor.R

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#' @export
1010
#' @examples
1111
#' # create a new directory
12-
#' dir <- tempfile()
13-
#' dir.create(dir)
12+
#' dir <- paste0(tempdir(), "/", gsub("\\s+|[[:punct:]]", "", Sys.time()))
13+
#' dir.create(dir, recursive = TRUE)
1414
#'
1515
#' # vendor the cpp4r headers into the directory
1616
#' vendor(dir)
@@ -22,22 +22,24 @@
2222
#' unlink(dir, recursive = TRUE)
2323
unvendor <- function(path = NULL) {
2424
stopifnot(!is.null(path), dir.exists(path))
25-
25+
2626
# Check if the cpp4r directory exists
2727
cpp4r_dir <- file.path(path, "cpp4r")
2828
cpp4r_hpp_path <- file.path(path, "cpp4r.hpp")
2929
info_file_path <- file.path(path, "00-cpp4r-vendoring-info.txt")
30-
30+
3131
# Check if vendored files exist
3232
has_cpp4r_dir <- dir.exists(cpp4r_dir)
3333
has_cpp4r_hpp <- file.exists(cpp4r_hpp_path)
3434
has_info_file <- file.exists(info_file_path)
35-
35+
3636
if (!has_cpp4r_dir && !has_cpp4r_hpp && !has_info_file) {
37-
if (is_interactive()) { message("Could not find vendored headers") }
37+
if (is_interactive()) {
38+
message("Could not find vendored headers")
39+
}
3840
return(invisible(NULL))
3941
}
40-
42+
4143
# Remove the cpp4r directory if it exists
4244
if (has_cpp4r_dir) {
4345
unlink(cpp4r_dir, recursive = TRUE)
@@ -47,7 +49,7 @@ unvendor <- function(path = NULL) {
4749
if (has_cpp4r_hpp) {
4850
unlink(cpp4r_hpp_path)
4951
}
50-
52+
5153
# Remove the info file if it exists
5254
if (has_info_file) {
5355
unlink(info_file_path)

R/vendor.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#' # vendor the cpp4r headers into the directory
2424
#' vendor(dir)
2525
#'
26-
#' list.files(file.path(dir, "src", "vendor"))
26+
#' list.files(dir, recursive = TRUE)
2727
#'
2828
#' # cleanup
2929
#' unlink(dir, recursive = TRUE)

README.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ knitr::opts_chunk$set(
2121
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
2222
[![R-CMD-check](https://github.com/pachadotdev/cpp4r/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/pachadotdev/cpp4r/actions/workflows/R-CMD-check.yaml)
2323
[![CRAN status](https://www.r-pkg.org/badges/version/cpp4r)](https://CRAN.R-project.org/package=cpp4r)
24-
[![Test coverage](https://raw.githubusercontent.com/pachadotdev/cpp4r/main/badges/coverage.svg)](https://github.com/pachadotdev/cpp4r/actions/workflows/test-coverage.yaml)
24+
[![Test coverage](https://raw.githubusercontent.com/pachadotdev/cpp4r/coverage/badges/coverage.svg)](https://github.com/pachadotdev/cpp4r/actions/workflows/test-coverage.yaml)
2525
[![BuyMeACoffee](https://raw.githubusercontent.com/pachadotdev/buymeacoffee-badges/main/bmc-yellow.svg)](https://buymeacoffee.com/pacha)
2626
<!-- badges: end -->
2727

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://
1313
[![CRAN
1414
status](https://www.r-pkg.org/badges/version/cpp4r)](https://CRAN.R-project.org/package=cpp4r)
1515
[![Test
16-
coverage](https://raw.githubusercontent.com/pachadotdev/cpp4r/main/badges/coverage.svg)](https://github.com/pachadotdev/cpp4r/actions/workflows/test-coverage.yaml)
16+
coverage](https://raw.githubusercontent.com/pachadotdev/cpp4r/coverage/badges/coverage.svg)](https://github.com/pachadotdev/cpp4r/actions/workflows/test-coverage.yaml)
1717
[![BuyMeACoffee](https://raw.githubusercontent.com/pachadotdev/buymeacoffee-badges/main/bmc-yellow.svg)](https://buymeacoffee.com/pacha)
1818
<!-- badges: end -->
1919

docs/content.css

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,15 +360,21 @@ mjx-container[jax="SVG"][display="false"] {
360360
display: inline-block !important;
361361
vertical-align: baseline !important;
362362
margin: 0 0.1em;
363-
transform: translateY(-0.3em) !important;
363+
transform: translateY(-0.2em) !important;
364364
position: relative !important;
365365
}
366366

367367
/* Target the SVG elements directly for better alignment */
368368
mjx-container[jax="SVG"][display="false"] svg {
369369
vertical-align: baseline !important;
370370
position: relative !important;
371-
top: -0.1em !important;
371+
top: -0.2em !important;
372+
}
373+
374+
/* Alternative alignment approach if the above doesn't work well */
375+
mjx-container[jax="SVG"]:not([display="true"]) {
376+
vertical-align: middle !important;
377+
line-height: 1 !important;
372378
}
373379

374380
/* SVG elements should inherit text color for dark mode */
@@ -383,3 +389,43 @@ mjx-container[jax="SVG"][display="false"] svg {
383389
/* overflow-x: auto; */
384390
}
385391
}
392+
393+
/* Styling for executed R examples */
394+
.sourceCode {
395+
margin-bottom: 0.5em;
396+
}
397+
398+
.sourceCode pre {
399+
background-color: var(--code-bg);
400+
border: 1px solid var(--border-color);
401+
border-radius: 4px;
402+
padding: 0.8em;
403+
margin: 0;
404+
}
405+
406+
.output {
407+
margin-bottom: 1em;
408+
}
409+
410+
.output pre {
411+
background-color: rgba(0, 0, 0, 0.05);
412+
border: none;
413+
border-radius: 4px;
414+
padding: 0.8em;
415+
margin: 0;
416+
color: #666;
417+
}
418+
419+
[data-theme="dark"] .output pre {
420+
background-color: rgba(255, 255, 255, 0.05);
421+
color: #ccc;
422+
}
423+
424+
.error pre {
425+
background-color: rgba(220, 53, 69, 0.1);
426+
border: 1px solid rgba(220, 53, 69, 0.3);
427+
border-radius: 4px;
428+
padding: 0.8em;
429+
margin: 0;
430+
color: #dc3545;
431+
}

docs/index.html

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
processHtmlClass: 'tex2jax_process'
2323
}
2424
};
25-
</script><script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script><script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script></head><body>
25+
</script><script id="MathJax-script" async src="js/tex-svg.js"></script></head><body>
2626
<div class="main-container">
2727
<div id="menu">
2828
<div>
@@ -39,9 +39,8 @@ <h1>cpp4r Documentation</h1>
3939

4040
<div class="submenu">
4141
<label>Functions</label>
42-
<a href="reference/cpp4r-package.html">cpp4r-package</a>
43-
<a href="reference/pkg_template.html">pkg_template</a>
4442
<a href="reference/register.html">register</a>
43+
<a href="reference/pkg_template.html">pkg_template</a>
4544
<a href="reference/unvendor.html">unvendor</a>
4645
<a href="reference/vendor.html">vendor</a>
4746
</div>
@@ -75,7 +74,7 @@ <h1>cpp4r Documentation</h1>
7574
<div id="content">
7675
<div class="content-wrapper">
7776
<div class="content-main">
78-
<h1>cpp4r</h1>
77+
<p># cpp4r</p>
7978

8079
<p><img src="man/figures/logo.svg" height="139" alt=""></p>
8180

@@ -84,7 +83,7 @@ <h1>cpp4r</h1>
8483
<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>
8584
<a href="https://CRAN.R-project.org/package=cpp4r"><img src="https://www.r-pkg.org/badges/version/cpp4r" alt="CRAN
8685
status"></a>
87-
<a href="https://github.com/pachadotdev/cpp4r/actions/workflows/test-coverage.yaml"><img src="https://raw.githubusercontent.com/pachadotdev/cpp4r/main/badges/coverage.svg" alt="Test
86+
<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
8887
coverage"></a>
8988
<a href="https://buymeacoffee.com/pacha"><img src="https://raw.githubusercontent.com/pachadotdev/buymeacoffee-badges/main/bmc-yellow.svg" alt="BuyMeACoffee"></a>
9089
<!-- badges: end --></p>
@@ -113,12 +112,13 @@ <h1>cpp4r</h1>
113112
<li><input type="checkbox" checked disabled> Support bidirectional passing of complex numbers/vectors.</li>
114113
<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>
115114
<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>
116-
</ul><h2>Getting started</h2>
115+
</ul>
116+
## Getting started
117117

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

121-
<h2>Using cpp4r in a package</h2>
121+
<p>## Using cpp4r in a package</p>
122122

123123
<p>Create a new package with <code>cpp4r::pkg_template("~/path/to/mypkg")</code> and
124124
then edit the generated files.</p>
@@ -132,8 +132,7 @@ <h2>Using cpp4r in a package</h2>
132132

133133
<pre><code>#' @useDynLib mypkg, .registration = TRUE
134134
#' @keywords internal
135-
"_PACKAGE"
136-
</code></pre>
135+
"_PACKAGE"</code></pre>
137136

138137
<p>Then decorate C++ functions you want to expose to R with
139138
<code>[[cpp4r::register]]</code>.</p>
@@ -142,7 +141,7 @@ <h2>Using cpp4r in a package</h2>
142141
use a shared library. It is straightforward and reliable to use in
143142
packages without fear of compile-time and run-time mismatches.</p>
144143

145-
<h2>Vendoring</h2>
144+
<p>## Vendoring</p>
146145

147146
<p>You can <a href="https://cpp4r.org/articles/01-motivations.html">vendor</a> the
148147
current installed version of cpp4r headers into your package with
@@ -158,24 +157,24 @@ <h2>Vendoring</h2>
158157
that you will not get bug fixes and new features unless you update the
159158
vendored headers.</p>
160159

161-
<h2>Getting help</h2>
160+
<p>## Getting help</p>
162161

163162
<p>Please open an issue or email me. I will do my best to respond before 48
164163
hours.</p>
165164

166-
<h2>Contributing</h2>
165+
<p>## Contributing</p>
167166

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

172-
<h2>Code of Conduct</h2>
171+
<p>## Code of Conduct</p>
173172

174173
<p>Please note that the cpp4r project is released with a <a href="https://cpp4r.org/CODE_OF_CONDUCT.html">Contributor Code
175174
of Conduct</a>. By contributing to
176175
this project, you agree to abide by its terms.</p>
177176
</div>
178-
<footer><p>Last updated: 2025-10-12 11:32:38</p>
177+
<footer><p>Last updated: 2025-10-12 17:59:33</p>
179178
</footer><script>
180179
document.addEventListener('DOMContentLoaded', function() {
181180
// Theme toggle functionality

docs/js/tex-svg.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/news/index.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
processHtmlClass: 'tex2jax_process'
2323
}
2424
};
25-
</script><script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script><script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script></head><body>
25+
</script><script id="MathJax-script" async src="../js/tex-svg.js"></script></head><body>
2626
<div class="main-container">
2727
<div id="menu">
2828
<div>
@@ -39,9 +39,8 @@ <h1>cpp4r Documentation</h1>
3939

4040
<div class="submenu">
4141
<label>Functions</label>
42-
<a href="../reference/cpp4r-package.html">cpp4r-package</a>
43-
<a href="../reference/pkg_template.html">pkg_template</a>
4442
<a href="../reference/register.html">register</a>
43+
<a href="../reference/pkg_template.html">pkg_template</a>
4544
<a href="../reference/unvendor.html">unvendor</a>
4645
<a href="../reference/vendor.html">vendor</a>
4746
</div>
@@ -76,21 +75,23 @@ <h1>cpp4r Documentation</h1>
7675
<div class="content-wrapper">
7776
<div class="content-main">
7877
<h1>Changelog</h1>
79-
<h1>cpp4r 0.3.0</h1>
78+
<p># cpp4r 0.3.0</p>
8079

8180
<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>
8281
<li>Improved memory management for <code>r_vector</code> iterators</li>
8382
<li>Slightly faster than <code>cpp11</code></li>
8483
<li><code>vendor()</code> and <code>unvendor()</code> use <code>path = NULL</code> as default to adhere to CRAN policies.</li>
85-
</ul><h1>cpp4r 0.2.0</h1>
84+
</ul>
85+
# cpp4r 0.2.0
8686

8787
<ul><li>Reduced dependencies on R side</li>
8888
<li>The vignettes are rendered only for the package site to keep the CRAN build minimal</li>
89-
</ul><h1>cpp4r 0.1.0</h1>
89+
</ul>
90+
# cpp4r 0.1.0
9091

9192
<ul><li>Initial release</li>
9293
</ul></div>
93-
<footer><p>Last updated: 2025-10-12 11:32:44</p>
94+
<footer><p>Last updated: 2025-10-12 17:59:40</p>
9495
</footer><script>
9596
document.addEventListener('DOMContentLoaded', function() {
9697
// Theme toggle functionality

0 commit comments

Comments
 (0)