Skip to content

Commit 4c2ef71

Browse files
authored
Merge pull request #795 from sdwheeler/sdw-w476168-v1-docs
Update v0.14 schema docs and add code design doc
2 parents 02a706f + e32c510 commit 4c2ef71

File tree

2 files changed

+275
-128
lines changed

2 files changed

+275
-128
lines changed

docs/CODE-LAYOUT.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Contributing to platyPS
2+
3+
## Get the code
4+
5+
```
6+
git clone https://github.com/PowerShell/platyPS
7+
```
8+
9+
## Understand code layout
10+
11+
There are two parts:
12+
13+
- `Markdown.MAML.dll`, a .NET library written in C#. It does the heavy lifting, like parsing
14+
Markdown, transforming it into XML, and so on. You can open `.\Markdown.MAML.sln` in Visual Studio
15+
on any platform.
16+
- A PowerShell module in `.\src\platyPS`. This module provides the user CLI.
17+
18+
## Build
19+
20+
To build the whole project, use the `build.ps1` helper script. It depends on the [dotnet cli][01]
21+
build tool.
22+
23+
On Windows you would also need to [install full dotnet framework][02] if it's not installed already.
24+
25+
```powershell
26+
.\build.ps1
27+
```
28+
29+
As part of the build, platyPS generates help for itself. The output of the build is placed in
30+
`out\Microsoft.PowerShell.PlatyPS`.
31+
32+
`build.ps1` also imports the module from `out\platyPS` and generates help itself.
33+
34+
> [!NOTE]
35+
> If you changed C# code, `build.ps1` will try to overwrite a DLL in use. You will then need to
36+
> re-open your PowerShell session. If you know a better workflow, please suggest it in the Issues.
37+
38+
## Tests
39+
40+
Each part of the project has a test set:
41+
42+
- The C# part has xUnit tests. You can run them from Visual Studio or from command line with
43+
`dotnet test ./test/Markdown.MAML.Test`.
44+
- The PowerShell part has [Pester][03] tests. You can run them with `Invoke-Pester`.
45+
46+
> [!NOTE]
47+
> Pester tests always force-import the module from the output ___location of `.\build.ps1`.
48+
49+
## Schema
50+
51+
If you have ideas or concerns about the Markdown schema, feel free to open a GitHub Issue to discuss
52+
it.
53+
54+
## Repo structure
55+
56+
- **src\platyPS** - sources to create the final PowerShell module.
57+
- **src\Markdown.MAML, Markdown.MAML.sln** - source code for C# Markdown to MAML converter.
58+
- **[platyPS.schema.md][04]** - description of Markdown that platyPS expects.
59+
60+
## Data transformations
61+
62+
Data transformations are the core of platyPS. A user has content in some form and she wants to
63+
transform it into another form. E.g. transform existing module help (in MAML) to Markdown and use it
64+
in the future to generate the external help (MAML) and static HTML for online references.
65+
66+
platyPS provides APIs in the form of cmdlets for end-user scenarios. These scenarios are assembled
67+
from simple transformations. This chart describes these simple transformations:
68+
69+
```
70+
+----------+
71+
| |
72+
| HTML |
73+
| |
74+
+------^---+
75+
|
76+
+------+------------+ +-----------------+
77+
| | | Markdown Model |
78+
| Markdown file +-----------> |
79+
| | +-+---------------+
80+
| | |
81+
+---------------^---+ |
82+
| |
83+
| |
84+
| |
85+
+--+-----------------v--+
86+
| MAML Model |
87+
| (= Generic Help model)|
88+
| |
89+
+--+-------------------^+
90+
| |
91+
| |
92+
| |
93+
+----------------v-----+ ++--------------------------+
94+
| MAML XML file | | Help Object in PowerShell |
95+
| (External help file) +------------> (+ Get-Command object) |
96+
+----------------------+ +---------------------------+
97+
```
98+
99+
### Example `New-MarkdownHelp`
100+
101+
A user creates a platyPS Markdown for the first time with `New-MarkdownHelp`:
102+
103+
```powershell
104+
New-MarkdownHelp -Command New-MyCommandHelp
105+
```
106+
107+
Under the hood, the following tranformations happen:
108+
109+
```
110+
[MAML XML file] --> [Help Object + Get-Command object] --> [MAML Model] --> [Markdown file]
111+
```
112+
113+
# Making a new release
114+
115+
1. Make sure that `CHANGELOG.md` is up-to-date, move section from `UNRELEASED` to new section
116+
`<release name>`.
117+
1. Make sure platyPS help itself (content in .\docs folder) is up to date.
118+
`Update-MarkdownHelp -Path .\docs` should result in no changes.
119+
1. Do not change the version in platyps.psd1. Git tag will update this version for release.
120+
1. From master, tag the release.
121+
1. Push tag to GitHub.
122+
1. Find the corresponding build on AppVeyor.
123+
1. Download ZIP archive with the module from Appveyor's Artifacts tab.
124+
1. Unblock the ZIP archive (`Unblock-File foo.zip`), and copy the ZIP's contents to
125+
`$env:PSMODULEPATH` so it's available to `Publish-Module`.
126+
1. Publish the module to the Gallery:
127+
`Publish-Module -RequiredVersion <version> -Verbose -NuGetApiKey $apiKey`.
128+
1. Check that https://www.powershellgallery.com/packages/platyPS/ updated.
129+
1. Publish a new github release from https://github.com/PowerShell/platyPS/releases to move "Latest
130+
release" label to the new tag.
131+
132+
Congratulations! You just made a release.
133+
134+
<!-- link references -->
135+
[01]: https://docs.microsoft.com/en-us/dotnet/core/tools/
136+
[02]: https://docs.microsoft.com/en-us/dotnet/framework/install/guide-for-developers
137+
[03]: https://github.com/pester/Pester
138+
[04]: platyPS.schema.md

0 commit comments

Comments
 (0)