@@ -303,18 +303,27 @@ function Get-DscResourceWikiExampleContent
303
303
304
304
<#
305
305
. SYNOPSIS
306
- Publishes the Wiki Content from an AppVeyor job artifact.
306
+ Publishes the Wiki Content from a module and AppVeyor job artifact.
307
307
308
308
. DESCRIPTION
309
- This function adds the content pages from the Wiki Content artifact of a specified
310
- AppVeyor job to the Wiki of a specified GitHub repository.
309
+ This function publishes the content pages from the Wiki Content artifact
310
+ of a specified AppVeyor job along with any additional files stored in the
311
+ 'WikiSource' directory of the repository and an auto-generated sidebar file
312
+ containing links to all the markdown files to the Wiki of a specified GitHub
313
+ repository.
311
314
312
315
. PARAMETER RepoName
313
316
The name of the Github Repo, in the format <account>/<repo>.
314
317
315
318
. PARAMETER JobId
316
319
The AppVeyor job id that contains the wiki artifact to publish.
317
320
321
+ . PARAMETER MainModulePath
322
+ The path of the DSC Resource Module.
323
+
324
+ . PARAMETER WikiSourceFolder
325
+ The name of the folder in the DSC Resource Module that contains any Wiki source files.
326
+
318
327
. PARAMETER ResourceModuleName
319
328
The name of the Dsc Resource Module.
320
329
@@ -332,9 +341,9 @@ function Get-DscResourceWikiExampleContent
332
341
333
342
. EXAMPLE
334
343
Publish-WikiContent -RepoName 'PowerShell/xActiveDirectory' -JobId 'imy2wgp1ylo9bcpb' -ResourceModuleName 'xActiveDirectory' `
335
- -BuildVersion 'v1.0.0'
344
+ -MainModulePath 'C:\ModulePath' - BuildVersion 'v1.0.0'
336
345
337
- Adds the Content pages from the AppVeyor Job artifact to the Wiki for the specified GitHub repository.
346
+ Adds the Content pages from the AppVeyor Job artifact and module path to the Wiki for the specified GitHub repository.
338
347
339
348
. NOTES
340
349
Appveyor - Push to remote Git repository from a build: https://www.appveyor.com/docs/how-to/git-push/
@@ -352,6 +361,16 @@ function Publish-WikiContent
352
361
[System.String ]
353
362
$JobId = $env: APPVEYOR_JOB_ID ,
354
363
364
+ [Parameter ()]
365
+ [ValidateNotNullOrEmpty ()]
366
+ [System.String ]
367
+ $MainModulePath = $env: APPVEYOR_BUILD_FOLDER ,
368
+
369
+ [Parameter ()]
370
+ [ValidateNotNullOrEmpty ()]
371
+ [System.String ]
372
+ $WikiSourceFolder = ' WikiSource' ,
373
+
355
374
[Parameter ()]
356
375
[System.String ]
357
376
$ResourceModuleName = (($env: APPVEYOR_REPO_NAME -split ' /' )[1 ]),
@@ -432,6 +451,10 @@ function Publish-WikiContent
432
451
Expand-Archive - Path $wikiContentArtifactPath - DestinationPath $path - Force
433
452
Remove-Item - Path $wikiContentArtifactPath
434
453
454
+ Set-WikiSidebar - ResourceModuleName $ResourceModuleName - Path $path
455
+ Set-WikiFooter - ResourceModuleName $ResourceModuleName - Path $path
456
+ Copy-WikiFile - MainModulePath $MainModulePath - Path $path - WikiSourceFolder $WikiSourceFolder
457
+
435
458
Push-Location
436
459
Set-Location - Path $path
437
460
@@ -478,7 +501,7 @@ function Invoke-Git
478
501
[CmdletBinding ()]
479
502
param
480
503
(
481
- [parameter (ValueFromRemainingArguments = $true )]
504
+ [Parameter (ValueFromRemainingArguments = $true )]
482
505
[System.String []]
483
506
$Arguments
484
507
)
@@ -541,4 +564,138 @@ function New-TempFolder
541
564
return $path
542
565
}
543
566
567
+ <#
568
+ . SYNOPSIS
569
+ Creates the Wiki side bar file from the list of markdown files in the path.
570
+
571
+ . PARAMETER ResourceModuleName
572
+ The name of the resource module.
573
+
574
+ . PARAMETER Path
575
+ The path of the Wiki page files.
576
+
577
+ . EXAMPLE
578
+ Set-WikiSidebar -ResourceModuleName $ResourceModuleName -Path $path
579
+
580
+ Creates the Wiki side bar from the list of markdown files in the path.
581
+ #>
582
+ function Set-WikiSidebar
583
+ {
584
+ [CmdletBinding ()]
585
+ param
586
+ (
587
+ [Parameter (Mandatory = $true )]
588
+ [System.String ]
589
+ $ResourceModuleName ,
590
+
591
+ [Parameter (Mandatory = $true )]
592
+ [System.String ]
593
+ $Path
594
+ )
595
+
596
+ $wikiSideBarFileBaseName = ' _Sidebar.md'
597
+ $wikiSideBarFileFullName = Join-Path - Path $path - ChildPath $wikiSideBarFileBaseName
598
+
599
+ Write-Verbose - Message ($localizedData.GenerateWikiSidebarMessage -f $wikiSideBarFileBaseName )
600
+ $WikiSidebar = @ (
601
+ " # $ResourceModuleName Module"
602
+ ' '
603
+ )
604
+
605
+ $wikiFiles = Get-ChildItem - Path $Path - Filter ' *.md'
606
+
607
+ foreach ($file in $wikiFiles )
608
+ {
609
+ $wikiSidebar += " - [$ ( $file.BaseName ) ]($ ( $file.BaseName ) )"
610
+ }
611
+
612
+ Out-File - InputObject $wikiSideBar - FilePath $wikiSideBarFileFullName - Encoding ASCII
613
+ }
614
+
615
+ <#
616
+ . SYNOPSIS
617
+ Creates the Wiki footer file if one does not already exist.
618
+
619
+ . PARAMETER Path
620
+ The path for the Wiki footer file.
621
+
622
+ . EXAMPLE
623
+ Set-WikiFooter -Path $path
624
+
625
+ Creates the Wiki footer.
626
+ #>
627
+ function Set-WikiFooter
628
+ {
629
+ [CmdletBinding ()]
630
+ param
631
+ (
632
+ [Parameter (Mandatory = $true )]
633
+ [System.String ]
634
+ $ResourceModuleName ,
635
+
636
+ [Parameter (Mandatory = $true )]
637
+ [System.String ]
638
+ $Path
639
+ )
640
+
641
+ $wikiFooterFileBaseName = ' _Footer.md'
642
+ $wikiFooterFileFullName = Join-Path - Path $path - ChildPath $wikiFooterFileBaseName
643
+
644
+ if (-not (Test-Path - Path $wikiFooterFileFullName ))
645
+ {
646
+ Write-Verbose - Message ($localizedData.GenerateWikiFooterMessage -f $wikiFooterFileBaseName )
647
+ $wikiFooter = @ ()
648
+
649
+ Out-File - InputObject $wikiFooter - FilePath $wikiFooterFileFullName - Encoding ASCII
650
+ }
651
+ }
652
+
653
+ <#
654
+ . SYNOPSIS
655
+ Copies any Wiki files from the module into the Wiki overwriting any existing files.
656
+
657
+ . PARAMETER MainModulePath
658
+ The path of the module.
659
+
660
+ . PARAMETER Path
661
+ The destination path for the Wiki files.
662
+
663
+ . PARAMETER WikiSourceFolder
664
+ The name of the folder that contains the source Wiki files.
665
+
666
+ . EXAMPLE
667
+ Copy-WikiFile -MainModulePath $MainModulePath -Path $path -WikiSourcePath $wikiSourcePath
668
+
669
+ Copies any Wiki files from the module into the Wiki.
670
+ #>
671
+ function Copy-WikiFile
672
+ {
673
+ [CmdletBinding ()]
674
+ param
675
+ (
676
+ [Parameter (Mandatory = $true )]
677
+ [System.String ]
678
+ $MainModulePath ,
679
+
680
+ [Parameter (Mandatory = $true )]
681
+ [System.String ]
682
+ $Path ,
683
+
684
+ [Parameter (Mandatory = $true )]
685
+ [System.String ]
686
+ $WikiSourceFolder
687
+ )
688
+
689
+ $wikiSourcePath = Join-Path - Path $MainModulePath - ChildPath $WikiSourceFolder
690
+ Write-Verbose - Message ($localizedData.CopyWikiFilesMessage -f $wikiSourcePath )
691
+
692
+ $wikiFiles = Get-ChildItem - Path $wikiSourcePath
693
+ foreach ($file in $wikiFiles )
694
+
695
+ {
696
+ Write-Verbose - Message ($localizedData.CopyFileMessage -f $file.name )
697
+ Copy-Item - Path $file.fullname - Destination $Path - Force
698
+ }
699
+ }
700
+
544
701
Export-ModuleMember - Function New-DscResourceWikiSite , Publish-WikiContent
0 commit comments