|
1 | | -[](https://ci.appveyor.com/project/PowerShell/markdown-maml/branch/master) |
2 | | -[](https://travis-ci.org/PowerShell/platyPS/builds) |
| 1 | +# Microsoft.PowerShell.PlatyPS |
3 | 2 |
|
4 | | -[](https://gitter.im/PowerShell/platyPS?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) |
| 3 | +**PlatyPS** is the tool that Microsoft uses to create the PowerShell content you get from `Get-Help` |
| 4 | +and build the content published as [PowerShell documentation][03] on Microsoft Learn. |
5 | 5 |
|
6 | | -# PlatyPS |
| 6 | +PowerShell help files are stored as [Microsoft Assistance Markup Language][05] (MAML), an XML |
| 7 | +format. **PlatyPS** simplifies the authoring process by allowing you to write the help files in |
| 8 | +Markdown, then convert to MAML. [Markdown][04] is widely used in the software industry, |
| 9 | +supported by many editors including **Visual Studio Code**, and easier to author. |
7 | 10 |
|
8 | | -PlatyPS provides a way to: |
| 11 | +**Microsoft.PowerShell.PlatyPS** includes several improvements: |
9 | 12 |
|
10 | | -* Write PowerShell External Help in Markdown |
11 | | -* Generate markdown help ([example](docs/Update-MarkdownHelp.md)) for your existing modules |
12 | | -* Keep markdown help up-to-date with your code |
| 13 | +- Re-write in C# leveraging [markdig][02] for parsing Markdown (the same library used by |
| 14 | + Microsoft Learn to render Markdown) |
| 15 | +- Provides a more accurate description of a PowerShell cmdlet and its parameters and includes |
| 16 | + information that was previously unavailable |
| 17 | +- Creates an object model of the help file that you can manipulate and supports chaining cmdlets for |
| 18 | + complex operations |
| 19 | +- Increased performance - processes 1000s of Markdown files in seconds |
13 | 20 |
|
14 | | -Markdown help docs can be generated from old external help files (also known as MAML-xml help), the command objects (reflection), or both. |
| 21 | +## Install Microsoft.PowerShell.PlatyPS |
15 | 22 |
|
16 | | -PlatyPS can also generate cab files for [`Update-Help`](https://technet.microsoft.com/en-us/library/hh849720.aspx). |
| 23 | +PlatyPS runs on: |
17 | 24 |
|
18 | | -## Why? |
| 25 | +- Windows PowerShell 5.1+ |
| 26 | +- PowerShell 7+ on Windows, Linux, and macOS |
19 | 27 |
|
20 | | -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. |
21 | | -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. |
22 | | - |
23 | | -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. |
24 | | - |
25 | | -Markdown is designed to be human-readable, without rendering. This makes writing and editing easy and efficient. |
26 | | -Many editors support it ([Visual Studio Code](https://code.visualstudio.com/), [Sublime Text](http://www.sublimetext.com/), etc), and many tools and collaboration platforms (GitHub, Visual Studio Online) render the Markdown nicely. |
27 | | - |
28 | | -## Common setups |
29 | | - |
30 | | -There are 2 common setups that are used: |
31 | | - |
32 | | -1. Use markdown as the source of truth and remove other types of help. |
33 | | -2. Keep comment based help as the source of truth and periodically generate markdown for web-site publishing. |
34 | | - |
35 | | -They both have advantages and use-cases, you should decide what's right for you. |
36 | | -There is slight preference toward number 1 (markdown as the source). |
37 | | - |
38 | | -## Quick start |
39 | | - |
40 | | -* Install platyPS module from the [PowerShell Gallery](https://powershellgallery.com): |
| 28 | +Install the module from [PSGallery][06]. |
41 | 29 |
|
42 | 30 | ```powershell |
43 | | -Install-Module -Name platyPS -Scope CurrentUser |
44 | | -Import-Module platyPS |
| 31 | +Install-PSResource -Name Microsoft.PowerShell.PlatyPS |
45 | 32 | ``` |
46 | 33 |
|
47 | | -* Create initial Markdown help for `MyAwesomeModule` module: |
| 34 | +## Layout of this repository |
48 | 35 |
|
49 | | -```powershell |
50 | | -# you should have module imported in the session |
51 | | -Import-Module MyAwesomeModule |
52 | | -New-MarkdownHelp -Module MyAwesomeModule -OutputFolder .\docs |
53 | | -``` |
| 36 | +### Branches |
54 | 37 |
|
55 | | -* Edit markdown files in `.\docs` folder and populate `{{ ... }}` placeholders with missed help content. |
| 38 | +- `main`: Contains the source code for the new version of PlatyPS named |
| 39 | + **Microsoft.PowerShell.PlatyPS**. This is the current supported version of PlatyPS. You can find |
| 40 | + this version listed as [Microsoft.PowerShell.PlatyPS][06] in the PowerShell Gallery. |
| 41 | +- `v1`: Contains the source code for the legacy version of PlatyPS named **platyPS**. This version |
| 42 | + is no longer actively maintained, but it's available for reference and legacy support. The latest |
| 43 | + version of this code is 0.14.2. You can find this version listed as [platyPS][07] in the |
| 44 | + PowerShell Gallery. |
56 | 45 |
|
57 | | -* Create external help from markdown help |
| 46 | +### Folder structure |
58 | 47 |
|
59 | | -```powershell |
60 | | -New-ExternalHelp .\docs -OutputPath en-US\ |
61 | | -``` |
| 48 | +- `docs` - contains design documentation for the PlatyPS project |
| 49 | +- `src` - contains the source code for the module |
| 50 | +- `test` - contains the tests files used to validate the code at build time |
| 51 | +- `tools` - contains tools used to build the module |
62 | 52 |
|
63 | | -* **Congratulations**, your help is now in markdown! |
| 53 | +## Contributing to the project |
64 | 54 |
|
65 | | -* Now, if your module code changes, you can easily update your markdown help with |
| 55 | +If you are interested in contributing to the PlatyPS project, please see the |
| 56 | +[contribution guide][01]. |
66 | 57 |
|
67 | | -```powershell |
68 | | -# re-import your module with latest changes |
69 | | -Import-Module MyAwesomeModule -Force |
70 | | -Update-MarkdownHelp .\docs |
71 | | -``` |
| 58 | +### Build the code |
72 | 59 |
|
73 | | -### PlatyPS markdown schema |
| 60 | +Prerequisites for build: |
74 | 61 |
|
75 | | -Unfortunately, you cannot just write any Markdown, as platyPS expects Markdown to be authored in a **particular way**. |
76 | | -We have defined a [**schema**](platyPS.schema.md) to determine how parameters are described, where scripts examples are shown, and so on. |
| 62 | +- PS7 |
| 63 | +- .NET 8 SDK |
77 | 64 |
|
78 | | -The schema closely resembles the existing output format of the `Get-Help` cmdlet in PowerShell. |
| 65 | +Prerequisites for test: |
79 | 66 |
|
80 | | -If you break the schema in your markdown, you will get error messages from `New-ExternalHelp` and `Update-MarkdownHelp`. |
81 | | -You would not be able to generate extrenal help or update your markdown. |
| 67 | +- Pester 4.x (Pester 5.x is not supported) |
82 | 68 |
|
83 | | -It may be fine for some scenarios, i.e. you want to have online-only version of markdown. |
| 69 | +To build the source code, run the following command in the root of the repository: |
84 | 70 |
|
85 | | -## [Usage](docs) |
86 | | - |
87 | | -Supported scenarios: |
88 | | - |
89 | | -* Create Markdown |
90 | | - * Using existing external help files (MAML schema, XML). |
91 | | - * Using reflection |
92 | | - * Using reflection and existing internal external help files. |
93 | | - * For a single cmdlet |
94 | | - * For an entire module |
95 | | - |
96 | | -* Update existing Markdown through reflection. |
97 | | - |
98 | | -* Create a module page <ModuleName>.md with summary. It will also allow you to create updatable help cab. |
99 | | - |
100 | | -* Retrieve markdown metadata from markdown file. |
101 | | - |
102 | | -* Create external help xml files (MAML) from platyPS Markdown. |
103 | | - |
104 | | -* Create external help file cab |
105 | | - |
106 | | -* Preview help from generated maml file. |
107 | | - |
108 | | -## Remoting |
109 | | - |
110 | | -PlatyPS supports working with [`Import-PSSession`](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/import-pssession?view=powershell-6) aka implicit remoting. |
111 | | -Just pass `-Session $Session` parameter to the platyPS cmdlets and it will do the rest. |
112 | | - |
113 | | -## Build |
| 71 | +```powershell |
| 72 | +.\build.ps1 -Clean |
| 73 | +``` |
114 | 74 |
|
115 | | -For information about building from sources and contributing see [contributing guidelines](CONTRIBUTING.md). |
| 75 | +<!-- link references --> |
| 76 | +[01]: ./CONTRIBUTING.md |
| 77 | +[02]: https://github.com/xoofx/markdig |
| 78 | +[03]: https://learn.microsoft.com/powershell/scripting |
| 79 | +[04]: https://wikipedia.org/wiki/Markdown |
| 80 | +[05]: https://wikipedia.org/wiki/Microsoft_Assistance_Markup_Language |
| 81 | +[06]: https://www.powershellgallery.com/packages/Microsoft.PowerShell.PlatyPS |
| 82 | +[07]: https://www.powershellgallery.com/packages/platyPS |
0 commit comments