You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sure! I don't really have any code to share as I barely scratched the surface. However, I can share some insights.
I think the grammar should work similarly to JSDoc. This way, the leading part until #' gets omitted and we are left with repeated @tag <arguments> structure.
The grammar needs to take into account that tag arguments can span multiple lines.
Implicit title and description (and details?) seemed to be tricky to handle. I would start with handling explicit tags, and eventually go back to handling those as a special case.
There are a few different tag categories that I would distinguish: no arguments (e.g., @noRd, @export), one argument (e.g., @import, @inheritParams), and multiple arguments (e.g., @param, @importFrom).
Perhaps it would be pragmatic to start with just no arguments and some arguments.
Eventually some of the tags could have more detailed grammar. For example: @importFrom could distinguish the package name and functions; @param could have multiple variants for "x" and "x,y", and the description could have markdown injected.
I remember I was exploring how roxygen2 parses things and I have a vague memory of shenanigans around "invalid" things like #' @noRd something. I am not sure if the tree-sitter grammar should concern itself with it in any way, though. I guess the bottom line is: how many edge cases which roxygen2 lets slip the grammar should reflect?
Overall, I would imagine the grammar to be a number of repeated tag nodes where each node either has no arguments or some arguments—this way, I think, we would end up with node starting with @someTag and ending just before (or a line before) the next @otherTag.
Activity
TymekDev commentedon Jun 13, 2025
Sure! I don't really have any code to share as I barely scratched the surface. However, I can share some insights.
#'gets omitted and we are left with repeated@tag <arguments>structure.@noRd,@export), one argument (e.g.,@import,@inheritParams), and multiple arguments (e.g.,@param,@importFrom).@importFromcould distinguish the package name and functions;@paramcould have multiple variants for "x" and "x,y", and the description could have markdown injected.#' @noRd something. I am not sure if the tree-sitter grammar should concern itself with it in any way, though. I guess the bottom line is: how many edge cases which roxygen2 lets slip the grammar should reflect?Overall, I would imagine the grammar to be a number of repeated tag nodes where each node either has no arguments or some arguments—this way, I think, we would end up with node starting with
@someTagand ending just before (or a line before) the next@otherTag.