Public/New-Documentation.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function New-Documentation {

    <#

    .SYNOPSIS
    Builds a R package documentation

    .DESCRIPTION
    Executes the devtools document function.

    .PARAMETER Path
    Specifies the path to the package source

    .PARAMETER Library
    Specifies an additional library path that contains required R packages.

    .OUTPUTS
    NULL

    .EXAMPLE
    PS C:\> New-RDocumentation -Path $PackagePath

    #>


    [CmdletBinding()]
    param (
        [Parameter( Mandatory )]
        [ValidateScript({ Test-Path $_ -PathType Container })]
        [string] $Path,

        [ValidateScript( { Test-Path $_ -PathType Container })]
        [string] $Library
    )

    $commands = @()

    if ( $Library ) {
        $commands += @( Get-AddLibraryCommand $Library )
    }

    $commands += @( 'devtools::document()' )

    Push-Location $Path
    try {
        Invoke-RScript -ArgumentList $commands -Timeout $null | Out-Null
    }
    finally {
        Pop-Location
    }
}