Created
February 15, 2013 16:01
-
-
Save fushnisoft/4961325 to your computer and use it in GitHub Desktop.
Extract rst formatted documentation blocks from clarion inc/clw files and process using Sphinx
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
cls | |
if ($args[0]) | |
{exit} | |
# NOTE: Make sure you have the PowerShell Community Extensions installed | |
# http://pscx.codeplex.com/ | |
Import-Module pscx | |
function ProcessFile($pSourceFile, $pOutputFile) { | |
Write-Host "Processing" $pSourceFile | |
[bool]$foundDocStart = $false | |
foreach ($line in Get-Content $pSourceFile) { | |
if ($line.Contains("Omit('!!!Docs!!!')")) { | |
$foundDocStart = $true | |
continue # Skip this line though, we will get the next one | |
} | |
elseif ($line.Contains("!!!Docs!!!")) { | |
$foundDocStart = $false | |
} | |
if ($foundDocStart -eq $false) { | |
continue | |
} | |
Add-Content $pOutputFile $line | |
} | |
Write-Host "Completed " $pOutputfile | |
} | |
# We assume we are going to process each inc/clw file in the current directory | |
$srcPath = (join-path -Path $(Get-Location) -ChildPath "_classes") | |
$dstPath = (join-path -Path $(Get-Location) -ChildPath "_docs\source") | |
get-childItem $srcPath -Include @("*.inc") -r | foreach-object { | |
$dstName = [io.path]::GetFileNameWithoutExtension($_.Name) | |
$dstFile = (Join-Path -Path $dstPath -ChildPath $($dstName + ".rst")) | |
Remove-Item $dstFile | |
# -ErrorAction SilentlyContinue | |
} | |
get-childItem $srcPath -Include @("*.inc", "*.clw") -r | Sort -Descending | foreach-object { | |
Write-Host "Source = " $_.FullName | |
$dstName = [io.path]::GetFileNameWithoutExtension($_.Name) | |
$dstFile = (Join-Path -Path $dstPath -ChildPath $($dstName + ".rst")) | |
Write-Host "Destination = " $dstFile | |
#Write-Host "Name = " $dstName | |
ProcessFile $_.FullName $dstFile | |
} | |
$originalPath = Get-Location | |
cd (join-path -Path $originalPath -ChildPath "_docs") | |
Invoke-BatchFile make html | |
cd $originalPath |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment