Skip to content

Updated Style Guide with article about formatting code samples#1954

Merged
joeyaiello merged 3 commits intoMicrosoftDocs:stagingfrom
sdwheeler:sdw-codestyle
Dec 14, 2017
Merged

Updated Style Guide with article about formatting code samples#1954
joeyaiello merged 3 commits intoMicrosoftDocs:stagingfrom
sdwheeler:sdw-codestyle

Conversation

@sdwheeler
Copy link
Copy Markdown
Collaborator

This article addresses the use of the PowerShell prompt and the proper use of language labels on code fences.

@sdwheeler sdwheeler requested a review from joeyaiello December 14, 2017 17:59
Copy link
Copy Markdown
Contributor

@joeyaiello joeyaiello left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only minor stuff, otherwise looks great. This'll be super useful for folks with questions. I'm gonna approve now assuming you're gonna make the small edits I proposed.


We want to adopt a consistent style for PowerShell code blocks and output in our documentation.
The existing documentation has uses multiple styles and the formatting rules have changed multiple times.
The current Open Publishing System (OPS) we use has a syntax highlighting feature that support many languages.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"supports"

[-ParameterType <PSTypeName[]>] [<CommonParameters>]
```

This is example is illustrating all of the possible parameters of the `Get-Command` cmdlet.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"This example"

However, not all examples in our documentation are intended to be run.
Some code blocks are simple illustrations of a PowerShell concept.

We are defining two scenarios for code blocks:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the delineation here, hits the nail on the head.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


## Formatting executable examples

More complex examples or examples that would be useful to copy and execute should use <code>\`\`\`powershell</code> &hellip; <code>\`\`\`</code> code fence markers.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just an FYI, but I believe you can do this like:

`` ```powershell `` ... `` ``` ``

which will render as:

```powershell ... ```

Source: https://gist.github.com/mcandre/8d76e076b2495fd8b36f439ec5033116

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This formatting was submitted by an external contributor and I accepted it then. The use of spaces gets dicey (especially if you get it wrong) and is harder to see the intent of the formatting.


- Code fences

Markdown allows for indentation to signal code block, however, all code blocks should be contained in a code fence.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"to signal" sounds a little weird, maybe "to signify" or "Markdown supports indentation for rendering code blocks"?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

- Code fences

Markdown allows for indentation to signal code block, however, all code blocks should be contained in a code fence.
A code fence is a block of code surrounded by <code>\`\`\`</code> strings.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another opportunity for double backticks if you want 'em

`` ``` ``

- Line continuation in code samples

Avoid using line continuation characters (\`) in PowerShell code examples.
These are a hard to see and can cause problems if there are extra spaces on the end of the line.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"These are hard to see"

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@saldana
Copy link
Copy Markdown
Contributor

saldana commented Dec 14, 2017

✅ Validation status: passed

File Status Preview URL Details
CONTRIBUTING.md ✅Succeeded
contributing/FORAMTTING-CODE.md ✅Succeeded
contributing/STYLE.md ✅Succeeded

For more details, please refer to the build report.

Note: If you changed an existing file name or deleted a file, broken links in other files to the deleted or renamed file are listed only in the full build report.

@saldana
Copy link
Copy Markdown
Contributor

saldana commented Dec 14, 2017

✅ Validation status: passed

File Status Preview URL Details
CONTRIBUTING.md ✅Succeeded
contributing/FORAMTTING-CODE.md ✅Succeeded
contributing/STYLE.md ✅Succeeded

For more details, please refer to the build report.

Note: If you changed an existing file name or deleted a file, broken links in other files to the deleted or renamed file are listed only in the full build report.

@saldana
Copy link
Copy Markdown
Contributor

saldana commented Dec 14, 2017

✅ Validation status: passed

File Status Preview URL Details
CONTRIBUTING.md ✅Succeeded
contributing/FORAMTTING-CODE.md ✅Succeeded
contributing/STYLE.md ✅Succeeded

For more details, please refer to the build report.

Note: If you changed an existing file name or deleted a file, broken links in other files to the deleted or renamed file are listed only in the full build report.

@joeyaiello joeyaiello merged commit 4a0e687 into MicrosoftDocs:staging Dec 14, 2017
@sdwheeler sdwheeler deleted the sdw-codestyle branch January 5, 2018 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants