From 69037510181bd28c2ee9ea6847276077ca559e94 Mon Sep 17 00:00:00 2001 From: "Jack He (Github)" Date: Tue, 10 Oct 2023 15:35:10 -0700 Subject: [PATCH] Add JIT compilation to replace relative path ../src with full URL to prepare for docfx (#3909) * update workflow to use main ref * opt for JIT compilation * update the correct env variable for docfx --------- Co-authored-by: Jack He --- .github/workflows/publish-docfx.yml | 8 +++++++- scripts/docfx-replace-url.ps1 | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 scripts/docfx-replace-url.ps1 diff --git a/.github/workflows/publish-docfx.yml b/.github/workflows/publish-docfx.yml index 890f7b5d3e..f3afb493fe 100644 --- a/.github/workflows/publish-docfx.yml +++ b/.github/workflows/publish-docfx.yml @@ -7,7 +7,7 @@ on: push: branches: ["main"] paths: ["docs/**", ".github/workflows/publish-docfx.yml"] - + pull_request: branches: ["main"] paths: ["docs/**", ".github/workflows/publish-docfx.yml"] @@ -42,6 +42,12 @@ jobs: - run: chmod +x ./scripts/generate-docfx-yml.ps1 - run: ./scripts/generate-docfx-yml.ps1 ./docs shell: pwsh + - run: chmod +x ./scripts/docfx-replace-url.ps1 + shell: pwsh + - run: ./scripts/docfx-replace-url.ps1 + shell: pwsh + - run: Set-Item -Path Env:DOCFX_SOURCE_BRANCH_NAME -Value 'main' + shell: pwsh - run: docfx docfx.json - run: chmod +x ./scripts/update-docfx-site.ps1 - name: Commit Changes diff --git a/scripts/docfx-replace-url.ps1 b/scripts/docfx-replace-url.ps1 new file mode 100644 index 0000000000..5f140783cd --- /dev/null +++ b/scripts/docfx-replace-url.ps1 @@ -0,0 +1,23 @@ +# Define the custom link to replace "../src" +$customLink = "https://github.com/microsoft/msquic/tree/main/src" + +# Get the directory of markdown files from the user input +$dir = "./docs" + +# Get all the markdown files in the directory +$files = Get-ChildItem -Path $dir -Filter *.md + +# Loop through each file +foreach ($file in $files) { + # Read the file content as a string + $content = Get-Content -Path $file.FullName -Raw + + # Replace all occurrences of "../src" with the custom link + $content = $content -replace "\.\./src", $customLink + + # Write the modified content back to the file + Set-Content -Path $file.FullName -Value $content +} + +# Write a message to indicate the completion of the task +Write-Host "All done!"