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

Syntax highlighting support for Rd's defining replacement methods? #2616

Closed
SebKrantz opened this issue Jun 1, 2024 · 8 comments
Closed

Comments

@SebKrantz
Copy link

The following documentation page doesn't render well: https://sebkrantz.github.io/collapse/reference/indexing.html
Souce: https://github.com/SebKrantz/collapse/blob/master/man/indexing.Rd

@hadley
Copy link
Member

hadley commented Jun 1, 2024

Same underlying problem as #2303

@hadley hadley closed this as completed Jun 1, 2024
@SebKrantz
Copy link
Author

What gets sent into downlit::highlight, which returns NA (invalid R code), in case it is useful. Seems to have nothing to do with > or <.

cat(ind$indexing.Rd$usage$contents)
## Create an 'indexed_frame' containing 'indexed_series'
findex_by(.X, ..., single = "auto", interact.ids = TRUE)
iby(.X, ..., single = "auto", interact.ids = TRUE)  # Shorthand

## Retrieve the index ('index_df') from an 'indexed_frame' or 'indexed_series'
findex(x)
ix(x)     # Shorthand

## Remove index from 'indexed_frame' or 'indexed_series' (i.e. get .X back)
unindex(x)

## Reindex 'indexed_frame' or 'indexed_series' (or index vectors / matrices)
reindex(x, index = findex(x), single = "auto")

## Check if 'indexed_frame', 'indexed_series', index or time vector is irregular
is_irregular(x, any_id = TRUE)

## Convert 'indexed_frame'/'indexed_series' to normal 'pdata.frame'/'pseries'
to_plm(x, row.names = FALSE)

# Subsetting & replacement methods: [(<-) methods call NextMethod().
# Also methods for fsubset, funique and roworder(v), na_omit (internal).

# S3 method for class 'indexed_series'
[(x, i, ..., drop.index.levels = "id")

# S3 method for class 'indexed_frame'
[(x, i, ..., drop.index.levels = "id")

# S3 method for class 'indexed_frame'
[(x, i, j) <- value

# S3 method for class 'indexed_frame'
$(x, name)

# S3 method for class 'indexed_frame'
$(x, name) <- value

# S3 method for class 'indexed_frame'
[[(x, i, ...)

# S3 method for class 'indexed_frame'
[[(x, i) <- value

# Index subsetting and printing: optimized using ss()

# S3 method for class 'index_df'
[(x, i, j, drop = FALSE, drop.index.levels = "id")

# S3 method for class 'index_df'
print(x, topn = 5, ...)

@hadley
Copy link
Member

hadley commented Jun 1, 2024

The problem is that [(x, i, ..., drop.index.levels = "id") is not valid R code.

@SebKrantz
Copy link
Author

Yup, generated from \method{[}{indexed_series}(x, i, \dots, drop.index.levels = "id")...

@SebKrantz
Copy link
Author

I've solved this in my fork as follows:

https://github.com/SebKrantz/pkgdown/blob/fb5aace6ffb31acc934b8447c190e96e849c66c8/R/highlight.R#L3C1-L11C1

Probably not the way you'd go about it but works for me.

@hadley
Copy link
Member

hadley commented Jun 3, 2024

@SebKrantz #2621 should at least avoid the need for that hack. I'm still hoping that I can figure out how to generate the standard usage though.

@hadley
Copy link
Member

hadley commented Jun 3, 2024

And in #2622 it now works the way I would hope 😄

Screenshot 2024-06-03 at 10 42 34

@SebKrantz
Copy link
Author

Thanks, much appreciated!

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