@@ -1229,14 +1229,62 @@ function Copy-BuildArtifact {
12291229}
12301230# endregion Build project functions
12311231
1232+ # region Documenting project functions
1233+ function Export-RustDocs {
1234+ [CmdletBinding ()]
1235+ param (
1236+ [DscProjectDefinition []]$Project ,
1237+ [ValidateSet (' current' , ' aarch64-pc-windows-msvc' , ' x86_64-pc-windows-msvc' , ' aarch64-apple-darwin' , ' x86_64-apple-darwin' , ' aarch64-unknown-linux-gnu' , ' aarch64-unknown-linux-musl' , ' x86_64-unknown-linux-gnu' , ' x86_64-unknown-linux-musl' )]
1238+ $Architecture = ' current' ,
1239+ [switch ]$Release ,
1240+ [switch ]$IncludeDependencies
1241+ )
1242+
1243+ begin {
1244+ $flags = @ ($Release ? ' -r' : $null )
1245+ if ($Architecture -ne ' current' ) {
1246+ $flags += ' --target'
1247+ $flags += $Architecture
1248+ } else {
1249+ $memberGroup = if ($IsLinux ) {
1250+ ' Linux'
1251+ } elseif ($IsMacOS ) {
1252+ ' macOS'
1253+ } elseif ($IsWindows ) {
1254+ ' Windows'
1255+ }
1256+ Set-DefaultWorkspaceMemberGroup - MemberGroup $memberGroup
1257+ }
1258+ if (-not $IncludeDependencies ) {
1259+ $flags += ' --no-deps'
1260+ }
1261+ }
1262+
1263+ process {
1264+ $members = Get-DefaultWorkspaceMemberGroup
1265+ Write-Verbose - Verbose " Exporting documentation for rust projects: [$members ]"
1266+ cargo doc @flags
1267+
1268+ if ($null -ne $LASTEXITCODE -and $LASTEXITCODE -ne 0 ) {
1269+ Write-Error " Last exit code is $LASTEXITCODE , 'cargo doc' failed"
1270+ }
1271+ }
1272+
1273+ clean {
1274+ Reset-DefaultWorkspaceMemberGroup
1275+ }
1276+ }
1277+ # endregion Documenting project functions
1278+
12321279# region Test project functions
12331280function Test-RustProject {
12341281 [CmdletBinding ()]
12351282 param (
12361283 [DscProjectDefinition []]$Project ,
12371284 [ValidateSet (' current' , ' aarch64-pc-windows-msvc' , ' x86_64-pc-windows-msvc' , ' aarch64-apple-darwin' , ' x86_64-apple-darwin' , ' aarch64-unknown-linux-gnu' , ' aarch64-unknown-linux-musl' , ' x86_64-unknown-linux-gnu' , ' x86_64-unknown-linux-musl' )]
12381285 $Architecture = ' current' ,
1239- [switch ]$Release
1286+ [switch ]$Release ,
1287+ [switch ]$Docs
12401288 )
12411289
12421290 begin {
@@ -1254,11 +1302,18 @@ function Test-RustProject {
12541302 }
12551303 Set-DefaultWorkspaceMemberGroup - MemberGroup $memberGroup
12561304 }
1305+ if ($Docs ) {
1306+ $flags += ' --doc'
1307+ }
12571308 }
12581309
12591310 process {
12601311 $members = Get-DefaultWorkspaceMemberGroup
1261- Write-Verbose - Verbose " Testing rust projects: [$members ]"
1312+ if ($Docs ) {
1313+ Write-Verbose - Verbose " Testing documentation for rust projects: [$members ]"
1314+ } else {
1315+ Write-Verbose - Verbose " Testing rust projects: [$members ]"
1316+ }
12621317 cargo test @flags
12631318
12641319 if ($null -ne $LASTEXITCODE -and $LASTEXITCODE -ne 0 ) {
0 commit comments