Skip to content

Commit

Permalink
Add JIT compilation to replace relative path ../src with full URL to …
Browse files Browse the repository at this point in the history
…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 <[email protected]>
  • Loading branch information
ProjectsByJackHe and ProjectsByJackHe authored Oct 10, 2023
1 parent f54cf5a commit 6903751
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .github/workflows/publish-docfx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions scripts/docfx-replace-url.ps1
Original file line number Diff line number Diff line change
@@ -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!"

0 comments on commit 6903751

Please sign in to comment.