File: RspConstruct.R

package info (click to toggle)
r-cran-r.rsp 0.46.0%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,472 kB
  • sloc: javascript: 612; tcl: 304; sh: 18; makefile: 16
file content (172 lines) | stat: -rw-r--r-- 3,669 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
###########################################################################/**
# @RdocClass RspConstruct
#
# @title "The RspConstruct class"
#
# \description{
#  @classhierarchy
#
#  An RspConstruct object represents an RSP construct, which can either be
#  (i) an RSP text (a plain text section), (ii) an RSP comment,
#  (iii) an RSP preprocessing directive, or (iv) an RSP expression.
# }
#
# @synopsis
#
# \arguments{
#   \item{object}{A R object.}
#   \item{...}{Arguments passed to @see "RspObject".}
#   \item{comment}{An optional @character string.}
# }
#
# \section{Fields and Methods}{
#  @allmethods
# }
#
# @author
#
# @keyword internal
#*/###########################################################################
setConstructorS3("RspConstruct", function(object=character(), ..., comment=NULL) {
  this <- extend(RspObject(object, ...), "RspConstruct")
  attr(this, "#comment") <- comment
  this
})


#########################################################################/**
# @RdocMethod getInclude
# @alias getInclude.RspText
# @alias getInclude.RspCodeChunk
# @alias getInclude.RspVariableDirective
#
# @title "Checks whether an RSP construct will include text to the output or not"
#
# \description{
#  @get "title".
# }
#
# @synopsis
#
# \arguments{
#   \item{...}{Not used.}
# }
#
# \value{
#  Returns @TRUE of @FALSE.
# }
#
# @author
#
# \seealso{
#   @seeclass
# }
#*/#########################################################################
setMethodS3("getInclude", "RspConstruct", function(object, ...) {
  FALSE
})



#########################################################################/**
# @RdocMethod getComment
#
# @title "Gets the comment of an RSP construct"
#
# \description{
#  @get "title".
# }
#
# @synopsis
#
# \arguments{
#   \item{...}{Not used.}
# }
#
# \value{
#  Returns a @character string.
# }
#
# @author
#
# \seealso{
#   @seeclass
# }
#*/#########################################################################
setMethodS3("getComment", "RspConstruct", function(object, ...) {
  getAttribute(object, "#comment")
})


#########################################################################/**
# @RdocMethod getSuffixSpecs
#
# @title "Gets the suffix specifications"
#
# \description{
#  @get "title".
# }
#
# @synopsis
#
# \arguments{
#   \item{...}{Not used.}
# }
#
# \value{
#  Returns a trimmed @character string.
# }
#
# @author
#
# \seealso{
#   @seeclass
# }
#*/#########################################################################
setMethodS3("getSuffixSpecs", "RspConstruct", function(object, ...) {
  specs <- attr(object, "suffixSpecs")
  if (is.null(specs)) return(NULL)
  specs <- trim(specs)
##  specs <- gsub("^\\[[ \t\v]*", "", specs)
##  specs <- gsub("[ \t\v]*\\]$", "", specs)
  specs
})



#########################################################################/**
# @RdocMethod "asRspString"
# @alias asRspString.RspCode
# @alias asRspString.RspCodeChunk
# @alias asRspString.RspComment
# @alias asRspString.RspDirective
# @alias asRspString.RspDocument
# @alias asRspString.RspText
# @alias asRspString.RspUnParsedDirective
# @alias asRspString.RspUnparsedDirective
#
# @title "Recreates an RSP string from an RspConstruct"
#
# \description{
#  @get "title".
# }
#
# @synopsis
#
# \arguments{
#   \item{...}{Not used.}
# }
#
# \value{
#  Returns an @see "RspString".
# }
#
# @author
#
# \seealso{
#   @seeclass
# }
#*/#########################################################################
setMethodS3("asRspString", "RspConstruct", function(object, ...) {
  throw(sprintf("Do not know how to construct an RSP string from %s: %s", class(object)[1L], capture.output(str(object))))
})