extras/PackageMaintenance.R

# @file PackageMaintenance
#
# Copyright 2022 Observational Health Data Sciences and Informatics
#
# This file is part of SelfControlledCohort
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Format and check code
devtools::spell_check()

OhdsiRTools::formatRFolder()
OhdsiRTools::checkUsagePackage("SelfControlledCohort")

OhdsiRTools::updateCopyrightYearFolder()


# Create manual
system("rm extras/SelfControlledCohort.pdf")
system("R CMD Rd2pdf ./ --output=extras/SelfControlledCohort.pdf")


# Create vignette
diag <- DiagrammeR::mermaid("
sequenceDiagram
  participant Tn100 as Observation Period Start
  participant Tn30 as Unexposed Risk Window Start
  participant Tn1 as Unexposed Risk Window End
  participant T0 as Exposure Start Date (Time 0)
  participant T1 as Exposed Risk Window Start
  participant T30 as Exposed Risk Window End
  participant T100 as Observation Period End

  Tn100 ->> T0: washout period
  T0 ->> T100: followup period
  Tn30->>Tn1: Unexposed time at risk
  T1->>T30: Exposed time at risk
")

print("Use R studio export view to save diag object to vignettes/ExposureWindowsDiagram.png")

rmarkdown::render("vignettes/UsingSelfControlledCohort.Rmd",
                  output_file = "inst/doc/UsingSelfControlledCohort.pdf",
                  rmarkdown::pdf_document(latex_engine = "pdflatex",
                                          toc = TRUE,
                                          number_sections = TRUE))
unlink("inst/doc/UsingSelfControlledCohort.tex")


pkgdown::build_site()
OhdsiRTools::fixHadesLogo()

# Create arg functions
rCode <- c("# This file has been autogenerated. Do not change by hand. ")
rCode <- ParallelLogger::createArgFunction("runSelfControlledCohort",
                                        excludeArgs = c("connectionDetails",
                                                        "cdmDatabaseSchema",
                                                        "oracleTempSchema",
                                                        "exposureDatabaseSchema",
                                                        "exposureTable",
                                                        "outcomeDatabaseSchema",
                                                        "outcomeTable",
                                                        "cdmVersion",
                                                        "exposureIds",
                                                        "outcomeIds",
                                                        "computeThreads"),
                                        rCode = rCode)
writeLines(rCode, "r/CreateArgFunctions.R")
ParallelLogger::formatRFile("r/CreateArgFunctions.R")
OHDSI/SelfControlledCohort documentation built on Feb. 22, 2023, 5:44 p.m.