|
16 | 16 | .PARAMETER ShowDocs
|
17 | 17 | Show the docs via `docfx serve --open-browser ...`. This option is useful for inner loop development of the docs as it allows
|
18 | 18 | opening a browser on the newly created docs for testing/checking the contents are produced correctly.
|
19 |
| -
|
20 |
| -.PARAMETER ServeDocs |
21 |
| - Skips the docs build and implies ShowDocs to serve the current docs in the repo. This is useful after a previous |
22 |
| - Build-All or similar validation on a local machine as that will also build the docs but won't show/serve them. |
23 | 19 | #>
|
24 | 20 | Param(
|
25 | 21 | [string]$Configuration="Release",
|
26 | 22 | [switch]$FullInit,
|
27 | 23 | [switch]$NoClone,
|
28 |
| - [switch]$ShowDocs, |
29 |
| - [switch]$ServeDocs |
| 24 | + [switch]$ShowDocs |
30 | 25 | )
|
31 | 26 |
|
32 |
| -function Invoke-DocFX |
33 |
| -{ |
34 |
| - docfx $args |
35 |
| - if(!$?) |
36 |
| - { |
37 |
| - throw "Invoke of dotnet returned exit code: $LastExitCode" |
38 |
| - } |
39 |
| -} |
40 |
| - |
41 | 27 | function Get-FullBuildNumber
|
42 | 28 | {
|
43 | 29 | # docfx no longer supports the docfxconsole and insists on doing everything manually
|
|
78 | 64 | $docsOutputPath = $buildInfo['DocsOutputPath']
|
79 | 65 | Write-Information "Docs OutputPath: $docsOutputPath"
|
80 | 66 |
|
81 |
| - if(!$ServeDocs) |
| 67 | + # Clone docs output location so it is available as a destination for the Generated docs content |
| 68 | + # and the versioned docs links can function correctly for locally generated docs |
| 69 | + if(!$NoClone -and !(Test-Path (Join-Path $docsOutputPath '.git') -PathType Container)) |
82 | 70 | {
|
83 |
| - # Clone docs output location so it is available as a destination for the Generated docs content |
84 |
| - # and the versioned docs links can function correctly for locally generated docs |
85 |
| - if(!$NoClone -and !(Test-Path (Join-Path $docsOutputPath '.git') -PathType Container)) |
| 71 | + # clean out existing docs content so that clone can work |
| 72 | + if(Test-Path -PathType Container $docsOutputPath) |
86 | 73 | {
|
87 |
| - # clean out existing docs content so that clone can work |
88 |
| - if(Test-Path -PathType Container $docsOutputPath) |
89 |
| - { |
90 |
| - Write-Information "Cleaning $docsOutputPath" |
91 |
| - Remove-Item -Path $docsOutputPath -Recurse -Force -ProgressAction SilentlyContinue |
92 |
| - } |
93 |
| - |
94 |
| - Write-Information "Cloning Docs repository" |
95 |
| - Invoke-External git clone $buildInfo['OfficialGitRemoteUrl'] -b gh-pages $docsOutputPath -q |
| 74 | + Write-Information "Cleaning $docsOutputPath" |
| 75 | + Remove-Item -Path $docsOutputPath -Recurse -Force -ProgressAction SilentlyContinue |
96 | 76 | }
|
97 | 77 |
|
98 |
| - # Delete everything in the docs output except the git folder so the result of applying changes |
99 |
| - # is ONLY what is generated by this script. |
100 |
| - Write-Information "Cleaning $docsOutputPath" |
101 |
| - Get-ChildItem -Path $docsOutputPath -Exclude '.git' | remove-item -Recurse -Force -ProgressAction SilentlyContinue |
| 78 | + Write-Information "Cloning Docs repository" |
| 79 | + Invoke-External git clone $buildInfo['OfficialGitRemoteUrl'] -b gh-pages $docsOutputPath -q |
| 80 | + } |
102 | 81 |
|
103 |
| - # Create a file to disable the default GitHub Pages use of JEKYLL as this uses docfx to generate the final |
104 |
| - # HTML. [It is at least theoretically plausible that JEKYLL could handle some/all of the metadata files produced |
105 |
| - # by DOCFX but it is not clear how much of the "build" stage would be lost if ONLY the metadata phase was used. |
106 |
| - # Thus, for now, this uses the docfx build phase.] |
107 |
| - "$([DateTime]::UtcNow.ToString('o'))" | Out-File -Path (Join-Path $docsOutputPath '.nojekyll') |
| 82 | + # Delete everything in the docs output except the git folder so the result of applying changes |
| 83 | + # is ONLY what is generated by this script. |
| 84 | + Write-Information "Cleaning $docsOutputPath" |
| 85 | + Get-ChildItem -Path $docsOutputPath -Exclude '.git' | remove-item -Recurse -Force -ProgressAction SilentlyContinue |
108 | 86 |
|
109 |
| - $fullBuildNumber = Get-FullBuildNumber |
110 |
| - push-location './docfx' |
111 |
| - try |
112 |
| - { |
113 |
| - Write-Information "Building docs [FullBuildNumber=$fullBuildNumber]" |
114 |
| - Invoke-External docfx '-m' _buildVersion=$fullBuildNumber '-o' $docsOutputPath |
115 |
| - } |
116 |
| - finally |
117 |
| - { |
118 |
| - Pop-Location |
119 |
| - } |
| 87 | + # Create a file to disable the default GitHub Pages use of JEKYLL as this uses docfx to generate the final |
| 88 | + # HTML. [It is at least theoretically plausible that JEKYLL could handle some/all of the metadata files produced |
| 89 | + # by DOCFX but it is not clear how much of the "build" stage would be lost if ONLY the metadata phase was used. |
| 90 | + # Thus, for now, this uses the docfx build phase.] |
| 91 | + "$([DateTime]::UtcNow.ToString('o'))" | Out-File -Path (Join-Path $docsOutputPath '.nojekyll') |
| 92 | + |
| 93 | + $fullBuildNumber = Get-FullBuildNumber |
| 94 | + push-location './docfx' |
| 95 | + try |
| 96 | + { |
| 97 | + Write-Information "Building docs [FullBuildNumber=$fullBuildNumber]" |
| 98 | + Invoke-External docfx '-m' _buildVersion=$fullBuildNumber '-o' $docsOutputPath |
120 | 99 | }
|
121 |
| - else |
| 100 | + finally |
122 | 101 | {
|
123 |
| - $ShowDocs = $true |
| 102 | + Pop-Location |
124 | 103 | }
|
125 | 104 |
|
126 | 105 | if($ShowDocs)
|
127 | 106 | {
|
128 |
| - Invoke-External docfx serve '--open-browser' $docsOutputPath |
| 107 | + .\Show-Docs.ps1 $buildInfo |
129 | 108 | }
|
130 | 109 | }
|
131 | 110 | catch
|
|
0 commit comments