Skip to content

Commit 43d40ba

Browse files
authored
Docs Update for Roxygen2 R6 Support (#323)
1 parent b3a95de commit 43d40ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1437
-1768
lines changed

DESCRIPTION

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,4 @@ Suggests:
3838
License: BSD_3_clause + file LICENSE
3939
URL: https://github.com/uptake/pkgnet, https://uptake.github.io/pkgnet/
4040
BugReports: https://github.com/uptake/pkgnet/issues
41-
RoxygenNote: 7.1.0
42-
Roxygen: list(r6 = FALSE)
41+
RoxygenNote: 7.3.1

NAMESPACE

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ importFrom(utils,browseURL)
6565
importFrom(utils,installed.packages)
6666
importFrom(utils,packageDescription)
6767
importFrom(visNetwork,visEdges)
68-
importFrom(visNetwork,visGroups)
6968
importFrom(visNetwork,visHierarchicalLayout)
7069
importFrom(visNetwork,visIgraphLayout)
71-
importFrom(visNetwork,visLegend)
7270
importFrom(visNetwork,visNetwork)
7371
importFrom(visNetwork,visOptions)

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55

66
## CHANGES
77
* Updated `pkgnet-intro` vignette to include information on the Class Inheritance Reporter and other minor edits.
8+
<<<<<<< HEAD
89
* Recursive functions `.parse_function` and `.parse_R6_expression` made tolerant to control statemets like `break` or `next` that would break the recursion. (#322)
910
* Excessive warnings removed for custom `vignette_path` param in `CreatePackageVignette()` (#322)
11+
=======
12+
* Updated R6 class documentation to be in line with current `roxygen2` standards.
13+
>>>>>>> df2fdd4 (latest R6 doc standards for roxygen and pkgdown)
1014
1115
## BUGFIXES
1216
* `CreatePackageReporter()` failing on Windows to build package coverage when `report_path` specified. (#322)

R/AbstractGraphReporter.R

Lines changed: 33 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,31 @@
1-
#' @title Network Reporters for Packages
2-
#' @name NetworkReporters
3-
#' @keywords internal
4-
#' @concept Reporters
5-
#' @description \pkg{pkgnet} defines several package reporter R6 classes that model
6-
#' a particular network aspect of a package as a graph. These network
7-
#' reporter classes are extended from \code{AbstractGraphReporter}, which
8-
#' itself extends the \code{\link[=PackageReporters]{AbstractPackageReporter}}
9-
#' with graph-modeling-related functionality.
1+
#' Abstract Network Reporter Class
102
#'
11-
#' This article describes the additional fields added by the
12-
#' \code{AbstractGraphReporter} class definition.
3+
#' @description
4+
#' \pkg{pkgnet} defines several package reporter R6 classes that model
5+
#' a particular network aspect of a package as a graph. These network
6+
#' reporter classes are extended from \code{AbstractGraphReporter}, which
7+
#' itself extends the \code{\link[=AbstractPackageReporter]{AbstractPackageReporter}}
8+
#' with graph-modeling-related functionality.
139
#'
14-
#' @section Public Methods:
15-
#' \describe{
16-
#' \item{\code{calculate_default_measures()}}{
17-
#' \itemize{
18-
#' \item{Calculates the default node and network measures for this
19-
#' reporter.
20-
#' }
21-
#' \item{\bold{Returns:}}{
22-
#' \itemize{
23-
#' \item{Self, invisibly.}
24-
#' }
25-
#' }
26-
#' }
27-
#' }
28-
#' }
29-
#' @section Public Fields:
30-
#' \describe{
31-
#' \item{\bold{\code{nodes}}}{a data.table, containing information about
32-
#' the nodes of the network the reporter is analyzing. The \code{node}
33-
#' column acts the identifier. Read-only.
34-
#' }
35-
#' \item{\bold{\code{edges}}}{a data.table, containing information about
36-
#' the edge connections of the network the reporter is analyzing. Each
37-
#' row is one edge, and the columns \code{SOURCE} and \code{TARGET}
38-
#' specify the node identifiers. Read-only.
39-
#' }
40-
#' \item{\bold{\code{network_measures}}}{a list, containing any measures
41-
#' of the network calculated by the reporter. Read-only.
42-
#' }
43-
#' \item{\bold{\code{pkg_graph}}}{a graph model object. See \link{DirectedGraph}
44-
#' for additional documentation. Read-only.
45-
#' }
46-
#' \item{\bold{\code{graph_viz}}}{a graph visualization object. A
47-
#' \code{\link[visNetwork:visNetwork]{visNetwork::visNetwork}} object.
48-
#' Read-only.
49-
#' }
50-
#' \item{\bold{\code{layout_type}}}{a character string, the current layout
51-
#' type for the graph visualization. Can be assigned a new valid layout
52-
#' type value. Use use
53-
#' \code{grep("^layout_\\\\S", getNamespaceExports("igraph"), value = TRUE)}
54-
#' to see valid options.
55-
#' }
56-
#' }
57-
NULL
58-
59-
10+
#' This article describes the additional fields added by the \code{AbstractGraphReporter} class definition.
11+
#' @keywords internal
12+
#' @concept Reporters
6013
#' @importFrom R6 R6Class
6114
#' @importFrom DT datatable formatRound
6215
#' @importFrom data.table data.table copy setkeyv
6316
#' @importFrom assertthat assert_that
6417
#' @importFrom grDevices colorRamp colorRampPalette rgb
6518
#' @importFrom magrittr %>%
6619
#' @importFrom visNetwork visNetwork visIgraphLayout visEdges visOptions
67-
#' visGroups visLegend
20+
# visGroups visLegend
6821
AbstractGraphReporter <- R6::R6Class(
6922
"AbstractGraphReporter"
7023
, inherit = AbstractPackageReporter
7124

7225
, public = list(
26+
#' @description
27+
#' Calculates the default node and network measures for this reporter.
28+
#' @return Self, invisibly.
7329
calculate_default_measures = function() {
7430
self$pkg_graph$node_measures(
7531
measures = self$pkg_graph$default_node_measures
@@ -80,6 +36,9 @@ AbstractGraphReporter <- R6::R6Class(
8036
return(invisible(self))
8137
}
8238

39+
#' @description
40+
#' Creates a summary table formatted for display.
41+
#' @return A \code{DT} object
8342
, get_summary_view = function(){
8443

8544
# Create DT for display of the nodes data.table
@@ -108,26 +67,36 @@ AbstractGraphReporter <- R6::R6Class(
10867
) # /public
10968

11069
, active = list(
111-
70+
#' @field nodes A data.table, containing information about
71+
#' the nodes of the network the reporter is analyzing. The \code{node}
72+
#' column acts the identifier. Read-only.
11273
nodes = function(){
11374
if (is.null(private$cache$nodes)){
11475
private$extract_nodes()
11576
}
11677
return(private$cache$nodes)
11778
},
11879

80+
#' @field edges A data.table, containing information about
81+
#' the edge connections of the network the reporter is analyzing. Each
82+
#' row is one edge, and the columns \code{SOURCE} and \code{TARGET}
83+
#' specify the node identifiers. Read-only.
11984
edges = function(){
12085
if (is.null(private$cache$edges)) {
12186
private$extract_edges()
12287
}
12388
return(private$cache$edges)
12489
},
12590

91+
#' @field network_measures A list, containing any measures
92+
#' of the network calculated by the reporter. Read-only.
12693
network_measures = function() {
12794
return(c(private$cache$network_measures
12895
, private$cache$pkg_graph$graph_measures()))
12996
},
13097

98+
#' @field pkg_graph a graph model object. See \link{DirectedGraph}
99+
#' for additional documentation. Read-only.
131100
pkg_graph = function(){
132101
if (is.null(private$cache$pkg_graph)){
133102
if (is.null(private$graph_class)) {
@@ -150,13 +119,18 @@ AbstractGraphReporter <- R6::R6Class(
150119
return(private$cache$pkg_graph)
151120
},
152121

122+
#' @field graph_viz a graph visualization object. A
123+
#' \code{\link[visNetwork:visNetwork]{visNetwork::visNetwork}} object.
124+
#' Read-only.
153125
graph_viz = function(){
154126
if (is.null(private$cache$graph_viz)) {
155127
private$cache$graph_viz <- private$plot_network()
156128
}
157129
return(private$cache$graph_viz)
158130
},
159131

132+
#' @field layout_type a character string, the current layout type for the graph visualization.
133+
#' Can be assigned a new valid layout type value. Use use \code{grep("^layout_\\\\S", getNamespaceExports("igraph"), value = TRUE)} to see valid options.
160134
layout_type = function(layout) {
161135
# If user using <- assignment, set layout and reset viz
162136
if (!missing(layout)) {

R/AbstractPackageReporter.R

Lines changed: 21 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,13 @@
1-
#' @title Package Reporters
2-
#' @name PackageReporters
1+
#' Abstract Package Reporter
2+
#'
3+
#' @description
4+
#' pkgnet defines several package reporter R6 classes that analyze
5+
#' some particular aspect of a package. These reporters share common
6+
#' functionality and interfaces defined by a base reporter class
7+
#' \code{AbstractPackageReporter}.
8+
#'
39
#' @keywords internal
410
#' @concept Reporters
5-
#' @description pkgnet defines several package reporter R6 classes that analyze
6-
#' some particular aspect of a package. These reporters share common
7-
#' functionality and interfaces defined by a base reporter class
8-
#' \code{AbstractPackageReporter}.
9-
#' @section Class Constructor:
10-
#' \describe{
11-
#' \item{\code{}}{
12-
#' \itemize{
13-
#' \item{Initialize an instance of the reporter.}
14-
#' \item{\bold{Returns:}}{
15-
#' \itemize{
16-
#' \item{Instantiated reporter object. Note that this
17-
#' reporter object isn't useful yet until you use the
18-
#' \code{set_package} method to set a package.
19-
#' }
20-
#' }
21-
#' }
22-
#' }
23-
#' }
24-
#' }
25-
#'
26-
#' @section Public Methods:
27-
#' \describe{
28-
#' \item{\code{set_package(pkg_name, pkg_path = NULL)}}{
29-
#' \itemize{
30-
#' \item{Set the package that the reporter will analyze. This can
31-
#' only be done once for a given instance of a reporter.
32-
#' Instantiate a new copy of the reporter if you need to analyze
33-
#' a different package.
34-
#' }
35-
#' \item{\bold{Args:}}{
36-
#' \itemize{
37-
#' \item{\bold{\code{pkg_name}}: character string, name of
38-
#' package
39-
#' }
40-
#' \item{\bold{\code{pkg_path}}: character string, optional
41-
#' directory path to source code of the package. It is used
42-
#' for calculating test coverage. It can be an absolute or
43-
#' relative path.
44-
#' }
45-
#' }
46-
#' }
47-
#' \item{\bold{Returns:}}{
48-
#' \itemize{
49-
#' \item{Self, invisibly.}
50-
#' }
51-
#' }
52-
#' }
53-
#' }
54-
#' \item{\code{get_summary_view()}}{
55-
#' \itemize{
56-
#' \item{Returns an htmlwidget object that summarizes the analysis
57-
#' of the reporter. Used when creating a
58-
#' \link[=CreatePackageReport]{package report}.
59-
#' }
60-
#' \item{\bold{Returns:}}{
61-
#' \itemize{
62-
#' \item{\link[htmlwidgets:htmlwidgets-package]{htmlwidget}
63-
#' object
64-
#' }
65-
#' }
66-
#' }
67-
#' }
68-
#' }
69-
#' }
70-
#'
71-
#' @section Public Fields:
72-
#' \describe{
73-
#' \item{\bold{\code{pkg_name}}}{character string, name of set package.
74-
#' Read-only.
75-
#' }
76-
#' \item{\bold{\code{report_markdown_path}}}{character string, path to
77-
#' R Markdown template for this reporter. Read-only.
78-
#' }
79-
#' }
80-
#'
81-
#' @section Special Methods:
82-
#' \describe{
83-
#' \item{\code{clone(deep = FALSE)}}{
84-
#' \itemize{
85-
#' \item{Method for copying an object. See
86-
#' \href{https://adv-r.hadley.nz/r6.html#r6-semantics}{\emph{Advanced R}}
87-
#' for the intricacies of R6 reference semantics.
88-
#' }
89-
#' \item{\bold{Args:}}{
90-
#' \itemize{
91-
#' \item{\bold{\code{deep}}: logical. Whether to recursively
92-
#' clone nested R6 objects.
93-
#' }
94-
#' }
95-
#' }
96-
#' \item{\bold{Returns:}}{
97-
#' \itemize{
98-
#' \item{Cloned object of this class.}
99-
#' }
100-
#' }
101-
#' }
102-
#' }
103-
#' }
104-
NULL
105-
10611
#' @importFrom R6 R6Class
10712
#' @importFrom assertthat assert_that is.string
10813
#' @importFrom tools file_path_as_absolute
@@ -111,6 +16,14 @@ AbstractPackageReporter <- R6::R6Class(
11116

11217
public = list(
11318

19+
#' @description
20+
#' Set the package that the reporter will analyze. This can
21+
#' only be done once for a given instance of a reporter.
22+
#' Instantiate a new copy of the reporter if you need to analyze a different package.
23+
#' @param pkg_name (character string) name of package
24+
#' @param pkg_path (character string) optional directory path to source code of the package.
25+
#' It is used for calculating test coverage. It can be an absolute or relative path.
26+
#' @return Self, invisibly.
11427
set_package = function(pkg_name, pkg_path = NULL) {
11528

11629
# Packages can only be set once
@@ -141,17 +54,22 @@ AbstractPackageReporter <- R6::R6Class(
14154
return(invisible(self))
14255
},
14356

57+
#' @description Returns an htmlwidget object that summarizes the analysis of the reporter.
58+
#' Used when creating a \link[=CreatePackageReport]{package report}.
59+
#' @return Self, invisibly.
14460
get_summary_view = function(){
14561
stop("get_summary_view has not been implemented.")
14662
}
14763
),
14864

14965
active = list(
15066

67+
#' @field pkg_name (character string) name of set package. Read-only.
15168
pkg_name = function(){
15269
return(private$private_pkg_name)
15370
},
15471

72+
#' @field report_markdown_path (character string) path to R Markdown template for this reporter. Read-only.
15573
report_markdown_path = function(){
15674
log_fatal("this reporter does not have a report markdown path")
15775
}

0 commit comments

Comments
 (0)