Skip to content

Commit 9b243fc

Browse files
authored
Grammatical/Markdown fixes
1 parent 89f27bc commit 9b243fc

File tree

1 file changed

+33
-37
lines changed

1 file changed

+33
-37
lines changed

Style-Guide/Documentation-and-Comments.md

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
### Documenting and Comments
22

3-
Comments that contradict the code are worse than no comments. Always make a priority of keeping the comments up-to-date when the code changes!
3+
Comments that contradict the code are worse than no comments. Always make a priority of keeping the comments up-to-date when the code changes!
44

5-
Comments should be in English, and should be complete sentences. If the comment is short, the period at the end can be omitted.
5+
Comments should be in English, and should be complete sentences. If the comment is short, the period at the end can be omitted.
66

77
Remember that comments should serve to your reasoning and decision-making, not attempt to explain what a command does. With the exception of regular expressions, well-written PowerShell can be pretty self-explanatory.
88

@@ -14,28 +14,27 @@ $Margin = $Margin + 2
1414
# Maybe write:
1515
# The rendering box obscures a couple of pixels.
1616
$Margin = $Margin + 2
17-
1817
```
1918

2019
#### Block comments
2120

2221
Don't go overboard with comments. Unless your code is particularly obscure, don't precede each line with a comment -- doing so breaks up the code and makes it harder to read. Instead, write a single block comment.
2322

24-
Block comments generally apply to some or all of the code which follows them, and are indented to the same level as that code. Each line should start with a # and a single space.
23+
Block comments generally apply to some or all of the code which follows them, and are indented to the same level as that code. Each line should start with a # and a single space.
2524

2625
If the block is particularly long (as in the case of documentation text) it is recommended to use the `<# ... #>` block comment syntax, but you should place the comment characters on their own lines, and indent the comment:
27-
26+
2827
```PowerShell
29-
# Requiring a space makes things legible and prevents confusion.
30-
# Writing comments one-per line makes them stand out more in the console.
28+
# Requiring a space makes things legible and prevents confusion.
29+
# Writing comments one-per line makes them stand out more in the console.
3130
32-
<#
33-
.SYNOPSIS
34-
Really long comment blocks are tedious to keep commented in single-line mode
35-
.DESCRIPTION
31+
<#
32+
.SYNOPSIS
33+
Really long comment blocks are tedious to keep commented in single-line mode.
34+
.DESCRIPTION
3635
Particularly when the comment must be frequently edited,
37-
as with the help and documentation for a function or script
38-
#>
36+
as with the help and documentation for a function or script.
37+
#>
3938
```
4039

4140
#### Inline comments
@@ -47,16 +46,16 @@ They should be separated from the code statement by at least two spaces, and ide
4746
```PowerShell
4847
$Options = @{
4948
Margin = 2 # The rendering box obscures a couple of pixels.
50-
Padding = 2 # We need space between the border and the text
51-
FontSize = 24 # Keep this above 16 so it's readable in presentations
49+
Padding = 2 # We need space between the border and the text.
50+
FontSize = 24 # Keep this above 16 so it's readable in presentations.
5251
}
5352
```
5453

5554
#### Documentation comments
5655

57-
Comment-based help should be written in simple language.
56+
Comment-based help should be written in simple language.
5857

59-
You're not writing a thesis for your college Technical Writing class - you're writing something that describes how a function works. Avoid unecessarily large words, and keep your explanations short. You're not trying to impress anyone, and the only people who will ever read this are just trying to figure out how to use the function.
58+
You're not writing a thesis for your college Technical Writing class - you're writing something that describes how a function works. Avoid unnecessarily large words, and keep your explanations short. You're not trying to impress anyone, and the only people who will ever read this are just trying to figure out how to use the function.
6059

6160
If you're writing in what is, for you, a foreign language, simpler words and simpler sentence structures are better, and more likely to make sense to a native reader.
6261

@@ -78,17 +77,17 @@ Every script function command should have at least a short statement describing
7877

7978
##### Document Each Parameter
8079

81-
Each parameter should be documented. To make it easier to keep the comments synchronized with changes to the parameters, the preferred location for parameter documentation comments is _within_ the `param` block, directly above each parameter.
80+
Each parameter should be documented. To make it easier to keep the comments synchronized with changes to the parameters, the preferred location for parameter documentation comments is _within_ the `param` block, directly above each parameter.
8281
Examples can be found in the ISE snippets:
8382

84-
```powershell
83+
```PowerShell
8584
Param(
8685
# Param1 help description
8786
[Parameter(Mandatory = $true,
8887
ValueFromPipelineByPropertyName = $true,
8988
Position = 0)]
9089
$Param1,
91-
90+
9291
    # Param2 help description
9392
[int]
9493
$Param2
@@ -101,16 +100,16 @@ It is also possible to write `.PARAMETER` statements with the rest of the docume
101100

102101
Your help should always provide an example for each major use case. A 'usage example' is just an example of what you would type in to Powershell to run the script - you can even cut and paste one from the command line while you're testing your function.
103102

104-
105103
```PowerShell
106104
function Test-Help {
107105
<#
108106
.SYNOPSIS
109-
An example function to display how help should be written
107+
An example function to display how help should be written.
108+
110109
.EXAMPLE
111110
Get-Help -Name Test-Help
112111
113-
This shows the help for the example function
112+
This shows the help for the example function.
114113
#>
115114
[CmdletBinding()]
116115
param(
@@ -125,17 +124,14 @@ function Test-Help {
125124
}
126125
```
127126

128-
129-
130-
131127
### DOC-01 Write comment-based help
132128

133129
You should always write comment-based help in your scripts and functions.
134130

135131
Comment-based help is formatted as follows:
136132

137133
```PowerShell
138-
function get-example {
134+
function Get-Example {
139135
<#
140136
.SYNOPSIS
141137
A brief description of the function or script.
@@ -144,34 +140,34 @@ function get-example {
144140
A longer description.
145141
146142
.PARAMETER FirstParameter
147-
Description of each of the parameters
143+
Description of each of the parameters.
148144
Note:
149-
       To make it easier to keep the comments synchronized with changes to the parameters,
150-
the preferred location for parameter documentation comments is not here,
145+
       To make it easier to keep the comments synchronized with changes to the parameters,
146+
the preferred location for parameter documentation comments is not here,
151147
but within the param block, directly above each parameter.
152148
153149
.PARAMETER SecondParameter
154-
Description of each of the parameters
150+
Description of each of the parameters.
155151
156152
.INPUTS
157-
Description of objects that can be piped to the script
153+
Description of objects that can be piped to the script.
158154
159155
.OUTPUTS
160-
Description of objects that are output by the script
156+
Description of objects that are output by the script.
161157
162158
.EXAMPLE
163-
Example of how to run the script
159+
Example of how to run the script.
164160
165161
.LINK
166-
Links to further documentation
162+
Links to further documentation.
167163
168164
.NOTES
169-
Detail on what the script does, if this is needed
165+
Detail on what the script does, if this is needed.
170166
171167
#>
172168
```
173169

174-
Comment-based help is displayed when the user types `help get-example` or `get-example -?`, etc.
170+
Comment-based help is displayed when the user types `help Get-Example` or `Get-Example -?`, etc.
175171

176172
Your help should be helpful. That is, if you've written a tool called `Get-LOBAppUser`, don't write help that merely says, "Gets LOB App Users." Duh.
177173

0 commit comments

Comments
 (0)