xref: /Universal-ctags/man/ctags-lang-r.7.rst.in (revision 03889d61aba38f72e8dbd86eadb6ffecf111a987)
1.. _ctags-lang-r(7):
2
3==============================================================
4ctags-lang-r
5==============================================================
6-------------------------------------------------------------------
7Random notes about tagging R source code with Universal Ctags
8-------------------------------------------------------------------
9:Version: @VERSION@
10:Manual group: Universal Ctags
11:Manual section: 7
12
13SYNOPSIS
14--------
15|	**@CTAGS_NAME_EXECUTABLE@** ... --languages=+R ...
16|	**@CTAGS_NAME_EXECUTABLE@** ... --language-force=R ...
17|	**@CTAGS_NAME_EXECUTABLE@** ... --map-R=+.r ...
18
19DESCRIPTION
20-----------
21This man page gathers random notes about tagging R source code
22with Universal Ctags.
23
24Kinds
25-----------
26If a variable gets a value returned from a *well-known constructor*
27and the variable appears for the first time in the current input file,
28the R parser makes a tag for the variable and attaches a kind
29associated with the constructor to the tag regardless of whether
30the variable appears in the top-level context or a function.
31
32Well-known constructor and kind mapping
33
34	============  ==================
35	Constructor   kind
36	============  ==================
37	function()    function
38	c()           vector
39	list()        list
40	data.frame()  dataframe
41	============  ==================
42
43If a variable doesn't get a value returned from one of well-known
44constructors, the R parser attaches ``globalVar`` or ``functionVar`` kind
45to the tag for the variable depending on the context.
46
47Here is an example demonstrating the usage of the kinds:
48
49"input.r"
50
51.. code-block:: R
52
53	G <- 1
54	v <- c(1, 2)
55	l <- list(3, 4)
56	d <- data.frame(n = v)
57	f <- function(a) {
58		g <- function (b) a + b
59		w <- c(1, 2)
60		m <- list (3, 4)
61		e <- data.frame(n = w)
62		L <- 2
63	}
64
65"output.tags"
66with "--options=NONE --sort=no --fields=+KZ -o - input.r"
67
68.. code-block:: tags
69
70	G	input.r	/^G <- 1$/;"	globalVar
71	v	input.r	/^v <- c(1, 2)$/;"	vector
72	l	input.r	/^l <- list(3, 4)$/;"	list
73	d	input.r	/^d <- data.frame(n = v)$/;"	dataframe
74	n	input.r	/^d <- data.frame(n = v)$/;"	nameattr	scope:dataframe:d
75	f	input.r	/^f <- function(a) {$/;"	function
76	g	input.r	/^	g <- function (b) a + b$/;"	function	scope:function:f
77	w	input.r	/^	w <- c(1, 2)$/;"	vector	scope:function:f
78	m	input.r	/^	m <- list (3, 4)$/;"	list	scope:function:f
79	e	input.r	/^	e <- data.frame(n = w)$/;"	dataframe	scope:function:f
80	n	input.r	/^	e <- data.frame(n = w)$/;"	nameattr	scope:dataframe:f.e
81	L	input.r	/^	L <- 2$/;"	functionVar	scope:function:f
82
83.. TODO:
84
85   - other kinds
86   - operators for assignment, <-, <<-, ->>, ->, =
87   - illuminating duplicated tags
88   - fields (constructor, assignmentop)
89   - sub parsers
90
91SEE ALSO
92--------
93ctags(1)
94