#' Format R Help Pages from Package Documentation
#'
#' This package was developed to allow additional formats for help pages created from R package
#' documentation (viz., DESCRIPTION and Rd files in the 'man' folder). It includes a wrapper
#' for the standard formats provided in 'tools' package (text, HTML, Latex and examples),
#' but at this stage only for single Rd files. Currently the only additional format provided
#' is \special{MoinMoin} wiki markup. For \special{MoinMoin} and for PDF, pages can be made
#' for both single Rd files and for whole packages (with header and footers).
#'
#' This package is work-in-progress, so do not expect all Rd features to be converted
#' to \special{MoinMoin} markup at this stage.
#'
#' The package name, 'rhelium', is in honour of 'roxygen2' that creates the Rd files used.
#' Helium is ligher than oxygen, so the name has both illustrative and metaphorical meanings.
#'
#' For a complete list, use library(help = "rhelium").
#'
#' @note
#' 'tools' does not export the functions used in this package, so this are subject to change,
#' and if so, this package will need to be revised accordingly.
#'
#' 'rhelium' uses some general functions from 'local' package, see \link{\Sexpr{local:::self_url}}.
#'
#' @author Ian Riley \email{ian@@riley.asia}
#' @docType package
#' @section Version:
#' \Sexpr{packageVersion("rhelium")}
#' @importFrom tools parse_Rd Rd_db Rd2txt Rd2HTML Rd2latex Rd2ex file_ext
#' @name rhelium
"_PACKAGE"

self <- "rhelium"
options(installing_package = TRUE)
source('~/.Rprofile')
options(installing_package = NULL)
home_path <- function() ifelse(is.null(options()$home), getwd(), options()$home)
self_path <- file.path(home_path(), paste0(self, "-package"))
self_url <- desc::desc_get_urls(self_path)[1]

#' Document and install self
#'
#' Load required libraries, `devtools` and `roxygen2`, then document and install 'self'-package.
#' @keywords internal
#' @return Nothing returned.
install_self <- function(package = self)
{
	local:::install_self(package = package)
}

#' Set working directory to package root
#'
#' @keywords internal
#' @return Current working directory.
pkgdir <- function(package = self)
{
	local:::pkgdir(package = package)
}

isLoaded <- function()
{
	isNamespaceLoaded(self)	
}

rhelium <- isLoaded()

