Code Monkey home page Code Monkey logo

platyps's Introduction

Build status Build status

Join the chat at https://gitter.im/PowerShell/platyPS

PlatyPS

PlatyPS provides a way to:

  • Write PowerShell External Help in Markdown
  • Generate markdown help (example) for your existing modules
  • Keep markdown help up-to-date with your code

Markdown help docs can be generated from old external help files (also known as MAML-xml help), the command objects (reflection), or both.

PlatyPS can also generate cab files for Update-Help.

Why?

Traditionally PowerShell external help files have been authored by hand or using complex tool chains and rendered as MAML XML for use as console help. MAML is cumbersome to edit by hand, and common tools and editors don't support it for complex scenarios like they do with Markdown. PlatyPS is provided as a solution for allow documenting PowerShell help in any editor or tool that supports Markdown.

An additional challenge PlatyPS tackles, is to handle PowerShell documentation for complex scenarios (e.g. very large, closed source, and/or C#/binary modules) where it may be desirable to have documentation abstracted away from the codebase. PlatyPS does not need source access to generate documentation.

Markdown is designed to be human-readable, without rendering. This makes writing and editing easy and efficient. Many editors support it (Visual Studio Code, Sublime Text, etc), and many tools and collaboration platforms (GitHub, Visual Studio Online) render the Markdown nicely.

Common setups

There are 2 common setups that are used:

  1. Use markdown as the source of truth and remove other types of help.
  2. Keep comment based help as the source of truth and periodically generate markdown for web-site publishing.

They both have advantages and use-cases, you should decide what's right for you. There is slight preference toward number 1 (markdown as the source).

Quick start

Install-Module -Name platyPS -Scope CurrentUser
Import-Module platyPS
  • Create initial Markdown help for MyAwesomeModule module:
# you should have module imported in the session
Import-Module MyAwesomeModule
New-MarkdownHelp -Module MyAwesomeModule -OutputFolder .\docs
  • Edit markdown files in .\docs folder and populate {{ ... }} placeholders with missed help content.

  • Create external help from markdown help

New-ExternalHelp .\docs -OutputPath en-US\
  • Congratulations, your help is now in markdown!

  • Now, if your module code changes, you can easily update your markdown help with

# re-import your module with latest changes
Import-Module MyAwesomeModule -Force
Update-MarkdownHelp .\docs

PlatyPS markdown schema

Unfortunately, you cannot just write any Markdown, as platyPS expects Markdown to be authored in a particular way. We have defined a schema to determine how parameters are described, where scripts examples are shown, and so on.

The schema closely resembles the existing output format of the Get-Help cmdlet in PowerShell.

If you break the schema in your markdown, you will get error messages from New-ExternalHelp and Update-MarkdownHelp. You would not be able to generate extrenal help or update your markdown.

It may be fine for some scenarios, i.e. you want to have online-only version of markdown.

Supported scenarios:

  • Create Markdown

    • Using existing external help files (MAML schema, XML).
    • Using reflection
    • Using reflection and existing internal external help files.
    • For a single cmdlet
    • For an entire module
  • Update existing Markdown through reflection.

  • Create a module page .md with summary. It will also allow you to create updatable help cab.

  • Retrieve markdown metadata from markdown file.

  • Create external help xml files (MAML) from platyPS Markdown.

  • Create external help file cab

  • Preview help from generated maml file.

Remoting

PlatyPS supports working with Import-PSSession aka implicit remoting. Just pass -Session $Session parameter to the platyPS cmdlets and it will do the rest.

Build

For information about building from sources and contributing see contributing guidelines.

Code of Conduct

Please see our Code of Conduct before participating in this project.

Security Policy

For any security issues, please see our Security Policy.

platyps's People

Contributors

adityapatwardhan avatar berniewhite avatar darquewarrior avatar daviwil avatar dotps1 avatar francisco-gamino avatar gitter-badger avatar it-praktyk avatar jameswtruher avatar jazzdelightsme avatar joeyaiello avatar jongeller avatar logosnazerath avatar miamiax avatar natescherer avatar pcgeek86 avatar przemyslawklys avatar sampy avatar sdwheeler avatar sergeytunnik avatar stevel-msft avatar swernli avatar thisisnotarobot avatar thomasnieto avatar timshererwithaquent avatar tlindsay42 avatar vors avatar xmdanni avatar yingdabeyondsoft avatar yishengjin1413 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

platyps's Issues

Simplified Markdown Parser mode to preserve original formatting

Hyperlinks currently handed far from perfect.

  • Our pattern uses @"\[(.+?)\]\((https?://[^'\"">\s]+)?\)" regex to recognize them. It would not treat relative github links as hyper-links.
  • After a full circle unrecognized link would gain additional escaping, so it would be rendered improperly

Generate the correct MAML filenames

Filenames need to have the full XML filename that is compatible all the way to PS 3.0. This differs across script, binary, CDXML, and provider cmdlets.

Add cabinet creation cmdlet to PlatyPs

Add the ability to compress prepared help files to a cabinet. This enables the creation of downloadable packages that can be used with Update-Help. Use MakeCab.exe as it is commonly available on Windows operating systems.

New Functionality - New-PlatyPsCabinet

Add a script cmdlet to platyPs that will utilize the makecab.exe to compress target files into a cabinet.
The name of the cab which must be particular for the PowerShell help engine to find and extract, will be based on the params provided for Module Name, GUID, and Locale.

Required Params

In order to correctly name a cab

    [Cmdletbinding()]
    param(
        [parameter(Mandatory=$true)]
        [string] $Source,
        [parameter(Mandatory=$true)]
        [string] $Destination,
        [parameter(Mandatory=$true)]
        [string] $Module,
        [parameter(Mandatory=$true)]
        [string] $Locale,
        [parameter(Mandatory=$true)]
        [string] $Guid
    )

Source

The source directory containing all of the files to be added to the cab. Non-Recursive.

Destination

The output directory to create the cab file. It should create a reusable folder structure:

\CabFile\
           \datetime cmdlet was run\
           \latest\

This folder structure will allow the output to be added to the latest folder, as well as a time stamped directory for historical purposes.

Module

The name of the module as it appears in the PowerShell console when Get-Command -ListAvailable is run.

Locale

The language code the of the help the cab will contain:
xx-XX format, ie: en-US or fr-FR or es-ES

Guid

The GUID of the PowerShell module.
Typically alphanumeric XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

Module Naming Convention

The help system in PowerShell requires that Cabs have a specific name scheme in order for Update-Help to find the package, download, and extract it.

<ModuleName>_<ModuleGuid>_<Locale>_helpcontent.cab

Output

Using the destination param, the cab file will be output to a target destination.

April/May 2016 Deliveries

  • Finalize on cmdlet Template - Issue #34 - Complete by April 14
  • Updating published Markdowns with new code changes in the PS Module -Issue #38 - Complete by May 13
  • Need a solution to generate Providers and About - Issue #37 - Complete by June 3
  • Add cabinet creation cmdlet to PlatyPS - Issue #35 - Complete by April 22
  • Add help.xml proper naming conversion cmdlet to PlatyPS - Issue #36 - Complete by May 10
  • Add metadata block support (for BI) in the schema - Completed
  • Add cmdlet for upgrade from schema - Issue #49 - Complete by May 13

Get-Help -Online parameter, required functionality

Creating this issue to ensure we test this functionality
When get-help is run against a cmdlets, if the -online parameter is used, an web page will be opened where the published version of the help can be seen.

The link data is available in the related links section, but the documentation authors need to be sure this will work once the conversion from MD to MAML is performed.

Get-Help Add-Computer -online
#links to: 
#https://technet.microsoft.com/library/712f3460-c5d0-4af8-8de6-6d06e4a1a838(v=wps.630).aspx

This link, is stored in the MAML related links section here, note the Online Version text:

    <maml:relatedLinks>
      <maml:navigationLink>
        <maml:linkText>Online Version:</maml:linkText>
        <maml:uri>http://go.microsoft.com/fwlink/p/?linkid=290488</maml:uri>
      </maml:navigationLink>
    </maml:relatedLinks>

Schema 2.0.0: add a hypen in front of parameter names

Before:

ScriptBlock

The ScriptBlock is called when the Chord is entered. The ScriptBlock is passed one or sometimes two arguments. The first argument is the key pressed (a ConsoleKeyInfo.) The second argument could be any object depending on the context.

Type: ScriptBlock
Parameter Sets: Set 1
Aliases: 

Required: True
Position: 1
Default value: 
Accept pipeline input: false
Accept wildcard characters: False

After:

-ScriptBlock

The ScriptBlock is called when the Chord is entered. The ScriptBlock is passed one or sometimes two arguments. The first argument is the key pressed (a ConsoleKeyInfo.) The second argument could be any object depending on the context.

Type: ScriptBlock
Parameter Sets: Set 1
Aliases: 

Required: True
Position: 1
Default value: 
Accept pipeline input: false
Accept wildcard characters: False

What do you think? We need to make a decision by Tuesday

Cmdlets renaming

I think current name looks pretty unfun.
I'd like to drop platyPS prefix and do other small tweaks.

  • Get-PlatyPSMarkdown -> New-Markdown (semantic changed after #51, so verb change)
  • Get-PlatyPSYamlMetadata -> Get-MarkdownMetadata
  • Get-PlatyPSExternalHelp -> New-ExternalHelp (we want to embeed information about naming convention in markdown metadata, so semantic would change: it would drop a file on the disk)
  • Get-PlatyPSTextHelpFromMaml -> Show-HelpPreview
  • New-PlatyPSCab -> New-ExternalHelpCab
  • Format-PlatyPsHelpXml -> $null (we will spreed this functionality across New-ExternalHelpCab and New-ExternalHelp)
  • new cmdlet from #49 -> Update-Markdown

cc @jongeller

Generic way to customize generated markdown

This is far in the future, but I want to capture this idea now.

There are write-only scenarios for generated markdown:
Examples:

It may be desirable to customize them somehow. I.e. do post-processing on cross-references to link them appropriately.

Something to have in mind for future.

Fix documentation

Before next release

  • src\platyPS\docs
  • README.md with updated scenarios

Address parser performance issues

MarkdownStringToMamlString must be fast (less then a minute for this file)

$markdown = cat .\Examples\SMA.Help.md -Raw
$generatedMaml = [Markdown.MAML.Renderer.MamlRenderer]::MarkdownStringToMamlString($markdown)

Is #### {Input type} by design?

in platyPS.schema.md, {Input type} is preceded by four #, where I would have expected the nesting level to be at three #, as is the case for {Parameter name}, {Output type} and {Example Name}.

Is this a design choice or a nesting error introduced in bbeba47?

Dynamic Param of type Swtich defaulting to mandatory.

I have a function that has a dynamic param set, and there is a switch that is not mandatory, but it is not explicitly set to false, and the markdown outputs Mandatory as true. If I add Mandatory = $false it will output correctly, so I am guessing it is just defaulting to $true?

*edit
this only seems to happen on param of Type Switch, i have a String param, that one is also not mandatory, and not explicitly defined as such, but it outputs as mandatory: False.

Example to view generated help errors out

This is what I get:

107> $generatedModule.Cmdlets | % { Get-Help -Name "$($generatedModule.Name)\$_" -Full | Out-String }
Get-Help : Get-Help could not find testplay.psm1-Help.xml_2139322656\Edit-File in a help file in this session. To
download updated help topics type: "Update-Help". To get help online, search for the help topic in the TechNet library
at http://go.microsoft.com/fwlink/?LinkID=107116.
At line:1 char:32
+ ... dlets | % { Get-Help -Name "$($generatedModule.Name)\$_" -Full | Out- ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (:) [Get-Help], HelpNotFoundException
    + FullyQualifiedErrorId : HelpNotFound,Microsoft.PowerShell.Commands.GetHelpCommand

Could it be that your example is working because you're working in the platyPS out dir (where there is a real module)?

Do we want to keep Common Parameters with explicit help entries?

There are common parameters in PowerShell.

There is a content help difference between v4 and v5

> (Get-Help Add-Computer).syntax.syntaxItem[0].Parameter.Name | ? {$_ -like 'info*'}
# in v5
InformationAction
InformationVariable
# in v4 nothing

To resolve it properly, I'd like to rise a conceptual question:
Is it a legitimate scenario to include explicit entry about particular common parameter in help?

Dynamic Parameters support

yesterday, my dynamic parameter sets where getting exported in New-Markdown, but this is no longer happening as of building this morning.

New cmdlet Test-Markdown

Scenarios:

  • Verify that markdown is compliant with schema
  • Verify / report that all text fields are filled (i.e. NOTES, description placeholders)

Scenarios to consider:

  • Verify markdown metadata keys. It's needed for a large scale pipelines, i.e. if MS adopts platyPS. Maybe create a Test-MarkdownMetadata instead?

Generate MD stubs via module reflection

This is the initial generation of "stub reference" documentation in Markdown for a new module.

Scenario here is to first finish the module and then to generate documentation for later annotation.

Make one cmdlet per file the default

Per discussion in #20 , everybody agreed that it's a good idea to enforce one cmdlet per file policy for the help. Hence, we should make it the default.

I would not pull out support for multiply cmdlets in the same file, but an APIs to bootstrap such markdown would be de-promoted from default to exotic.

Suggestion for generated markdown header

Hello! This tool looks great, and I plan to use this to help automate my github wiki very soon! However, I see in the newest version (from the repo, not from the PoSh Gallery) that the New-Markdown shows a header, even on your pages. For instance:


---
external help file: gShell.dll-Help.xml
schema: 2.0.0

---

At the very least can this be moved to the bottom and/or become optional with a switch like you'd see with Export-Csv -NoTypeInformation?

I'm hip deep in things at the moment, but I can look in to making a pull request sometime this week if that would make things any faster.

Thanks for your consideration!

Add help.xml proper naming convention cmdlet to PlatyPs

Add a cmdlet to PlatyPs the properly names a help.xml file for use.
Help files need to be specifically named in order for the PowerShell help engine to find them. There must be a help file corresponding to each cmdlet-providing code file, DLL, CDXML, PSM1.

New Functionality - Format-PlatyPsHelpXml

This cmdlet will take the name of a file that contains the code for a Powershell module's cmdlets. It will also take in the source help.xml file. Using these two things, the cmdlet will generate a help.xml file that is properly named and can be consumed by the PowerShell help engine.

Required Params

[Cmdletbinding()]
    param(
        [parameter(Mandatory=$true)]
        [string] $HelpFileSourceXml,
        [parameter(Mandatory=$true)]
        [string] $ModuleFileName,
        [parameter(Mandatory=$true)]
        [string] $Destination
    )

File naming convention

The help system in PowerShell requires that help.xml files have a specific name scheme in order for Get-Help to find the documentation and display it in the help console.

<ModuleCodeFileName>-help.xml

Need a solution to generate About topics

This ask was split later, in thread, keep reading....
PlatyPS doesn't yet have a solution to generate providers data. Need a solution in place to handle this content.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.