Skip to content

Commit 009a383

Browse files
committed
Merging changes synced from https://github.com/MicrosoftDocs/cpp-docs-pr (branch live)
2 parents 26c26ac + 88a9b3d commit 009a383

File tree

1 file changed

+101
-57
lines changed

1 file changed

+101
-57
lines changed

styleguide/template.md

Lines changed: 101 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
# Metadata and Markdown Template
1+
# Metadata and Markdown Template for C++ Docs
22

3-
This core-docs template contains examples of Markdown syntax, as well as guidance on setting the metadata. To get the most of it, you must view both the [raw Markdown](https://raw.githubusercontent.com/dotnet/docs/master/styleguide/template.md) and the [rendered view](https://github.com/dotnet/docs/blob/master/styleguide/template.md) (for instance, the raw Markdown shows the metadata block, while the rendered view does not).
3+
This C++ repo-specific core-docs template contains examples of Markdown syntax, and guidance on setting the metadata. To get the most of it, you must view both the [raw Markdown](https://raw.githubusercontent.com/MicrosoftDocs/cpp-docs/main/styleguide/template.md) and the [rendered view](https://github.com/MicrosoftDocs/cpp-docs/blob/master/styleguide/template.md) (for instance, the raw Markdown shows the metadata block, while the rendered view doesn't).
44

55
When creating a Markdown file, you should copy this template to a new file, fill out the metadata as specified below, set the H1 heading above to the title of the article, and delete the content.
66

77
## Metadata
88

9-
The full metadata block is above (in the [raw Markdown](https://raw.githubusercontent.com/dotnet/docs/master/styleguide/template.md)), divided into required fields and optional fields. Some key notes:
9+
The full metadata block is yaml data between two lines that only contain `---` at the top of the document contents (in the [raw Markdown](https://raw.githubusercontent.com/MicrosoftDocs/cpp-docs/main/styleguide/template.md)). It's divided into required fields and optional fields. Some key notes:
1010

11-
- You **must** have a space between the colon (:) and the value for a metadata element.
12-
- If an optional metadata element does not have a value, comment out the element with a # or remove it (do not leave it blank or use "na"); if you are adding a value to an element that was commented out, be sure to remove the #.
13-
- Colons in a value (for example, a title) break the metadata parser. In this case, surround the title with double quotes (for example, `title: "Writing .NET Core console apps: An advanced step-by-step guide"`).
14-
- **title**: This title will appear in search engine results. You can also add a pipe (|) followed by the product name (for example, `title: Developing Libraries with Cross Platform Tools | .NET Core`). The title doesn't need be identical to the title in your H1 heading and it should contain 65 characters or less (including | PRODUCT NAME).
15-
- **author**, **manager**, **ms.reviewer**: The author field should contain the **GitHub username** of the author, not their alias. The "manager" and "ms.reviewer" fields, on the other hand, should contain Microsoft aliases. ms.reviewer specifies the name of the PM/dev associated with the article or feature.
16-
- **ms.devlang** defines the technology. Some of the supported values are: `dotnet`, `cpp`, `csharp`, `fsharp`, `vb` and `xml`.
17-
- **ms.assetid**: This is the GUID of the article that is used for internal tracking purposes such as Business Intelligence (BI). When creating a new Markdown file, you can get a GUID from [Online GUID Generator](https://www.guidgenerator.com/).
11+
- You **must** have a space between the colon (`:`) and the value for a metadata element.
12+
- If an optional metadata element doesn't have a value, comment out the element with a `#` or remove it (don't leave it blank or use "na"); if you're adding a value to an element that was commented out, be sure to remove the `#`.
13+
- Colons in a value (for example, a title) break the metadata parser. In this case, surround the title with double quotes (for example, `title: "Writing Windows console apps: An advanced step-by-step guide"`).
14+
- **`title`**: This title will appear in search engine results. You can also add a pipe (|) followed by the product name (for example, `title: Developing Libraries with Cross Platform Tools | Microsoft C++`). The default product name is set in the *`docfx.json`* file, so only specify it if necessary. The title doesn't need to be identical to the title in your H1 heading. It should contain 65 characters or less (including \| PRODUCT NAME).
15+
- **`author`**, **`manager`**, **`ms.author`**: These values are optional and will default to per-directory settings in the *`docfx.json`* file. Set them only if the value is different from the default. The `author` field should contain the **GitHub username** of the author, not their alias. The `manager` and `ms.author` fields, on the other hand, should contain Microsoft aliases. We don't normally include the **`ms.reviewer`** value, but if present, it specifies the name of the PM/dev associated with the article or feature.
16+
- **`ms.devlang`** defines the technology. This value is optional and will default to per-directory settings in the *`docfx.json`* file. Set it only if the value is different from the default. Some of the supported values are: `dotnet`, `cpp`, `csharp`, `fsharp`, `vb` and `xml`.
17+
- **`ms.assetid`**: Don't set this value in new articles. It exists only as a historical link to archived versions of the document.
1818

1919
## Basic Markdown, GFM, and special characters
2020

21-
All basic and GitHub Flavored Markdown (GFM) is supported. For more information on these, see:
21+
All basic and GitHub Flavored Markdown (GFM) is supported. For more information on Markdown, see:
2222

2323
- [Baseline Markdown syntax](https://daringfireball.net/projects/markdown/syntax)
2424
- [GFM documentation](https://guides.github.com/features/mastering-markdown)
@@ -27,24 +27,25 @@ Markdown uses special characters such as \*, \`, and \# for formatting. If you w
2727

2828
- Put a backslash before the special character to "escape" it (for example, `\*` for a \*)
2929
- Use the [HTML entity code](https://www.ascii.cl/htmlcodes.htm) for the character (for example, `*` for a *).
30+
- Markdown allows you to use two spaces at the end of a line to indicate a line break. Because the spaces are invisible in most editors and easy to break, use the alternative of a single backslash (`\`) instead.
3031

3132
## Markdown editing tools
3233

3334
You can use [Visual Studio Code](https://code.visualstudio.com/) to edit Markdown documents. VS Code has many helpful Markdown extensions, such as:
3435

35-
- [docs-markdown](https://marketplace.visualstudio.com/items?itemName=docsmsft.docs-markdown) by Microsoft
36+
- [Docs Authoring Pack](https://marketplace.visualstudio.com/items?itemName=docsmsft.docs-authoring-pack) by Microsoft
3637
- [markdownlint](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint)
3738

3839
## File name
3940

4041
File names use the following rules:
4142

4243
- Contain only lowercase letters, numbers, and hyphens.
43-
- No spaces or punctuation characters. Use the hyphens to separate words and numbers in the file name.
44-
- Use action verbs that are specific, such as develop, buy, build, troubleshoot. No -ing words.
45-
- No small words - don't include a, and, the, in, or, etc.
46-
- Must be in Markdown and use the .md file extension.
47-
- Keep file names reasonably short. They are part of the URL for your articles.
44+
- No spaces or punctuation characters. Use hyphens to separate words and numbers in the file name.
45+
- Use action verbs that are specific, such as "develop", "buy", "build", "troubleshoot". Don't use "-ing" words.
46+
- No small words: Don't include "a", "and", "the", "in", "or", and so on.
47+
- Must be in Markdown and use the `.md` file extension.
48+
- Keep file names reasonably short. They're part of the URL for your articles.
4849

4950
## Headings
5051

@@ -53,13 +54,13 @@ Use sentence-style capitalization. Always capitalize:
5354
- The first word of a heading.
5455
- The word following a colon in a title or heading (for example, "How to: Sort an array").
5556

56-
Headings should be done using atx-style, that is, use 1-6 hash characters (#) at the start of the line to indicate a heading, corresponding to HTML headings levels H1 through H6. Examples of first- and second-level headers are used above.
57+
Headings should be done using atx-style, that is, use 1-6 hash characters (`#`) at the start of the line to indicate a heading, corresponding to HTML headings levels H1 through H6. Examples of first- and second-level headers are used above.
5758

58-
There **must** be only one first-level heading (H1) in your topic, which will be displayed as the on-page title.
59+
There **must** be only one first-level heading (H1) in your article, which will be displayed as the on-page title.
5960

60-
If your heading finishes with a `#` character, you need to add an extra `#` character in the end in order for the title to render correctly. For example, `# Async Programming in F# #`.
61+
If your heading ends with a `#` character, you need to add an extra `#` character in the end in order for the title to render correctly. For example, `# Async Programming in F# #`.
6162

62-
There should always be one blank line before and after a heading (except for first-level headings).
63+
There should always be one blank line before and after a heading (except for first-level headings, which shouldn't have a blank line before).
6364

6465
Second-level headings will generate the on-page TOC that appears in the "In this article" section underneath the on-page title.
6566

@@ -75,18 +76,37 @@ Second-level headings will generate the on-page TOC that appears in the "In this
7576

7677
## Text styling
7778

78-
*Italics*
79-
Use for user-generated filenames, folders, and paths (for long items, split onto their own line); new terms; parameter names; user-entered values; and URLs (unless rendered as links, which is the default).
79+
*Italics*\
80+
\*Italics\*\
81+
Use for user-generated filenames, folders, and paths (for long items, split onto their own line); new terms; user-entered values; and URLs (unless rendered as links, which is the default).
8082

81-
**Bold**
82-
Use for UI elements and language keywords.
83+
**Bold**\
84+
\*\*Bold\*\*\
85+
Use for UI elements.
86+
87+
**`Bold Code`**\
88+
\*\*\`Bold Code\`\*\*\
89+
Use for keywords, operators, and compiler and tool options.
90+
91+
*`Italic Code`*\
92+
\*\`Italic Code\`\*\
93+
Use for parameters.
94+
95+
`Inline Code`\
96+
\`Inline Code\`\
97+
Use for non-localizable elements such as library function names, preprocessor macros, fixed filenames, and inline code such as a single variable, expression, or statement.
98+
99+
> Blockquote\
100+
\> Blockquote
101+
102+
Use blockquote for error and warning messages, syntax sections, and EBNF content.
83103

84104
## Links
85105

86106
### Internal Links
87107

88-
To link to a header in the same Markdown file (also known as anchor links), you'll need to find out the id of the header you're trying to link to. To confirm the ID, view the source of the rendered article, find the id of the header (for example, `id="blockquote"`), and link using # + id (for example, `#blockquote`).
89-
The id is auto-generated based on the header text. So, for example, given a unique section named `## Step 2`, the id would look like this `id="step-2"`.
108+
To link to a header in the same Markdown file (also known as anchor links), you'll need to find out the ID of the header you're trying to link to. To confirm the ID, view the source of the rendered article, find the ID of the header (for example, `id="blockquote"`), and link using `#` + ID (for example, `#blockquote`).
109+
The ID is auto-generated based on the header text. So, for example, given a unique section named `## Step 2`, the ID would look like this `id="step-2"`.
90110

91111
- Example: [Chapter 1](#chapter-1)
92112

@@ -101,7 +121,7 @@ To link to a header in a Markdown file in the same repo, use relative linking +
101121

102122
### Docs Links
103123

104-
To link to a file in a different Docs repo, use the docs.microsoft.com relative URL as the link. Do not include the .md suffix.
124+
To link to a file in a different Docs repo, use the docs.microsoft.com relative URL as the link. Don't include the .md suffix or the language/locale element.
105125

106126
- Example: [Universal Windows Platform documentation](/windows/uwp)
107127

@@ -117,10 +137,11 @@ If a URL appears in a Markdown file, it will be transformed into a clickable lin
117137

118138
### Links to APIs
119139

120-
The build system has some extensions that allow us to link to .NET Core APIs without having to use external links.
140+
The build system has some extensions that allow us to link to Managed APIs without having to use external links.
141+
121142
When linking to an API, you can use its unique identifier (UID) that is auto-generated from the source code.
122143

123-
You can use one of the following syntax:
144+
You can use one of the following syntax forms:
124145

125146
1. Markdown link: `[link_text](xref:UID)`
126147
2. Auto link: `<xref:UID>`
@@ -135,7 +156,7 @@ For more information about using this notation, see [Using cross reference](http
135156
136157
When the UID contains the special characters \` or \#, the UID value needs to be HTML encoded as %60 and %23 respectively as in the following examples:
137158

138-
- Example: @System.Threading.Tasks.Task\`1 becomes `@System.Threading.Tasks.Task%601`
159+
- Example: `@System.Threading.Tasks.Task\`1` becomes `@System.Threading.Tasks.Task%601`
139160
- Example: @System.Exception.\#ctor becomes `@System.Exception.%23ctor`
140161

141162
## Lists
@@ -144,8 +165,8 @@ Lists should be surrounded by blank lines.
144165

145166
### Ordered lists
146167

147-
1. This
148-
1. Is
168+
1. Example
169+
1. Of
149170
1. An
150171
1. Ordered
151172
1. List
@@ -156,30 +177,30 @@ Lists should be surrounded by blank lines.
156177
1. comes
157178
1. an
158179
1. embedded
159-
1. Miss Scarlett
160-
1. Professor Plum
180+
1. Scarlet
181+
1. Plum
161182
1. ordered
162183
1. list
163184

164185
### Unordered Lists
165186

166-
- This
167-
- is
187+
- Example
188+
- of
168189
- a
169190
- bulleted
170191
- list
171192

172193
#### Unordered list with an embedded list
173194

174-
- This
195+
- Sometimes
175196
- bulleted
176-
- list
177-
- Mrs. Peacock
178-
- Mr. Green
179-
- contains
197+
- lists
198+
- Chartreuse
199+
- Lime
200+
- contain
180201
- other
181-
1. Colonel Mustard
182-
1. Mrs. White
202+
1. Magenta
203+
1. Fuchsia
183204
- lists
184205

185206
## Horizontal rule
@@ -188,13 +209,14 @@ ___
188209

189210
## Tables
190211

191-
| Tables | Are | Cool |
192-
| ------------- |:-------------:| -----:|
193-
| col 3 is | right-aligned | $1600 |
194-
| col 2 is | centered | $12 |
195-
| col 1 is default | left-aligned | $1 |
212+
| Tables | Are | Cool |
213+
|--|:-:|-:|
214+
| col 3 is | right-aligned | $1600 |
215+
| col 2 is | centered | $12 |
216+
| col 1 is default | left-aligned | $1 |
196217

197218
You can use a [Markdown table generator tool](https://www.tablesgenerator.com/markdown_tables) to help creating them more easily. See also [Markdown editing tools](#markdown-editing-tools).
219+
The C++ standard is to use the table format created by the **`Docs: Consolidate selected table`** tool in the Docs Authoring Pack. Don't try to align the vertical lines in your tables; it's extra work that's easy to break.
198220

199221
## Code
200222

@@ -224,7 +246,7 @@ code that should be included. Use the `#region` and `#endregion` preprocessor sy
224246
to specify the region of code to include.
225247

226248
For cases where regions don't work, you can specify the start and end of a snippet
227-
using an XML element name in a single line comment. For example, you could write this in C#:
249+
using an XML element name in a single line comment. For example, you could write this sample region in C#:
228250

229251
```csharp
230252
// <CodeToInclude>
@@ -237,15 +259,35 @@ int sum = i + j;
237259
In other languages, use the comment syntax for that language.
238260

239261
Finally, you can use line numbers: `#L1-L10` would include lines 1 through 10. We discourage line numbers
240-
because they are very brittle.
262+
because they're brittle.
241263

242264
Including snippets from full programs ensures that all code runs through our Continuous Integration (CI)
243265
system. However, if you need to show something that causes compile time or runtime errors, you can
244266
use inline code blocks.
245267

246268
### Inline code blocks with language identifier
247269

248-
Use three backticks (\`\`\`) + a language ID to apply language-specific color coding to a code block. Here is the entire list of [GFM language IDs](https://github.com/jmm/gfm-lang-ids/wiki/GitHub-Flavored-Markdown-(GFM)-language-IDs).
270+
Use three backticks (\`\`\`) + a language ID to apply language-specific color coding to a code block. Here's the entire list of [GFM language IDs](https://github.com/jmm/gfm-lang-ids/wiki/GitHub-Flavored-Markdown-(GFM)-language-IDs).
271+
272+
#### C++
273+
274+
```cpp
275+
#include <iostream>
276+
int main()
277+
{
278+
std::cout << "Hello World!\n";
279+
}
280+
```
281+
282+
#### C
283+
284+
```C
285+
#include <stdio.h>
286+
int main()
287+
{
288+
printf("Hello World!\n");
289+
}
290+
```
249291

250292
#### C\#
251293

@@ -318,19 +360,21 @@ Use backticks (&#96;) for `inline code`. Use inline code for command-line comman
318360

319361
## Videos
320362

321-
### Channel 9
363+
### Shows
322364

323-
[![Larry Osterman - His one interaction with Bill Gates (over DOS networking stack).](https://sec.ch9.ms/ch9/caf5/f8657a22-5b83-47a3-9748-4c1be9fecaf5/Larry-Osterman-His-one-interaction-with-Bill-Gate_960.jpg)
324-
](https://channel9.msdn.com/Blogs/TheChannel9Team/Larry-Osterman-His-one-interaction-with-Bill-Gates-over-DOS-networking-stack)
365+
[![C++ A General Purpose Language and Library: (01) Getting Started](https://docs.microsoft.com/video/media/e8265f2d-9ea3-4052-99cd-b8cfb246b0f0/clanguagelibrarym01_960.jpg)
366+
](https://docs.microsoft.com/en-us/shows/cplusplus-language-library/01)\
367+
C++ A General Purpose Language and Library: (01) Getting Started.
325368

326369
### YouTube
327370

328371
[![On .NET 2/4/2016 - Scott Hunter.](https://img.youtube.com/vi/g2a4W6Q7aRw/0.jpg)
329-
](https://www.youtube.com/watch?v=g2a4W6Q7aRw)
372+
](https://www.youtube.com/watch?v=g2a4W6Q7aRw)\
373+
On .NET 2/4/2016 - Scott Hunter.
330374

331375
## docs.microsoft extensions
332376

333-
docs.microsoft provides a few additional extensions to GitHub Flavored Markdown.
377+
docs.microsoft provides a few more extensions to GitHub Flavored Markdown.
334378

335379
### Alerts
336380

0 commit comments

Comments
 (0)