@@ -80,13 +80,65 @@ awk '
8080' NAMESPACE > NAMESPACE.tmp
8181mv NAMESPACE.tmp NAMESPACE
8282
83+ # Rust-only topics: not exported and not documented on the CRAN tier.
84+ # This list drives both the Rd removal and the \link{} rewrite below, so the
85+ # two cannot drift apart. It is every export(zarrs_*) in NAMESPACE except
86+ # zarrs_compiled_features, which survives as the stub above.
87+ ZARRS_ONLY_TOPICS=" zarrs_close_store zarrs_create_array zarrs_get_key
88+ zarrs_get_subset zarrs_node_exists zarrs_open_array_metadata
89+ zarrs_runtime_info zarrs_set_codec_concurrent_target
90+ zarrs_set_http_batch_range_requests zarrs_set_nthreads zarrs_set_subset"
91+
8392# Remove Rd pages for Rust-only functions.
84- rm -f man/zarrs_close_store.Rd man/zarrs_create_array.Rd \
85- man/zarrs_get_subset.Rd man/zarrs_node_exists.Rd \
86- man/zarrs_open_array_metadata.Rd man/zarrs_runtime_info.Rd \
87- man/zarrs_set_codec_concurrent_target.Rd \
88- man/zarrs_set_http_batch_range_requests.Rd \
89- man/zarrs_set_nthreads.Rd man/zarrs_set_subset.Rd
93+ for topic in $ZARRS_ONLY_TOPICS ; do
94+ rm -f " man/${topic} .Rd"
95+ done
96+
97+ # Surviving Rd pages still \link{} to the topics just removed, which fails
98+ # "checking Rd cross-references" with a missing-link WARNING. Unwrap those
99+ # links to their display text, leaving any surrounding \code{} intact:
100+ # \code{\link[=zarrs_get_subset]{zarrs_get_subset()}} -> \code{zarrs_get_subset()}
101+ # Match \link[=topic]{...} for any dropped topic, for the skip test below.
102+ DROPPED_LINK_RE=" $( echo $ZARRS_ONLY_TOPICS | tr " " " |" ) "
103+ DROPPED_LINK_RE=" \\ link\[=($DROPPED_LINK_RE )\]"
104+
105+ for rd in man/* .Rd; do
106+ [ -f " $rd " ] || continue
107+ # Skip files with no link to a dropped topic: most of man/ is untouched.
108+ grep -Eq " $DROPPED_LINK_RE " " $rd " || continue
109+ awk -v topics=" $ZARRS_ONLY_TOPICS " '
110+ BEGIN {
111+ n = split(topics, t, /[ \t\n]+/)
112+ for (i = 1; i <= n; i++) if (t[i] != "") drop[t[i]] = 1
113+ }
114+ {
115+ line = $0; out = ""
116+ while ((i = index(line, "\\link")) > 0) {
117+ out = out substr(line, 1, i - 1)
118+ rest = substr(line, i + 5)
119+ if (substr(rest, 1, 2) == "[=") {
120+ j = index(rest, "]{")
121+ if (j == 0) { out = out "\\link"; line = rest; continue }
122+ topic = substr(rest, 3, j - 3)
123+ rest = substr(rest, j + 2)
124+ } else if (substr(rest, 1, 1) == "{") {
125+ topic = ""
126+ rest = substr(rest, 2)
127+ } else {
128+ out = out "\\link"; line = rest; continue
129+ }
130+ k = index(rest, "}")
131+ if (k == 0) { out = out "\\link"; line = rest; continue }
132+ text = substr(rest, 1, k - 1)
133+ if (topic == "") topic = text
134+ out = out ((topic in drop) ? text : "\\link[=" topic "]{" text "}")
135+ line = substr(rest, k + 1)
136+ }
137+ print out line
138+ }
139+ ' " $rd " > " $rd .tmp"
140+ mv " $rd .tmp" " $rd "
141+ done
90142
91143# Include vignettes in the shipped tarball. They are .Rbuildignored on
92144# the r-universe tier, so strip that line for the CRAN tier.
0 commit comments