-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate Help From Publish-able powershell script #389
Comments
The |
I too have this question. Any help greatly appreciated! Edit Removed previous comment as I had misunderstood the instruction. Last Edit :) I didn't have to install the module first. While platyps threw an error it threw an error it seemed to still generate the markdown when I called it like this:
I didn't have to dot source the script or anything. |
@Geogboe that is some good information. In said script where that worked where is your help block? Do you use the PSScriptInfo block at all for publishing scripts? |
@darksidemilk Yep, I had the psscriptinfo block. I'll provide some more details below: Sample script<#PSScriptInfo
.VERSION 0.0.1
.GUID 23092348203842390
.AUTHOR Me
.COMPANYNAME Companay
.COPYRIGHT Now
.TAGS script
.LICENSEURI MIT
.PROJECTURI
.ICONURI
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES
- v0.0.1 - initial release
.PRIVATEDATA
#>
<#
.SYNOPSIS
does stuff
.DESCRIPTION
even more
.EXAMPLE
.\my-script.ps1 -path $pwd
Will test the path provided by $pwd and return true or false
#>
[cmdletbinding( PositionalBinding )]
param (
[Parameter( Mandatory )]
[string]
$Path
)
Test-Path $Path Command outputNew-MarkdownHelp -Command ".\my-script.ps1" -Force -OutputFolder .\docs\
Get-Command : The term 'my-script.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
At C:\Program Files\WindowsPowerShell\Modules\platyPS\0.12.0\platyPS.psm1:211 char:58
+ ... $helpFileName = GetHelpFileName (Get-Command @a)
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (my-script.ps1:String) [Get-Command], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommand
Directory: C:\docs
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 11/28/2018 1:01 PM 1001 my-script.ps1.md Despite the error the markdown document is created and looks right |
Hm, very interesting. Indeed it's an external command.
@Geogboe @darksidemilk would you care to fix platyPS to avoid throwing error in this case and send a pull request? |
@vors I have powershell experience but I've never done a pull. I'm happy to give it a shot though! |
@vors I looked through the code and it looks like the error is being thrown only when platy is trying to come up with a name for the markdown file it's going to create. Right now, platy successfully finds and loads the command ( The most straightforward solution seemed to be, check if this command is an external script and if so, make sure we resolve the path ( relative to us ) and pass THAT to get-command. I'm not sure I fully understand the core of platy yet though so this may just be a work around solution rather than a full solution. Just let me know though. 5 tests failed but those same 5 tests failed before I made the change so I think that's unrelated. |
Hello @Geogboe , I have same problem as describe @darksidemilk . I have similiar script with help
Actually I not have implemented support of commandline parameters because I working now with technical demo. But I expect generation of help from script. And I have same problem with error messages if I will try use New-MarkdownHelp command:
|
We also ran in this issue. |
@theJasonHelmick @adityapatwardhan I marked this as consider for 2.0 since there is a PR open to fix the problem. |
Implementation in PR for the v2 for New-MarkdownHelp seems to have resolved this issue: #520 I do not have dates for the next release though, hopefully soon. |
thank you, I will happy for this release :) |
There are a few issues being described in this issue.
Answers
|
So say I have a script that I have made publishable, and it's something that doesn't make sense to be its own module. So I've utilized the powershell command
New-scriptfileinfo
to create the proper headers including a top level help comment block. Then the script also has various functions each with a comment block.If I try to import the script it runs the script,
Since I am able to add a .link parameter I figure it would be nice to create md files for hosting at the site I put said link.
So in short, Is it possible to use playtps to generate file from a normal ps1 file, or something of that sort.
Here's a little more info with an example.
Here's the heading of a script I use for firstlogoncommands that's launched via an unattend.xml in the oobe phase of sysprep.
Then there are various functions defined each with their own help block. Then a main function is called.
Once this script is installed via
install-script firstlogoncommands -repository internalRepo
it is added to the powershell scripts folder that is added to the PATH the first time a script is installed. So if I runget-help firstlogoncommands
it shows the second comment block with the standard help block info.I'm also wondering if the information such as the release notes, version author, etc. could also be converted to markdown as part of generating the help file.
Thanks,
-JJ
The text was updated successfully, but these errors were encountered: