-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: Remove REPL prompts (>>>) from documentation
- Loading branch information
Showing
1 changed file
with
12 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,20 @@ | ||
# Define the directories to search | ||
$directories = @("docs/guides", "docs/migration-guides") | ||
|
||
# Define the search pattern and replacement text | ||
$searchPattern = ">>> " | ||
$replacementText = "print(" | ||
# Define the search pattern and replacement format | ||
$searchPattern = ">>> (.+)" | ||
$replacementText = "print(`$1)" | ||
|
||
# Loop through each directory and process the files | ||
foreach ($directory in $directories) { | ||
Get-ChildItem -Path $directory -Recurse -File | ForEach-Object { | ||
(Get-Content -Path $_.FullName) -replace [regex]::Escape($searchPattern), $replacementText | Set-Content -Path $_.FullName | ||
# Read file content | ||
$content = Get-Content -Path $_.FullName | ||
|
||
# Replace occurrences of >>> with print() | ||
$newContent = $content -replace $searchPattern, $replacementText | ||
|
||
# Write back the modified content | ||
$newContent | Set-Content -Path $_.FullName | ||
} | ||
} | ||
} |