-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
374 enum listing molecules #380
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,84 @@ | ||
#' @title .getTitlesFromFamilyTag | ||
#' @description Get all title names from documented functions/R6 classes that have specific family tags. | ||
#' The function aims at created automated and synchronized enums | ||
#' @param familyTag Family tag used to document functions or R6 classes | ||
#' @return character array of titles | ||
#' @import ospsuite.utils | ||
#' @keywords internal | ||
.getTitlesFromFamilyTag <- function(familyTag) { | ||
functionNames <- NULL | ||
for (filePath in list.files("./R", full.names = TRUE)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no idea how it works - but it works :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When building/documenting a package, the working directory is internally set to the package location during the procedure (I did some testing with The function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, cool. Thanks for the explanation :) |
||
fileContent <- readLines(filePath, warn = FALSE) | ||
familyTagLines <- grep(pattern = paste0("#' @family ", familyTag), x = fileContent) | ||
if (isEmpty(familyTagLines)) { | ||
next | ||
} | ||
# Get closest title before tag | ||
titleLines <- grep(pattern = "#' @title", x = fileContent) | ||
functionNames <- c( | ||
functionNames, | ||
sapply( | ||
familyTagLines, | ||
# assumes that title tag is defined before family tag | ||
FUN = function(familyTagLine) { | ||
# Get line of closest title tag before family tag | ||
titleLine <- titleLines[which.min( | ||
familyTagLine - titleLines[titleLines < familyTagLine] | ||
)] | ||
functionName <- trimws(gsub(".*@title", "", fileContent[titleLine])) | ||
return(functionName) | ||
} | ||
) | ||
) | ||
} | ||
return(functionNames) | ||
} | ||
|
||
#' @title AestheticFields | ||
#' @import ospsuite.utils | ||
#' @export | ||
#' @description | ||
#' List of all available aesthetic fields that manage aesthetic properties | ||
#' @family enum helpers | ||
AestheticFields <- enum(c( | ||
"lines", | ||
"points", | ||
"ribbons", | ||
"errorbars" | ||
)) | ||
|
||
#' @title AtomPlots | ||
#' @import ospsuite.utils | ||
#' @export | ||
#' @description | ||
#' List of all available atom plots | ||
#' @family enum helpers | ||
AtomPlots <- enum(c(.getTitlesFromFamilyTag("atom plots"))) | ||
|
||
#' @title MoleculePlots | ||
#' @import ospsuite.utils | ||
#' @export | ||
#' @description | ||
#' List of all available molecule plots | ||
#' @family enum helpers | ||
MoleculePlots <- enum(c(.getTitlesFromFamilyTag("molecule plots"))) | ||
|
||
#' @title PlotConfigurations | ||
#' @import ospsuite.utils | ||
#' @export | ||
#' @description | ||
#' List of all available molecule plots | ||
#' @family enum helpers | ||
PlotConfigurations <- enum(c(.getTitlesFromFamilyTag("PlotConfiguration classes"))) | ||
|
||
#' @title DataMappings | ||
#' @import ospsuite.utils | ||
#' @export | ||
#' @description | ||
#' List of all available molecule plots | ||
#' @family enum helpers | ||
DataMappings <- enum(c(.getTitlesFromFamilyTag("DataMapping classes"))) | ||
|
||
#' @title Alignments | ||
#' @import ospsuite.utils | ||
#' @export | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting feature :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally.
I think it could be beneficial to apply it to other R6 objects such as workflows or task settings in RE (that would make user defined tasks or settings more flexible)