diff --git a/tools/Docs/Get-AllCommands/.gitignore b/tools/Docs/Get-AllCommands/.gitignore new file mode 100644 index 000000000000..9c9b9c274789 --- /dev/null +++ b/tools/Docs/Get-AllCommands/.gitignore @@ -0,0 +1,2 @@ +Output/ +Null/ diff --git a/tools/Docs/Get-AllCommands/Get-AllCommands.ps1 b/tools/Docs/Get-AllCommands/Get-AllCommands.ps1 new file mode 100644 index 000000000000..d5ad51294858 --- /dev/null +++ b/tools/Docs/Get-AllCommands/Get-AllCommands.ps1 @@ -0,0 +1,523 @@ +function Test-BuildMamlFolder { + + Param + ( + [CmdletBinding()] + [parameter(Mandatory=$true)] + [String] + $MamlFolderPath, + [parameter(Mandatory=$true)] + [String] + $ModuleName + ) + + #$MamlFolderPath = "\\srvua\PSPush2x\Main\DXPowerShellBlue\AGPM_Cmdlets\PSMAML\" + $MamlFileNames = (Get-ChildItem -Path $MamlFolderPath | WHERE { $_.Name -like "*.xml"}).Name + $CmdletCount = 0 + $ParmCount = 0 + $ShortDescCount = 0 + $LongDescCount = 0 + $HelpExCount = 0 + $InputObjectDesccount = 0 + $OutputObjectDesccount = 0 + $MissingContent = 0 + $OutArray = @() + + foreach ($MamlFile in $MamlFileNames) + { + $FullName = $MamlFolderPath + $MamlFile + [xml]$MamlXml = Get-Content $FullName + $CmdletCount += 1 + $WarnCount = 0 + $CmdletName = $MamlXml.command.details.name + $CmdletName = $CmdletName.Trim() + $ShortDescription = $MamlXml.command.details.description.para + + if ($ShortDescription.Length -gt 10 -and $ShortDescription) + { + $ShortDescCount += 1 + } + else + { + if (!$NoWarnings) + { + $OutArray += "No short description for $CmdletName." + $WarnCount += 1 + } + } + + # Long Description + # Updated for PS MAML Files + + $LongDescription = $MamlXml.command.description.para + + if ($LongDescription.Length -gt 10 -and $LongDescription) + { + $LongDescCount += 1 + } + else + { + if (!$NoWarnings) + { + $OutArray += "No long description for $CmdletName." + $WarnCount += 1 + } + + } + + # PS MAML Examples Count Check + #Updated for PS MAML Files + + $MamlExamples = $MamlXml.command.examples.example + + if($MamlExamples) + { + ForEach($Example in $MamlExamples) + { + $ExCount += 1 + if(!$Example.title) + { + $OutArray += "No example title found for an example in $CmdletName." + } + if(!$Example.introduction.para) + { + $OutArray += "No example introduction found for an example in $CmdletName." + } + if(!$Example.code) + { + $OutArray += "No example code found for an example in $CmdletName." + } + + } + } + else + { + $OutArray += "No examples found for $CmdletName." + } + + + #Cmdlet Input Object Description + #Updated for PS MAML Files + + $InputObjects = $MamlXml.command.inputTypes.inputType + if($InputObjects) + { + foreach($InputObj in $InputObjects) + { + $inputObjName = $InputObj.type.name + if ($inputObj.description.para.innertext) + { + $InputObjectDesccount += 1 + } + else + { + if (!$NoWarnings) + { + $OutArray += "No input object description for $inputObjName in $CmdletName" + $WarnCount += 1 + } + } + } + } + + #PS MAML Output Object Description + #Updated for PS MAML Files + $OutPutObjects = $MamlXml.command.returnValues.returnValue + if($OutPutObjects) + { + foreach($outputObj in $OutPutObjects) + { + $outputObjName = $outputObj.type.name + if ($outputObj.description.para.innertext) + { + $OutputObjectDesccount += 1 + } + else + { + if (!$NoWarnings) + { + $OutArray += "No output object description for $outputObjName in $CmdletName" + $WarnCount += 1 + } + } + } + } + # Parameter Descriptions + #Updated for PS MAML Files + $Parameters = $MamlXml.command.parameters.parameter + + foreach ($parm in $Parameters) + { + $ParmCount += 1 + $ParmName = $parm.Name + if ($parm.Description) + { + $ParmDescCount += 1 + } + else + { + if (!$NoWarnings) + { + $OutArray += "No parameter description for $CmdletName -$ParmName." + $WarnCount += 1 + } + } + } + #Evaluates Missing Elements + if ($WarnCount -ne 0) + { + $MissingContent +=1 + } + } + + if($MissingContent -gt 0) + { + $OutFileName = ($MamlFolderPath + " \..\..\..\" + $ModuleName + "_Report_MISSING_CONTENT.txt") + } + else + { + $OutFileName = ($MamlFolderPath + " \..\..\..\" + $ModuleName + "_Report.txt") + } + + + #Computation of Percentage Complete + $fShortDescPercent = "{0:P1}" -f ($ShortDescCount/$CmdletCount) + $fLongDescPercent = "{0:P1}" -f ($LongDescCount/$CmdletCount) + $fExPercent = "{0:P1}" -f ($ExCount/$CmdletCount) + $fParmDescPercent = "{0:P1}" -f ($ParmDescCount/$ParmCount) + $fMissingContentPercent = "{0:P1}" -f ($MissingContent/$CmdletCount) + $fInputObject = "{0:P1}" -f ($InputObjectDesccount/$CmdletCount) + $fOutputObjectDesc = "{0:P1}" -f ($OutputObjectDesccount/$CmdletCount) + + ###Report Output into PowerShell Host + #Header Message + $OutArray += "`nReport Summary" + $OutArray += "--------------" + $OutArray += "Folder Path: $MamlFolderPath" + $OutArray += "Commands: $CmdletCount" + $OutArray += "Parameters: $ParmCount" + + #Short Desc Message + $ShortDescMessage = "Short Descriptions: $ShortDescCount ( $fShortDescPercent )" + if($fShortDescPercent -eq '100.0 %'){ $OutArray += $ShortDescMessage } + else + { $OutArray += $ShortDescMessage } + + #Long Desc Message + $LongDescMessage = "Long Descriptions: $LongDescCount ( $fLongDescPercent )" + if($fLongDescPercent -eq '100.0 %'){$OutArray += "Long Descriptions: $LongDescCount ( $fLongDescPercent )" } + else + { $OutArray += $LongDescMessage } + + #Example Message + $ExamplesMessage = "Examples: $ExCount ( $fExPercent )" + if($fExPercent -eq '100.0 %'){$OutArray += $ExamplesMessage } + else + { $OutArray += $ExamplesMessage } + $OutArray += " Minimum Required: $CmdletCount" + + #Input Object Message + $InputObjectMessage = "Input Objects: $InputObjectDesccount ( $fInputObject )" + if($fInputObject -eq '100.0 %'){ $OutArray += $InputObjectMessage } + else + { $OutArray += $InputObjectMessage } + + #Output Object Message + $OutputObjectMessage = "Output Object: $OutputObjectDesccount ( $fOutputObjectDesc )" + if($fOutputObjectDesc -eq '100.0 %'){ $OutArray += $OutputObjectMessage } + else + { $OutArray += $OutputObjectMessage } + + #Parameter Messaage + $ParameterMessage = "Parameter Descriptions: $ParmDescCount ( $fParmDescPercent )" + if($fParmDescPercent -eq '100.0 %'){ $OutArray += $ParameterMessage } + else + { $OutArray += $ParameterMessage } + + #Error & Closing Message + $OutArray += "Number of cmdlets missing content: $MissingContent ( $fMissingContentPercent )" + $OutArray += "--------------" + $OutArray | Out-File -FilePath $OutFileName +} + +function Split-HelpFiles { + [Cmdletbinding()] + Param + ( + [parameter(Mandatory=$true)] + [String] + $InputXML, + + [parameter(Mandatory=$true)] + [String] + $OutputPath + ) + + $namespace = @{command="http://schemas.microsoft.com/maml/dev/command/2004/10"; maml="http://schemas.microsoft.com/maml/2004/10"; dev="http://schemas.microsoft.com/maml/dev/2004/10"} + + if (!(test-path $OutputPath)) { mkdir $OutputPath } + if (dir $InputXML | select-string " + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/Docs/Get-AllCommands/Templates/ProjectList.xml b/tools/Docs/Get-AllCommands/Templates/ProjectList.xml new file mode 100644 index 000000000000..9954fa5f14f1 --- /dev/null +++ b/tools/Docs/Get-AllCommands/Templates/ProjectList.xml @@ -0,0 +1,4 @@ + + + +