Skip to content

Repo sync for protected CLA branch #4059

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 101 additions & 57 deletions styleguide/template.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# Metadata and Markdown Template
# Metadata and Markdown Template for C++ Docs

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).
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).

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.

## Metadata

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:
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:

- You **must** have a space between the colon (:) and the value for a metadata element.
- 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 #.
- 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"`).
- **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).
- **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.
- **ms.devlang** defines the technology. Some of the supported values are: `dotnet`, `cpp`, `csharp`, `fsharp`, `vb` and `xml`.
- **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/).
- You **must** have a space between the colon (`:`) and the value for a metadata element.
- 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 `#`.
- 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"`).
- **`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).
- **`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.
- **`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`.
- **`ms.assetid`**: Don't set this value in new articles. It exists only as a historical link to archived versions of the document.

## Basic Markdown, GFM, and special characters

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

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

- Put a backslash before the special character to "escape" it (for example, `\*` for a \*)
- Use the [HTML entity code](https://www.ascii.cl/htmlcodes.htm) for the character (for example, `*` for a *).
- 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.

## Markdown editing tools

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

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

## File name

File names use the following rules:

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

## Headings

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

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.
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.

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

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# #`.
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# #`.

There should always be one blank line before and after a heading (except for first-level headings).
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).

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

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

## Text styling

*Italics*
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).
*Italics*\
\*Italics\*\
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).

**Bold**
Use for UI elements and language keywords.
**Bold**\
\*\*Bold\*\*\
Use for UI elements.

**`Bold Code`**\
\*\*\`Bold Code\`\*\*\
Use for keywords, operators, and compiler and tool options.

*`Italic Code`*\
\*\`Italic Code\`\*\
Use for parameters.

`Inline Code`\
\`Inline Code\`\
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.

> Blockquote\
\> Blockquote

Use blockquote for error and warning messages, syntax sections, and EBNF content.

## Links

### Internal Links

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`).
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"`.
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`).
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"`.

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

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

### Docs Links

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.
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.

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

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

### Links to APIs

The build system has some extensions that allow us to link to .NET Core APIs without having to use external links.
The build system has some extensions that allow us to link to Managed APIs without having to use external links.

When linking to an API, you can use its unique identifier (UID) that is auto-generated from the source code.

You can use one of the following syntax:
You can use one of the following syntax forms:

1. Markdown link: `[link_text](xref:UID)`
2. Auto link: `<xref:UID>`
Expand All @@ -135,7 +156,7 @@ For more information about using this notation, see [Using cross reference](http

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:

- Example: @System.Threading.Tasks.Task\`1 becomes `@System.Threading.Tasks.Task%601`
- Example: `@System.Threading.Tasks.Task\`1` becomes `@System.Threading.Tasks.Task%601`
- Example: @System.Exception.\#ctor becomes `@System.Exception.%23ctor`

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

### Ordered lists

1. This
1. Is
1. Example
1. Of
1. An
1. Ordered
1. List
Expand All @@ -156,30 +177,30 @@ Lists should be surrounded by blank lines.
1. comes
1. an
1. embedded
1. Miss Scarlett
1. Professor Plum
1. Scarlet
1. Plum
1. ordered
1. list

### Unordered Lists

- This
- is
- Example
- of
- a
- bulleted
- list

#### Unordered list with an embedded list

- This
- Sometimes
- bulleted
- list
- Mrs. Peacock
- Mr. Green
- contains
- lists
- Chartreuse
- Lime
- contain
- other
1. Colonel Mustard
1. Mrs. White
1. Magenta
1. Fuchsia
- lists

## Horizontal rule
Expand All @@ -188,13 +209,14 @@ ___

## Tables

| Tables | Are | Cool |
| ------------- |:-------------:| -----:|
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| col 1 is default | left-aligned | $1 |
| Tables | Are | Cool |
|--|:-:|-:|
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| col 1 is default | left-aligned | $1 |

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).
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.

## Code

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

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

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

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

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

### Inline code blocks with language identifier

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).
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).

#### C++

```cpp
#include <iostream>
int main()
{
std::cout << "Hello World!\n";
}
```

#### C

```C
#include <stdio.h>
int main()
{
printf("Hello World!\n");
}
```

#### C\#

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

## Videos

### Channel 9
### Shows

[![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)
](https://channel9.msdn.com/Blogs/TheChannel9Team/Larry-Osterman-His-one-interaction-with-Bill-Gates-over-DOS-networking-stack)
[![C++ A General Purpose Language and Library: (01) Getting Started](https://docs.microsoft.com/video/media/e8265f2d-9ea3-4052-99cd-b8cfb246b0f0/clanguagelibrarym01_960.jpg)
](https://docs.microsoft.com/en-us/shows/cplusplus-language-library/01)\
C++ A General Purpose Language and Library: (01) Getting Started.

### YouTube

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

## docs.microsoft extensions

docs.microsoft provides a few additional extensions to GitHub Flavored Markdown.
docs.microsoft provides a few more extensions to GitHub Flavored Markdown.

### Alerts

Expand Down