Initial Commit
This commit is contained in:
194
helpers/psDoc-master/src/out-confluence-markup-template.ps1
Normal file
194
helpers/psDoc-master/src/out-confluence-markup-template.ps1
Normal file
@@ -0,0 +1,194 @@
|
||||
function TrimAllLines([string] $str) {
|
||||
$lines = $str -split "`n"
|
||||
|
||||
for ($i = 0; $i -lt $lines.Count; $i++) {
|
||||
$lines[$i] = $lines[$i].Trim()
|
||||
}
|
||||
|
||||
# Trim EOL.
|
||||
($lines | Out-String).Trim()
|
||||
}
|
||||
|
||||
function FixMarkdownString([string] $in = '', [bool] $includeBreaks = $false, [bool]$BlankStringToSpace = $False) {
|
||||
|
||||
if ($in -eq $null) { return }
|
||||
|
||||
if($in -eq "" -and $BlankStringToSpace ) { return " " }
|
||||
|
||||
$replacements = @{
|
||||
'\' = '\\'
|
||||
'`' = '\`'
|
||||
'*' = '\*'
|
||||
'_' = '\_'
|
||||
'{' = '\{'
|
||||
'}' = '\}'
|
||||
'[' = '\['
|
||||
']' = '\]'
|
||||
'(' = '\('
|
||||
')' = '\)'
|
||||
'#' = '\#'
|
||||
'+' = '\+'
|
||||
'!' = '\!'
|
||||
}
|
||||
|
||||
$rtn = $in.Trim()
|
||||
foreach ($key in $replacements.Keys) {
|
||||
$rtn = $rtn.Replace($key, $replacements[$key])
|
||||
}
|
||||
|
||||
$rtn = TrimAllLines $rtn
|
||||
|
||||
if ($includeBreaks) {
|
||||
$crlf = [Environment]::NewLine
|
||||
$rtn = $rtn.Replace($crlf, " $crlf")
|
||||
}
|
||||
$rtn
|
||||
}
|
||||
|
||||
function FixMarkdownCodeString([string] $in) {
|
||||
if ($in -eq $null) { return }
|
||||
|
||||
TrimAllLines $in
|
||||
}
|
||||
|
||||
function IncludeTableOfContents {
|
||||
|
||||
return "{toc:printable=true|style=square|maxLevel=2|indent=5px|minLevel=2|class=bigpink|exclude=[1//2]|type=list|outline=true|include=.*}"
|
||||
}
|
||||
|
||||
|
||||
@"
|
||||
h1. $moduleName
|
||||
|
||||
$(IncludeTableOfContents)
|
||||
|
||||
\\
|
||||
\\
|
||||
"@
|
||||
|
||||
|
||||
$progress = 0
|
||||
$commandsHelp | % {
|
||||
Update-Progress $_.Name 'Documentation'
|
||||
$progress++
|
||||
@"
|
||||
h2. $(FixMarkdownString($_.Name))
|
||||
"@
|
||||
$synopsis = $_.synopsis.Trim()
|
||||
$syntax = $_.syntax | out-string
|
||||
if(-not ($synopsis -ilike "$($_.Name.Trim())*")){
|
||||
$tmp = $synopsis
|
||||
$synopsis = $syntax
|
||||
$syntax = $tmp
|
||||
@"
|
||||
h3. Synopsis
|
||||
$(FixMarkdownString($syntax))
|
||||
"@
|
||||
}
|
||||
|
||||
|
||||
@"
|
||||
h3. Description
|
||||
$(FixMarkdownString $(($_.Description | out-string).Trim()) $true)
|
||||
"@
|
||||
|
||||
@"
|
||||
h3. Syntax
|
||||
{code:theme=Confluence|linenumbers=false|language=Powershell|firstline=0001|collapse=false}
|
||||
$(TrimAllLines $synopsis)
|
||||
{code}
|
||||
"@
|
||||
|
||||
if (!($_.alias.Length -eq 0)) {
|
||||
@"
|
||||
h3. $($_.Name) Aliases
|
||||
"@
|
||||
$_.alias | % {
|
||||
@"
|
||||
- $($_.Name)
|
||||
"@
|
||||
}
|
||||
@"
|
||||
|
||||
"@
|
||||
}
|
||||
|
||||
if($_.parameters){
|
||||
@"
|
||||
h3. Parameters
|
||||
|
||||
||Name||Alias||Description||Required?||Pipeline Input||Default Value||
|
||||
"@
|
||||
$_.parameters.parameter | % {
|
||||
@"
|
||||
|$(FixMarkdownString $_.Name $false $true)|$(FixMarkdownString $_.Aliases $false $true)|$(FixMarkdownString $($_.Description | out-string).Trim() $true $true)|$(FixMarkdownString $_.Required $false $true)|$(FixMarkdownString $_.PipelineInput $false $true)|$(FixMarkdownString $_.DefaultValue $false $true)|
|
||||
"@
|
||||
}
|
||||
@"
|
||||
|
||||
|
||||
"@
|
||||
}
|
||||
$inputTypes = $(FixMarkdownString($_.inputTypes | out-string))
|
||||
if ($inputTypes.Length -gt 0 -and -not $inputTypes.Contains('inputType')) {
|
||||
@"
|
||||
h3. Inputs
|
||||
- $inputTypes
|
||||
|
||||
"@
|
||||
}
|
||||
$returnValues = $(FixMarkdownString($_.returnValues | out-string))
|
||||
if ($returnValues.Length -gt 0 -and -not $returnValues.StartsWith("returnValue")) {
|
||||
@"
|
||||
h3. Outputs
|
||||
- $returnValues
|
||||
|
||||
"@
|
||||
}
|
||||
$notes = $(FixMarkdownString($_.alertSet | out-string))
|
||||
if ($notes.Trim().Length -gt 0) {
|
||||
@"
|
||||
h3. Note
|
||||
$notes
|
||||
|
||||
"@
|
||||
}
|
||||
if(($_.examples | Out-String).Trim().Length -gt 0) {
|
||||
@"
|
||||
h3. Examples
|
||||
"@
|
||||
$_.examples.example | % {
|
||||
@"
|
||||
{code:title=$(FixMarkdownString($_.title.Trim(('-',' '))))|theme=Confluence|linenumbers=true|language=Powershell|firstline=0001|collapse=false}
|
||||
$(FixMarkdownCodeString($_.code | out-string ))
|
||||
{code}
|
||||
|
||||
$(FixMarkdownString($_.remarks | out-string ) $true)
|
||||
"@
|
||||
}
|
||||
}
|
||||
if(($_.relatedLinks | Out-String).Trim().Length -gt 0) {
|
||||
@"
|
||||
h3. Links
|
||||
|
||||
"@
|
||||
$_.links | % {
|
||||
@"
|
||||
- [$($_.name)|$($_.link)]
|
||||
"@
|
||||
}
|
||||
}
|
||||
|
||||
@"
|
||||
|
||||
\\
|
||||
\\
|
||||
\\
|
||||
----
|
||||
\\
|
||||
\\
|
||||
\\
|
||||
|
||||
"@
|
||||
|
||||
}
|
346
helpers/psDoc-master/src/out-html-template.ps1
Normal file
346
helpers/psDoc-master/src/out-html-template.ps1
Normal file
@@ -0,0 +1,346 @@
|
||||
@"
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
<auto-generated>
|
||||
<synopsis>
|
||||
This code was generated by a tool. on: $(Get-Date)
|
||||
</synopsis>
|
||||
<description>
|
||||
If you'd like to regenerate the documentation, please open up powershell and run
|
||||
|
||||
> .\psDoc.ps1 -moduleName NameOfYourModule
|
||||
|
||||
If the documentation is incomplete, or eronious,
|
||||
please edit the comments at the top of the module method within it's respecive .ps1 file.
|
||||
</description>
|
||||
</auto-generated>
|
||||
-->
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>$moduleName Documentation</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/styles/shCore.min.css" rel="stylesheet" charset="utf-8">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/styles/shCoreDefault.min.css" rel="stylesheet" charset="utf-8">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" charset="utf-8">
|
||||
|
||||
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
||||
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
<style>
|
||||
.syntaxhighlighter {
|
||||
overflow-y: hidden !important;
|
||||
overflow-x: auto !important;
|
||||
}
|
||||
pre {
|
||||
min-height: 30px;
|
||||
}
|
||||
.navbar-nav {
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.form-group {
|
||||
padding-top: 12px;
|
||||
padding-left: 12px;
|
||||
padding-right: 12px;
|
||||
}
|
||||
.sidebar-nav .navbar-header {
|
||||
float: none;
|
||||
}
|
||||
.sidebar-nav .navbar li a {
|
||||
padding-top: 4px;
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
@media (min-width: 768px) {
|
||||
.sidebar-nav .navbar .navbar-collapse {
|
||||
padding: 0;
|
||||
max-height: none;
|
||||
}
|
||||
.sidebar-nav .navbar ul {
|
||||
float: none;
|
||||
}
|
||||
.sidebar-nav .navbar ul:not {
|
||||
display: block;
|
||||
}
|
||||
.sidebar-nav .navbar li {
|
||||
float: none;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div><h1>$moduleName</h1></div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="col-lg-3 col-md-4 col-sm-5 col-xs-12">
|
||||
<div class="sidebar-nav">
|
||||
<div class="navbar navbar-default" role="navigation">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-navbar-collapse">
|
||||
<span class="sr-only">Toggle</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="visible-xs navbar-brand">click menu to open</span>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse sidebar-navbar-collapse">
|
||||
|
||||
<div class="form-group">
|
||||
<input class="form-control" id="searchinput" type="search" placeholder="Filter..." />
|
||||
</div>
|
||||
|
||||
<ul class="nav navbar-nav list-group" id="searchList">
|
||||
"@
|
||||
$progress = 0
|
||||
$commandsHelp | % {
|
||||
Update-Progress $_.Name 'Navigation'
|
||||
$progress++
|
||||
" <li class=`"nav-menu list-group-item`"><a href=`"#$($_.Name)`">$($_.Name)</a></li>"
|
||||
}
|
||||
@'
|
||||
</ul>
|
||||
</div><!--/.nav-collapse -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-9 col-md-8 col-sm-7 col-xs-12">
|
||||
'@
|
||||
$progress = 0
|
||||
$commandsHelp | % {
|
||||
Update-Progress $_.Name 'Documentation'
|
||||
$progress++
|
||||
@"
|
||||
<div id=`"$(FixString($_.Name))`" class="toggle_container">
|
||||
<div class="page-header">
|
||||
<h2> $(FixString($_.Name)) </h2>
|
||||
"@
|
||||
$syn = FixString($_.synopsis)
|
||||
if(!($syn).StartsWith($(FixString($_.Name)))){
|
||||
@"
|
||||
<p>$syn</p>
|
||||
<p>$(FixString(($_.Description | out-string).Trim()) $true)</p>
|
||||
"@
|
||||
}
|
||||
@"
|
||||
</div>
|
||||
"@
|
||||
if (!($_.alias.Length -eq 0)) {
|
||||
@"
|
||||
<div class='panel panel-default'>
|
||||
<div class='panel-heading'>
|
||||
<h3 class='panel-title'> $($_.Name) Aliases </h3>
|
||||
</div>
|
||||
<div class='panel-body'>
|
||||
<ul>
|
||||
"@
|
||||
$_.alias | % {
|
||||
@"
|
||||
<li>$($_.Name)</li>
|
||||
"@
|
||||
}
|
||||
@"
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
"@
|
||||
}
|
||||
if (!($_.syntax | Out-String ).Trim().Contains('syntaxItem')) {
|
||||
@"
|
||||
<div>
|
||||
<h3> Syntax </h3>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class='panel-body'>
|
||||
<pre class="brush: ps">$(FixString($_.syntax | out-string))</pre>
|
||||
</div>
|
||||
</div>
|
||||
"@
|
||||
}
|
||||
if($_.parameters){
|
||||
@"
|
||||
<div>
|
||||
<h3> Parameters </h3>
|
||||
<table class="table table-striped table-bordered table-condensed visible-on">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th class="visible-lg visible-md">Alias</th>
|
||||
<th>Description</th>
|
||||
<th class="visible-lg visible-md">Required?</th>
|
||||
<th class="visible-lg">Pipeline Input</th>
|
||||
<th class="visible-lg">Default Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
"@
|
||||
$_.parameters.parameter | % {
|
||||
@"
|
||||
<tr>
|
||||
<td><nobr>-$(FixString($_.Name))</nobr></td>
|
||||
<td class="visible-lg visible-md">$(FixString($_.Aliases))</td>
|
||||
<td>$(FixString(($_.Description | out-string).Trim()) $true)</td>
|
||||
<td class="visible-lg visible-md">$(FixString($_.Required))</td>
|
||||
<td class="visible-lg">$(FixString($_.PipelineInput))</td>
|
||||
<td class="visible-lg">$(FixString($_.DefaultValue))</td>
|
||||
</tr>
|
||||
"@
|
||||
}
|
||||
@"
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
"@
|
||||
}
|
||||
$inputTypes = $(FixString($_.inputTypes | out-string))
|
||||
if ($inputTypes.Length -gt 0 -and -not $inputTypes.Contains('inputType')) {
|
||||
@"
|
||||
<div>
|
||||
<h3> Inputs </h3>
|
||||
<p>The input type is the type of the objects that you can pipe to the cmdlet.</p>
|
||||
<ul><li>$inputTypes</li></ul>
|
||||
</div>
|
||||
"@
|
||||
}
|
||||
$returnValues = $(FixString($_.returnValues | out-string))
|
||||
if ($returnValues.Length -gt 0 -and -not $returnValues.StartsWith("returnValue")) {
|
||||
@"
|
||||
<div>
|
||||
<h3> Outputs </h3>
|
||||
<p>The output type is the type of the objects that the cmdlet emits.</p>
|
||||
<ul><li>$returnValues</li></ul>
|
||||
</div>
|
||||
"@
|
||||
}
|
||||
$notes = $(FixString($_.alertSet | out-string))
|
||||
if ($notes.Trim().Length -gt 0) {
|
||||
@"
|
||||
<div class='panel panel-default'>
|
||||
<div class='panel-heading'>
|
||||
<h3 class='panel-title'> Note </h3>
|
||||
</div>
|
||||
<div class='panel-body'>$notes</div>
|
||||
</div>
|
||||
"@
|
||||
}
|
||||
if(($_.examples | Out-String).Trim().Length -gt 0) {
|
||||
@"
|
||||
<div>
|
||||
<h3> Examples </h3>
|
||||
</div>
|
||||
<div class='panel panel-default'>
|
||||
<div class='panel-body'>
|
||||
"@
|
||||
$_.examples.example | % {
|
||||
@"
|
||||
<strong>$(FixString($_.title.Trim(('-',' '))))</strong>
|
||||
<pre class="brush: ps">$(FixString($_.code | out-string ).Trim())</pre>
|
||||
<div>$(FixString($_.remarks | out-string ).Trim())</div>
|
||||
"@
|
||||
}
|
||||
@"
|
||||
</div>
|
||||
</div>
|
||||
<p class='pull-right'><a onclick='document.body.scrollTop = document.documentElement.scrollTop = 0;' style='cursor: pointer;'>Top of page</a>
|
||||
"@
|
||||
}
|
||||
if(($_.relatedLinks | Out-String).Trim().Length -gt 0) {
|
||||
@"
|
||||
<div>
|
||||
<h3> Links </h3>
|
||||
<div>
|
||||
<ul>
|
||||
"@
|
||||
$_.links | % {
|
||||
@"
|
||||
<li class='$($_.cssClass)'><a href='$($_.link)' target='$($_.target)'>$($_.name)</a></li>
|
||||
"@
|
||||
}
|
||||
@"
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
"@
|
||||
}
|
||||
@"
|
||||
</div>
|
||||
"@
|
||||
}
|
||||
@'
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js" ></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/js/bootstrap.min.js" charset="utf-8"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shCore.min.js" charset="utf-8"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/scripts/shBrushPowerShell.min.js" charset="utf-8"></script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$(".toggle_container").hide();
|
||||
var previousId;
|
||||
if(location.hash) {
|
||||
var id = location.hash.slice(1); //Get rid of the # mark
|
||||
var elementToShow = $("#" + id); //Save local reference
|
||||
if(elementToShow.length) { //Check if the element exists
|
||||
elementToShow.slideToggle('fast'); //Show the element
|
||||
elementToShow.addClass("check_list_selected"); //Add class to element (the link)
|
||||
}
|
||||
previousId = id;
|
||||
}
|
||||
|
||||
$('.nav-menu a, .psLink a').click(function() {
|
||||
$(".sidebar-navbar-collapse").collapse('hide');
|
||||
$('.toggle_container').hide(); // Hide all
|
||||
var elem = $(this).prop("hash");
|
||||
$(elem).toggle('fast'); // Show HREF/to/ID one
|
||||
history.pushState({}, '', $(this).attr("href"));
|
||||
window.scrollTo(0, 0);
|
||||
return false;
|
||||
});
|
||||
SyntaxHighlighter.defaults['toolbar'] = false;
|
||||
SyntaxHighlighter.defaults['gutter'] = false;
|
||||
SyntaxHighlighter.all();
|
||||
|
||||
$('#searchList').btsListFilter('#searchinput', {itemChild: 'a', initial: false, resetOnBlur: true});
|
||||
|
||||
$(document).keyup(function( e ) {
|
||||
if(!$('#searchinput').is(':focus') && e.which >= 65 && e.which <= 90 ){
|
||||
$('#searchinput').val(String.fromCharCode(e.keyCode));
|
||||
$('#searchinput').focus();
|
||||
}
|
||||
});
|
||||
$(document).click(function() {
|
||||
$('#searchinput').blur();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!-- bootstrap-list-filter.min.js - removed as external resource and added as content -->
|
||||
<script>
|
||||
/*
|
||||
* bootstrap-list-filter v0.1.7 - 2015-03-30
|
||||
*
|
||||
* Copyright 2015 Stefano Cudini
|
||||
* stefano.cudini@gmail.com
|
||||
* http://labs.easyblog.it/
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
*
|
||||
* Demos:
|
||||
* http://labs.easyblog.it/bootstrap-list-filter/
|
||||
*
|
||||
* Source:
|
||||
* git@github.com:stefanocudini/bootstrap-list-filter.git
|
||||
*
|
||||
*/
|
||||
!function(a){a.fn.btsListFilter=function(b,c){function d(a,b){return a.replace(/\{ *([\w_]+) *\}/g,function(a,c){return b[c]||""})}function e(a,b){var c;return b=b||300,function(){var d=this,e=arguments;clearTimeout(c),c=setTimeout(function(){a.apply(d,Array.prototype.slice.call(e))},b)}}var f,g=this,h=a(this),i=a(b),j=h;return c=a.extend({delay:300,minLength:1,initial:!0,eventKey:"keyup",resetOnBlur:!0,sourceData:null,sourceTmpl:'<a class="list-group-item" href="#"><span>{title}</span></a>',sourceNode:function(a){return d(c.sourceTmpl,a)},emptyNode:function(){return'<a class="list-group-item well" href="#"><span>No Results</span></a>'},itemEl:".list-group-item",itemChild:null,itemFilter:function(b,d){d=d&&d.replace(new RegExp("[({[^.$*+?\\]})]","g"),"");var e=a(b).text(),f=c.initial?"^":"",g=new RegExp(f+d,"i");return g.test(e)}},c),i.on(c.eventKey,e(function(){var b=a(this).val();c.itemEl&&(j=h.find(c.itemEl)),c.itemChild&&(j=j.find(c.itemChild));var d=j.filter(function(){return c.itemFilter.call(g,this,b)}),e=j.not(d);c.itemChild&&(d=d.parents(c.itemEl),e=e.parents(c.itemEl).hide()),""!==b&&b.length>=c.minLength?(d.show(),e.hide(),"function"===a.type(c.sourceData)?(d.hide(),e.hide(),f&&(a.isFunction(f.abort)?f.abort():a.isFunction(f.stop)&&f.stop()),f=c.sourceData.call(g,b,function(b){if(f=null,d.hide(),e.hide(),h.find(".bts-dynamic-item").remove(),b&&0!==b.length)for(var i in b)a(c.sourceNode.call(g,b[i])).addClass("bts-dynamic-item").appendTo(h);else a(c.emptyNode.call(g)).addClass("bts-dynamic-item").appendTo(h)})):0===d.length&&a(c.emptyNode.call(g)).addClass("bts-dynamic-item").appendTo(h)):(d.show(),e.show(),h.find(".bts-dynamic-item").remove())},c.delay)),c.resetOnBlur&&i.on("blur",function(){a(this).val("").trigger(c.eventKey)}),h}}(jQuery);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
'@
|
159
helpers/psDoc-master/src/out-markdown-template.ps1
Normal file
159
helpers/psDoc-master/src/out-markdown-template.ps1
Normal file
@@ -0,0 +1,159 @@
|
||||
function TrimAllLines([string] $str) {
|
||||
$lines = $str -split "`n"
|
||||
|
||||
for ($i = 0; $i -lt $lines.Count; $i++) {
|
||||
$lines[$i] = $lines[$i].Trim()
|
||||
}
|
||||
|
||||
# Trim EOL.
|
||||
($lines | Out-String).Trim()
|
||||
}
|
||||
|
||||
function FixMarkdownString([string] $in = '', [bool] $includeBreaks = $false) {
|
||||
if ($in -eq $null) { return }
|
||||
|
||||
$replacements = @{
|
||||
'\' = '\\'
|
||||
'`' = '\`'
|
||||
'*' = '\*'
|
||||
'_' = '\_'
|
||||
'{' = '\{'
|
||||
'}' = '\}'
|
||||
'[' = '\['
|
||||
']' = '\]'
|
||||
'(' = '\('
|
||||
')' = '\)'
|
||||
'#' = '\#'
|
||||
'+' = '\+'
|
||||
'!' = '\!'
|
||||
'<' = '\<'
|
||||
'>' = '\>'
|
||||
}
|
||||
|
||||
$rtn = $in.Trim()
|
||||
foreach ($key in $replacements.Keys) {
|
||||
$rtn = $rtn.Replace($key, $replacements[$key])
|
||||
}
|
||||
|
||||
$rtn = TrimAllLines $rtn
|
||||
$crlf = [Environment]::NewLine
|
||||
if ($includeBreaks) {
|
||||
$rtn = $rtn.Replace($crlf, " $crlf")
|
||||
}
|
||||
else {
|
||||
$rtn = $rtn.Replace($crlf, " ").Trim()
|
||||
}
|
||||
$rtn
|
||||
}
|
||||
|
||||
function FixMarkdownCodeString([string] $in) {
|
||||
if ($in -eq $null) { return }
|
||||
|
||||
TrimAllLines $in
|
||||
}
|
||||
|
||||
@"
|
||||
# $moduleName Module
|
||||
"@
|
||||
$progress = 0
|
||||
$commandsHelp | % {
|
||||
Update-Progress $_.Name 'Documentation'
|
||||
$progress++
|
||||
@"
|
||||
## $(FixMarkdownString($_.Name))
|
||||
"@
|
||||
$synopsis = $_.synopsis.Trim()
|
||||
$syntax = $_.syntax | out-string
|
||||
if (-not ($synopsis -ilike "$($_.Name.Trim())*")) {
|
||||
$tmp = $synopsis
|
||||
$synopsis = $syntax
|
||||
$syntax = $tmp
|
||||
@"
|
||||
### Synopsis
|
||||
$(FixMarkdownString($syntax))
|
||||
"@
|
||||
}
|
||||
@"
|
||||
### Syntax
|
||||
``````powershell
|
||||
$($synopsis)
|
||||
``````
|
||||
"@
|
||||
|
||||
if (!($_.alias.Length -eq 0)) {
|
||||
@"
|
||||
### $($_.Name) Aliases
|
||||
"@
|
||||
$_.alias | % {
|
||||
@"
|
||||
- $($_.Name)
|
||||
"@
|
||||
}
|
||||
@"
|
||||
|
||||
"@
|
||||
}
|
||||
|
||||
if ($_.parameters) {
|
||||
@"
|
||||
### Parameters
|
||||
| Name | Alias | Description | Required? | Pipeline Input | Default Value |
|
||||
| - | - | - | - | - | - |
|
||||
"@
|
||||
$_.parameters.parameter | % {
|
||||
@"
|
||||
| <nobr>$(FixMarkdownString($_.Name))</nobr> | $(FixMarkdownString($_.Aliases)) | $(FixMarkdownString(($_.Description | out-string).Trim())) | $(FixMarkdownString($_.Required)) | $(FixMarkdownString($_.PipelineInput)) | $(FixMarkdownString($_.DefaultValue)) |
|
||||
"@
|
||||
}
|
||||
}
|
||||
$inputTypes = $(FixMarkdownString($_.inputTypes | out-string))
|
||||
if ($inputTypes.Length -gt 0 -and -not $inputTypes.Contains('inputType')) {
|
||||
@"
|
||||
### Inputs
|
||||
- $inputTypes
|
||||
|
||||
"@
|
||||
}
|
||||
$returnValues = $(FixMarkdownString($_.returnValues | out-string))
|
||||
if ($returnValues.Length -gt 0 -and -not $returnValues.StartsWith("returnValue")) {
|
||||
@"
|
||||
### Outputs
|
||||
- $returnValues
|
||||
|
||||
"@
|
||||
}
|
||||
$notes = $(FixMarkdownString($_.alertSet | out-string))
|
||||
if ($notes.Trim().Length -gt 0) {
|
||||
@"
|
||||
### Note
|
||||
$notes
|
||||
|
||||
"@
|
||||
}
|
||||
if (($_.examples | Out-String).Trim().Length -gt 0) {
|
||||
@"
|
||||
### Examples
|
||||
"@
|
||||
$_.examples.example | % {
|
||||
@"
|
||||
**$(FixMarkdownString($_.title.Trim(('-',' '))))**
|
||||
``````powershell
|
||||
$(FixMarkdownCodeString($_.code | out-string ))
|
||||
``````
|
||||
$(FixMarkdownString($_.remarks | out-string ) $true)
|
||||
|
||||
"@
|
||||
}
|
||||
}
|
||||
if (($_.relatedLinks | Out-String).Trim().Length -gt 0) {
|
||||
@"
|
||||
### Links
|
||||
|
||||
"@
|
||||
$_.links | % {
|
||||
@"
|
||||
- [$($_.name)]($($_.link))
|
||||
"@
|
||||
}
|
||||
}
|
||||
}
|
63
helpers/psDoc-master/src/psDoc.ps1
Normal file
63
helpers/psDoc-master/src/psDoc.ps1
Normal file
@@ -0,0 +1,63 @@
|
||||
param(
|
||||
[parameter(Mandatory=$true, Position=0)] [string] $moduleName,
|
||||
[parameter(Mandatory=$false, Position=1)] [string] $template = "./out-html-template.ps1",
|
||||
[parameter(Mandatory=$false, Position=2)] [string] $outputDir = './help',
|
||||
[parameter(Mandatory=$false, Position=3)] [string] $fileName = 'index.html'
|
||||
)
|
||||
|
||||
function FixString ($in = '', [bool]$includeBreaks = $false){
|
||||
if ($in -eq $null) { return }
|
||||
|
||||
$rtn = $in.Replace('&', '&').Replace('<', '<').Replace('>', '>').Trim()
|
||||
|
||||
if($includeBreaks){
|
||||
$rtn = $rtn.Replace([Environment]::NewLine, '<br>')
|
||||
}
|
||||
return $rtn
|
||||
}
|
||||
|
||||
function Update-Progress($name, $action){
|
||||
Write-Progress -Activity "Rendering $action for $name" -CurrentOperation "Completed $progress of $totalCommands." -PercentComplete $(($progress/$totalCommands)*100)
|
||||
}
|
||||
$i = 0
|
||||
$commandsHelp = (Get-Command -module $moduleName) | get-help -full | Where-Object {! $_.name.EndsWith('.ps1')}
|
||||
|
||||
foreach ($h in $commandsHelp){
|
||||
$cmdHelp = (Get-Command $h.Name)
|
||||
|
||||
# Get any aliases associated with the method
|
||||
$alias = get-alias -definition $h.Name -ErrorAction SilentlyContinue
|
||||
if($alias){
|
||||
$h | Add-Member Alias $alias
|
||||
}
|
||||
|
||||
# Parse the related links and assign them to a links hashtable.
|
||||
if(($h.relatedLinks | Out-String).Trim().Length -gt 0) {
|
||||
$links = $h.relatedLinks.navigationLink | % {
|
||||
if($_.uri){ @{name = $_.uri; link = $_.uri; target='_blank'} }
|
||||
if($_.linkText){ @{name = $_.linkText; link = "#$($_.linkText)"; cssClass = 'psLink'; target='_top'} }
|
||||
}
|
||||
$h | Add-Member Links $links
|
||||
}
|
||||
|
||||
# Add parameter aliases to the object.
|
||||
foreach($p in $h.parameters.parameter ){
|
||||
$paramAliases = ($cmdHelp.parameters.values | where name -like $p.name | select aliases).Aliases
|
||||
if($paramAliases){
|
||||
$p | Add-Member Aliases "$($paramAliases -join ', ')" -Force
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Create the output directory if it does not exist
|
||||
if (-Not (Test-Path $outputDir)) {
|
||||
New-Item -Path $outputDir -ItemType Directory | Out-Null
|
||||
}
|
||||
|
||||
$totalCommands = $commandsHelp.Count
|
||||
if (!$totalCommands) {
|
||||
$totalCommands = 1
|
||||
}
|
||||
|
||||
$template = Get-Content $template -raw -force
|
||||
Invoke-Expression $template > "$outputDir\$fileName"
|
Reference in New Issue
Block a user