Skip to content

Commit

Permalink
Remove SkipToolInstall flag since we now check the version; fix main …
Browse files Browse the repository at this point in the history
…site build and upgrade to latest docfx
  • Loading branch information
paulirwin committed Sep 22, 2024
1 parent ef21a0f commit e6c6742
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 38 deletions.
35 changes: 16 additions & 19 deletions websites/apidocs/docs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ param (
[string] $LuceneNetVersion,
[switch] $ServeDocs = $false,
[switch] $Clean = $false,
[switch] $SkipToolInstall = $false, # to speed up iteration if you already have the tool installed
[switch] $DisableMetaData = $false,
[switch] $DisableBuild = $false,
[switch] $DisablePlugins = $false,
Expand Down Expand Up @@ -65,27 +64,25 @@ $TocPath2 = Join-Path -Path $ApiDocsFolder -ChildPath "toc\toc.yml"
$BreadcrumbPath = Join-Path -Path $ApiDocsFolder -ChildPath "docfx.global.subsite.json"

# install docfx tool
if ($SkipToolInstall -eq $false) {
$InstallDocFx = $false
try {
$InstalledDocFxVersion = (& docfx --version).Trim().Split('+')[0]

if ([version]$InstalledDocFxVersion -lt [version]$DocFxVersion) {
Write-Host "DocFx is installed, but the version is less than $DocFxVersion, will install it."
$InstallDocFx = $true
}
else {
Write-Host "DocFx is installed and the version is $InstalledDocFxVersion."
}
} catch {
Write-Host "DocFx is not installed or not in the PATH, will install it."
$InstallDocFx = $false
try {
$InstalledDocFxVersion = (& docfx --version).Trim().Split('+')[0]

if ([version]$InstalledDocFxVersion -lt [version]$DocFxVersion) {
Write-Host "DocFx is installed, but the version is less than $DocFxVersion, will install it."
$InstallDocFx = $true
}

if ($InstallDocFx -eq $true) {
Write-Host "Installing docfx global tool..."
dotnet tool install -g docfx --version $DocFxVersion
else {
Write-Host "DocFx is installed and the version is $InstalledDocFxVersion."
}
} catch {
Write-Host "DocFx is not installed or not in the PATH, will install it."
$InstallDocFx = $true
}

if ($InstallDocFx -eq $true) {
Write-Host "Installing docfx global tool..."
dotnet tool install -g docfx --version $DocFxVersion
}

# delete anything that already exists
Expand Down
3 changes: 1 addition & 2 deletions websites/site/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@
"lucenetemplate"
],
"postProcessors": [],
"markdownEngineName": "markdig",
"noLangKeyword": false,
"keepFileLink": false,
"cleanupCacheHistory": false,
"disableGitFeatures": false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<meta name="generator" content="docfx {{_docfxVersion}}">
{{#_description}}<meta name="description" content="{{_description}}">{{/_description}}
<link rel="shortcut icon" href="{{_rel}}{{{_appFaviconPath}}}{{^_appFaviconPath}}favicon.ico{{/_appFaviconPath}}">
<link rel="stylesheet" href="{{_rel}}styles/docfx.vendor.css">
<link rel="stylesheet" href="{{_rel}}styles/docfx.vendor.min.css">
<link rel="stylesheet" href="{{_rel}}styles/docfx.css">
<link rel="stylesheet" href="{{_rel}}styles/main.css">
<meta property="docfx:navrel" content="{{_navRel}}">
Expand Down
2 changes: 1 addition & 1 deletion websites/site/lucenetemplate/partials/head.tmpl.partial
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<meta name="generator" content="docfx {{_docfxVersion}}">
{{#_description}}<meta name="description" content="{{_description}}">{{/_description}}
<link rel="shortcut icon" href="{{_rel}}{{{_appFaviconPath}}}{{^_appFaviconPath}}favicon.ico{{/_appFaviconPath}}">
<link rel="stylesheet" href="{{_rel}}styles/docfx.vendor.css">
<link rel="stylesheet" href="{{_rel}}styles/docfx.vendor.min.css">
<link rel="stylesheet" href="{{_rel}}styles/docfx.css">
<link rel="stylesheet" href="{{_rel}}styles/main.css">
<meta property="docfx:navrel" content="{{_navRel}}">
Expand Down
38 changes: 23 additions & 15 deletions websites/site/site.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ param (
$StagingPort = 8081
)

$DocFxVersion = "2.77.0" # Required DocFx version

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

$PSScriptFilePath = (Get-Item $MyInvocation.MyCommand.Path).FullName
Expand All @@ -43,21 +45,27 @@ if ($Clean) {
Remove-Item (Join-Path -Path $ToolsFolder "\*") -recurse -force -ErrorAction SilentlyContinue
}

New-Item "$ToolsFolder\tmp" -type directory -force
# install docfx tool
$InstallDocFx = $false
try {
$InstalledDocFxVersion = (& docfx --version).Trim().Split('+')[0]

# Go get docfx.exe if we don't have it
New-Item "$ToolsFolder\docfx" -type directory -force
$DocFxExe = "$ToolsFolder\docfx\docfx.exe"
if (-not (test-path $DocFxExe))
{
Write-Host "Retrieving docfx..."
$DocFxZip = "$ToolsFolder\tmp\docfx.zip"
Invoke-WebRequest "https://github.com/dotnet/docfx/releases/download/v2.58/docfx.zip" -OutFile $DocFxZip -TimeoutSec 60
#unzip
Expand-Archive $DocFxZip -DestinationPath (Join-Path -Path $ToolsFolder -ChildPath "docfx")
if ([version]$InstalledDocFxVersion -lt [version]$DocFxVersion) {
Write-Host "DocFx is installed, but the version is less than $DocFxVersion, will install it."
$InstallDocFx = $true
}
else {
Write-Host "DocFx is installed and the version is $InstalledDocFxVersion."
}
} catch {
Write-Host "DocFx is not installed or not in the PATH, will install it."
$InstallDocFx = $true
}

Remove-Item -Recurse -Force "$ToolsFolder\tmp"
if ($InstallDocFx -eq $true) {
Write-Host "Installing docfx global tool..."
dotnet tool install -g docfx --version $DocFxVersion
}

# delete anything that already exists
if ($Clean) {
Expand All @@ -75,11 +83,11 @@ if($?) {
if ($ServeDocs -eq $false) {
# build the output
Write-Host "Building docs..."
& $DocFxExe build $DocFxJson -l "$DocFxLog" --loglevel $LogLevel
& docfx build $DocFxJson -l "$DocFxLog" --logLevel $LogLevel
}
else {
# build + serve (for testing)
Write-Host "starting website..."
& $DocFxExe $DocFxJson --serve --port $StagingPort
& docfx $DocFxJson --serve --port $StagingPort
}
}
}

0 comments on commit e6c6742

Please sign in to comment.