Skip to content

Commit aa5922c

Browse files
committed
update documentation
+ improve get_description + export get_description + update as.code to handle case when iterator has default model object + rebuild documentation
1 parent 9a6d86a commit aa5922c

35 files changed

+323
-139
lines changed

Diff for: DESCRIPTION

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: struct
22
Type: Package
33
Title: Statistics in R Using Class-based Templates
4-
Version: 1.15.2
4+
Version: 1.15.3
55
Authors@R: c(
66
person(
77
c("Gavin","Rhys"),
@@ -49,7 +49,8 @@ Collate:
4949
'resampler_class.R'
5050
'struct.R'
5151
'struct_templates.R'
52-
RoxygenNote: 7.1.2
52+
'zzz.R'
53+
RoxygenNote: 7.2.3
5354
Depends: R (>= 4.0)
5455
Suggests:
5556
testthat,

Diff for: NAMESPACE

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export("output_value<-")
1414
export("param_list<-")
1515
export("param_obj<-")
1616
export("param_value<-")
17+
export(.struct_class)
1718
export(DatasetExperiment)
1819
export(as.DatasetExperiment)
1920
export(as.SummarizedExperiment)
@@ -31,6 +32,7 @@ export(enum_stato)
3132
export(example_chart)
3233
export(example_iterator)
3334
export(example_model)
35+
export(get_description)
3436
export(iris_DatasetExperiment)
3537
export(is_output)
3638
export(is_param)

Diff for: R/generics.R

+1-2
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ setGeneric("output_list<-",function(obj,value)standardGeneric("output_list<-"))
230230
#'
231231
#' Returns a list of valid charts for a struct object
232232
#'
233-
#' The chart_names method searches chart objects that specify the input object
234-
#' type as an input.
233+
#' The chart_names method searches for chart objects associated with the unput object.
235234
#'
236235
#' @param obj An object derived from the struct_class object
237236
#' @param ret A string indicating whether a list of objects ('obj') or a list of chart

Diff for: R/iterator_class.R

+10-8
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ setMethod(f = 'show',
229229
signature = c('iterator'),
230230
definition = function(object) {
231231
callNextMethod()
232-
232+
233233
if (is(models(object),'model_seq')) {
234234
cat('models: ','a model_seq with ', length(models(object)),' steps\n',sep='')
235235
} else {
@@ -251,9 +251,11 @@ setMethod(f = 'as.code',
251251
definition = function(M,start='M = ',mode='compact',quiet=FALSE) {
252252
str=.as_code(M,start,mode)
253253
# get models
254-
m=models(M)
255-
# if iterator then multiply
256-
str=paste0(str,' * \n')
254+
m = models(M)
255+
# if iterator then multiply, if not default model
256+
if (class(m)[1]!='model') {
257+
str=paste0(str,' * \n')
258+
}
257259
if (is(m,'model_seq') & length(m) > 1) {
258260
if (mode=='expanded') {
259261
str=paste0(str,paste0(paste0(rep(' ',nchar(start)),collapse=''),'(\n'))
@@ -266,14 +268,14 @@ setMethod(f = 'as.code',
266268
}
267269

268270
str=paste0(str,')')
269-
} else {
271+
} else if (class(m)[1]!='model') {
270272
str=paste0(str,as.code(m,start=paste0(rep(' ',nchar(start)),collapse=''),mode,quiet=TRUE))
271273
}
272-
274+
273275
if (!quiet){
274276
cat(str)
275277
}
276-
278+
277279
invisible(str)
278280
}
279281
)
@@ -288,7 +290,7 @@ setMethod(f = 'as.code',
288290
.DollarNames.struct_class(x,pattern)
289291
}
290292

291-
#' @export
293+
#' @export
292294
#' @rdname autocompletion
293295
setMethod('.DollarNames','iterator',.DollarNames.iterator)
294296

Diff for: R/output_class.R

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#' @include generics.R struct_class.R
22
#'
3-
#' @describeIn output_obj
3+
#' @rdname output_obj
44
#' @export
55
setMethod(f = "output_obj",
66
signature = c("struct_class","character"),
@@ -10,7 +10,7 @@ setMethod(f = "output_obj",
1010
}
1111
)
1212

13-
#' @describeIn output_obj
13+
#' @rdname output_obj
1414
#' @export
1515
#' @return the modified object
1616
setMethod(f = "output_obj<-",
@@ -24,7 +24,7 @@ setMethod(f = "output_obj<-",
2424
}
2525
)
2626

27-
#' @describeIn is_output
27+
#' @rdname is_output
2828
#' @export
2929
setMethod(f = "is_output",
3030
signature = c("struct_class"),
@@ -38,7 +38,7 @@ setMethod(f = "is_output",
3838
}
3939
)
4040

41-
#' @describeIn output_ids
41+
#' @rdname output_ids
4242
#' @export
4343
setMethod(f = "output_ids",
4444
signature = c("struct_class"),
@@ -62,7 +62,7 @@ setMethod(f = "output_ids",
6262
}
6363
)
6464

65-
#' @describeIn output_name
65+
#' @rdname output_name
6666
#' @export
6767
setMethod(f = "output_name",
6868
signature = c("struct_class",'character'),
@@ -79,7 +79,7 @@ setMethod(f = "output_name",
7979
}
8080
)
8181

82-
#' @describeIn output_list
82+
#' @rdname output_list
8383
#' @export
8484
setMethod(f = 'output_list',
8585
signature = c('struct_class'),
@@ -93,7 +93,7 @@ setMethod(f = 'output_list',
9393
}
9494
)
9595

96-
#' @describeIn output_list
96+
#' @rdname output_list
9797
#' @export
9898
setMethod(f = 'output_list<-',
9999
signature = c('struct_class','list'),
@@ -106,7 +106,7 @@ setMethod(f = 'output_list<-',
106106
}
107107
)
108108

109-
#' @describeIn output_value
109+
#' @rdname output_value
110110
#' @export
111111
setMethod(f = "output_value",
112112
signature = c("struct_class","character"),
@@ -125,7 +125,7 @@ setMethod(f = "output_value",
125125
)
126126

127127

128-
#' @describeIn output_value
128+
#' @rdname output_value
129129
#' @export
130130
setMethod(f = "output_value<-",
131131
signature = c("struct_class","character"),

Diff for: R/parameter_class.R

+7-7
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ setMethod(f = "param_obj",
2525

2626

2727
#' @export
28-
#' @describeIn is_param
28+
#' @rdname is_param
2929
setMethod(f = "is_param",
3030
signature = c("struct_class"),
3131
definition = function(obj,name) {
@@ -39,7 +39,7 @@ setMethod(f = "is_param",
3939
)
4040

4141
#' @export
42-
#' @describeIn param_ids
42+
#' @rdname param_ids
4343
setMethod(f = "param_ids",
4444
signature = c("struct_class"),
4545
definition = function(obj) {
@@ -65,7 +65,7 @@ setMethod(f = "param_ids",
6565

6666

6767
#' @export
68-
#' @describeIn param_name
68+
#' @rdname param_name
6969
setMethod(f = "param_name",
7070
signature = c("struct_class",'character'),
7171
definition = function(obj,name) {
@@ -82,7 +82,7 @@ setMethod(f = "param_name",
8282
)
8383

8484
#' @export
85-
#' @describeIn param_list
85+
#' @rdname param_list
8686
setMethod(f = 'param_list',
8787
signature = c('struct_class'),
8888
definition = function(obj) {
@@ -96,7 +96,7 @@ setMethod(f = 'param_list',
9696
)
9797

9898
#' @export
99-
#' @describeIn param_list
99+
#' @rdname param_list
100100
setMethod(f = 'param_list<-',
101101
signature = c('struct_class','list'),
102102
definition = function(obj,value) {
@@ -109,7 +109,7 @@ setMethod(f = 'param_list<-',
109109
)
110110

111111
#' @export
112-
#' @describeIn param_value
112+
#' @rdname param_value
113113
setMethod(f = "param_value",
114114
signature = c("struct_class","character"),
115115
definition = function(obj,name) {
@@ -128,7 +128,7 @@ setMethod(f = "param_value",
128128
)
129129

130130
#' @export
131-
#' @describeIn param_value
131+
#' @rdname param_value
132132
setMethod(f = "param_value<-",
133133
signature = c("struct_class","character","ANY"),
134134
definition = function(obj,name,value) {

Diff for: R/struct_class.R

+18-7
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ setMethod(f = "$<-",
226226
}
227227
)
228228

229-
#' @describeIn chart_names
230229
#' @export
230+
#' @rdname chart_names
231231
setMethod(f = "chart_names",
232232
signature = c("struct_class"),
233233
definition = function(obj,ret = 'char') {
@@ -647,7 +647,7 @@ setMethod('.DollarNames','struct_class',.DollarNames.struct_class)
647647
setMethod(f = 'as.code',
648648
signature = c('struct_class'),
649649
definition = function(M,start = 'M = ',mode = 'compact',quiet=FALSE) {
650-
str=.as_code(M,start,mode)
650+
str=struct:::.as_code(M,start,mode)
651651

652652
if (!quiet) {
653653
cat(str)
@@ -664,9 +664,9 @@ setMethod(f = 'as.code',
664664
if (!(mode %in% c('compact','neat','expanded','full'))) {
665665
stop(paste0('unknown option "', mode , '" for as.code()'))
666666
}
667-
str=start
667+
str = start
668668
# model object name
669-
str=paste0(str,class(M)[1],'(')
669+
str = paste0(str,class(M)[1],'(')
670670

671671
# parameters
672672
P = param_ids(M)
@@ -679,17 +679,24 @@ setMethod(f = 'as.code',
679679
}
680680
# add predicted if its not the default
681681
if (is(M,'model')) {
682-
N=new_struct(class(M)[1])
682+
N = new_struct(class(M)[1])
683+
683684
if (length(predicted_name(N))==0) {
684-
N@predicted='cake'
685+
N@predicted='not specified'
686+
}
687+
if (length(predicted_name(M))==0) {
688+
M@predicted='not specified'
685689
}
686690

687691
if (predicted_name(N) != predicted_name(M) | mode=='full') {
688692
P=c(P,'predicted')
689693
}
690694
}
691695

692-
if (mode != "compact") {
696+
if ((mode=='neat' | mode=='expanded') & length(P)==0) {
697+
str=paste0(str)
698+
indent=nchar(start)+2
699+
} else if (mode != "compact") {
693700
str=paste0(str,'\n')
694701
indent=nchar(start)+2
695702
} else {
@@ -753,5 +760,9 @@ setMethod(f = 'as.code',
753760
}
754761
}
755762

763+
if (length(P)==0) {
764+
str=paste0(str,')')
765+
}
766+
756767
return(str)
757768
}

0 commit comments

Comments
 (0)