diff --git a/eng/docgeneration/docfx.json b/eng/docgeneration/docfx.json new file mode 100644 index 000000000000..ddd8412e7b79 --- /dev/null +++ b/eng/docgeneration/docfx.json @@ -0,0 +1,72 @@ +{ + "metadata": [ + { + "src": [ + { + "files": [ + "src/**.csproj" + ] + } + ], + "dest": "api", + "disableGitFeatures": false, + "disableDefaultFilter": false + } + ], + "build": { + "content": [ + { + "files": [ + "api/**.yml", + "api/**.md", + "api/index.md" + ] + }, + { + "files": [ + "toc.yml", + "*.md" + ] + } + ], + "resource": [ + { + "files": [ + "images/**" + ] + } + ], + "overwrite": [ + { + "files": [ + "apidoc/**.md" + ], + "exclude": [ + "obj/**", + "_site/**" + ] + } + ], + "dest": "_site", + "globalMetadataFiles": [], + "fileMetadataFiles": [], + "template": [ + "default", + "templates/matthews" + ], + "postProcessors": [], + "markdownEngineName": "markdig", + "noLangKeyword": false, + "keepFileLink": false, + "cleanupCacheHistory": false, + "disableGitFeatures": false, + "globalMetadata": { + "_appTitle": "Azure SDK for NET", + "_appFooter": "Azure SDK for Net", + "_enableSearch": false, + "_enableNewTab": true, + "_appFaviconPath": "https://c.s-microsoft.com/favicon.ico?v2", + "_disableContribution": true + } + } +} \ No newline at end of file diff --git a/eng/docgeneration/docindex.yml b/eng/docgeneration/docindex.yml new file mode 100644 index 000000000000..76f26eac69ee --- /dev/null +++ b/eng/docgeneration/docindex.yml @@ -0,0 +1,125 @@ +resources: + repositories: + - repository: azure-sdk-tools + type: github + name: azure/azure-sdk-tools + endpoint: azure + +jobs: + - job: GenerateDocIndex + variables: + - template: ../pipelines/templates/variables/globals.yml + pool: + vmImage: windows-2019 + steps: + - pwsh: | + Invoke-WebRequest -Uri "https://github.com/dotnet/docfx/releases/download/v2.43.2/docfx.zip" ` + -OutFile "docfx.zip" | Wait-Process; Expand-Archive -Path "docfx.zip" -DestinationPath "./docfx/" + workingDirectory: $(Build.BinariesDirectory) + displayName: Download and Extract DocFX + - task: CmdLine@2 + displayName: Provision DocFX Directory + inputs: + script: $(Build.BinariesDirectory)/docfx/docfx.exe init -q + workingDirectory: $(Build.SourcesDirectory) + failOnStderr: true + - pwsh: New-Item -Path . -Name "templates" -ItemType "directory" + displayName: Create Template Directory + workingDirectory: $(Build.SourcesDirectory)/docfx_project/ + - task: CopyFiles@2 + displayName: Copy Template to templates folder + inputs: + sourceFolder: $(Build.SourcesDirectory)/eng/docgeneration/templates + content: '**\*' + targetFolder: $(Build.SourcesDirectory)/docfx_project/templates + overWrite: true + - pwsh: ls + workingDirectory: $(Build.SourcesDirectory)/docfx_project/ + - pwsh: ls + workingDirectory: $(Build.SourcesDirectory)/docfx_project/templates + - pwsh: | + Copy-Item "$(Build.SourcesDirectory)/eng/docgeneration/docfx.json" -Destination "$(Build.SourcesDirectory)/docfx_project/" -Force + displayName: Copy over docfx.json + - pwsh: | + $ServiceList = Get-ChildItem "$(Build.SourcesDirectory)/sdk" -Directory -Exclude eng, mgmtcommon, template | Sort-Object + $YmlPath = "$(Build.SourcesDirectory)/docfx_project/api" + New-Item -Path $YmlPath -Name "toc.yml" -Force + foreach ($Dir in $ServiceList) + { + New-Item -Path $YmlPath -Name "$($Dir.Name).md" -Force + Write-Host "Write to Toc.yml" + Add-Content -Path "$($YmlPath)/toc.yml" -Value "- name: $($Dir.Name.ToUpper())`r`n href: $($Dir.Name).md" + Write-Host "Write Client Header" + $PkgList = Get-ChildItem $Dir.FullName -Directory -Exclude .vs, .vscode, Azure.Security.KeyVault.Shared | Where-Object -FilterScript {$_.Name -notmatch ".Management."} + if (($PkgList | Measure-Object).count -eq 0) + { + continue + } + Add-Content -Path "$($YmlPath)/$($Dir.Name).md" -Value "# CLIENT" + Add-Content -Path "$($YmlPath)/$($Dir.Name).md" -Value "---" + foreach ($Pkg in $PkgList) + { + if (Test-Path "$($pkg.FullName)\src") + { + $ProjectName = Get-ChildItem "$($pkg.FullName)\src\*" -Include *.csproj + Write-Host "Write $($ProjectName.Name)" + Add-Content -Path "$($YmlPath)/$($Dir.Name).md" -Value "#### $($ProjectName.BaseName)" + } + } + } + foreach ($Dir in $ServiceList) + { + Write-Host "Write Mgmt Header" + $PkgList = Get-ChildItem $Dir.FullName -Directory | Where-Object -FilterScript {$_.Name -match ".Management."} + if (($PkgList | Measure-Object).count -eq 0) + { + continue + } + Add-Content -Path "$($YmlPath)/$($Dir.Name).md" -Value "# MANAGEMENT" + Add-Content -Path "$($YmlPath)/$($Dir.Name).md" -Value "---" + foreach ($Pkg in $PkgList) + { + if (Test-Path "$($pkg.FullName)\src") + { + $ProjectName = Get-ChildItem "$($pkg.FullName)\src\*" -Include *.csproj + Write-Host "Write $($ProjectName.Name)" + Add-Content -Path "$($YmlPath)/$($Dir.Name).md" -Value "#### $($ProjectName.BaseName)" + } + } + } + New-Item -Path "$(Build.SourcesDirectory)/docfx_project" -Name "toc.yml" -Force + Add-Content -Path "$(Build.SourcesDirectory)/docfx_project/toc.yml" -Value "- name: Azure SDK for NET APIs`r`n href: api/`r`n homepage: api/index.md" + Copy-Item "$(Build.SourcesDirectory)/README.md" -Destination "$(Build.SourcesDirectory)/docfx_project/api/index.md" -Force + Copy-Item "$(Build.SourcesDirectory)/*.md" -Destination "$(Build.SourcesDirectory)/docfx_project/api" -Force + displayName: Create main index and navigation toc.yml, copy over readme. + - pwsh: ls + workingDirectory: $(Build.SourcesDirectory)/docfx_project/api + - task: CmdLine@2 + displayName: Build Doc Content + inputs: + script: $(Build.BinariesDirectory)/docfx/docfx.exe build + workingDirectory: $(Build.SourcesDirectory)/docfx_project/ + failOnStderr: true + - pwsh: | + Copy-Item "$(Build.SourcesDirectory)/eng/docgeneration/assets/logo.svg" -Destination "$(Build.SourcesDirectory)/docfx_project/_site/" -Force + Copy-Item "$(Build.SourcesDirectory)/eng/docgeneration/assets/toc.yml" -Destination "$(Build.SourcesDirectory)/docfx_project/_site/" -Force + displayName: Replace site assets + - task: UsePythonVersion@0 + displayName: 'Use Python 3.6' + inputs: + versionSpec: '3.6' + - template: eng/pipelines/templates/scripts/mashup-doc-index.yml@azure-sdk-tools + parameters: + SourceDirectory: $(Build.SourcesDirectory) + - task: CopyFiles@2 + displayName: Copy HTML to Artifacts Directory + inputs: + sourceFolder: $(Build.SourcesDirectory)/docfx_project/ + content: '**\*' + targetFolder: $(Build.ArtifactStagingDirectory)/docfx_project + overWrite: true + - task: PublishPipelineArtifact@0 + condition: succeeded() + inputs: + artifactName: "Doc.Index" + targetPath: $(Build.ArtifactStagingDirectory)/docfx_project/_site \ No newline at end of file