Skip to content

Commit bf25907

Browse files
committed
Put the examples together in a more cohesive manner
1 parent 5cf34d9 commit bf25907

File tree

25 files changed

+648
-1695
lines changed

25 files changed

+648
-1695
lines changed

docs/csharp/language-reference/xmldoc/examples.md

Lines changed: 21 additions & 519 deletions
Large diffs are not rendered by default.

docs/csharp/language-reference/xmldoc/recommended-tags.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ C# documentation comments use XML elements to define the structure of the output
100100
- Documentation text should be written using complete sentences ending with full stops.
101101
- Partial classes are fully supported, and documentation information will be concatenated into a single entry for that type.
102102

103+
XML documentation starts with `///`. When you create a new project, the templates put some starter `///` lines in for you. The processing of these comments has some restrictions:
104+
105+
- The documentation must be well-formed XML. If the XML is not well-formed, a warning is generated and the documentation file will contain a comment that says that an error was encountered.
106+
- Developers are free to create their own set of tags. Some of the recommended tags have special meanings:
107+
- The `<param>` tag is used to describe parameters. If used, the compiler verifies that the parameter exists and that all parameters are described in the documentation. If the verification fails, the compiler issues a warning.
108+
- The `cref` attribute can be attached to any tag to reference a code element. The compiler verifies that this code element exists. If the verification fails, the compiler issues a warning. The compiler respects any `using` statements when it looks for a type described in the `cref` attribute.
109+
- The `<summary>` tag is used by IntelliSense inside Visual Studio to display additional information about a type or member.
110+
> [!NOTE]
111+
> The XML file does not provide full information about the type and members (for example, it does not contain any type information). To get full information about a type or member, use the documentation file together with reflection on the actual type or member.
112+
103113
Some of the recommended tags can be used on any language element. Others have more specialized usage. Finally, some of the tags are used to format text in your documentation. this article describes the recommended tags organized by their use:
104114

105115
- [General Tags](#general-tags) used for multiple elements - These are the minimum set for any API tasks.
@@ -123,8 +133,8 @@ Some of the recommended tags can be used on any language element. Others have mo
123133
- [Generate links and references](#generate-links-and-references) - These tags generate links to other documentation.
124134
- [`<see>`](#see) \*
125135
- [`<seealso>`](#seealso) \*
126-
- [`<cref>`](#cref)
127-
- [`<href>`](#href)
136+
- [`<cref>`](#cref-attribute)
137+
- [`<href>`](#href-attribute)
128138
- [Tags for generic types and methods](#generic-types-and-methods) - These tags are used only on generic types and methods
129139
- [`<typeparam>`](#typeparam) \*
130140
- [`<typeparamref>`](#typeparamref)
@@ -334,15 +344,15 @@ The `<see>` tag lets you specify a link from within text. Use [\<seealso>](#seea
334344
- `cref="member"`: A reference to a member or field that is available to be called from the current compilation environment. The compiler checks that the given code element exists and passes `member` to the element name in the output XML.`member` must appear within double quotation marks (" ").
335345
- `href="link"`: A clickable link to a given URL. For example, `<seealso href="https://github.com">GitHub</seealso>` produces a clickable link with text :::no-loc text="GitHub"::: that links to `https://github.com`.
336346

337-
The `<seealso>` tag lets you specify the text that you might want to appear in a See Also section. Use [\<see>](#see) to specify a link from within text.
347+
The `<seealso>` tag lets you specify the text that you might want to appear in a **See Also** section. Use [\<see>](#see) to specify a link from within text.
338348

339349
### cref attribute
340350

341351
The `cref` attribute in an XML documentation tag means "code reference." It specifies that the inner text of the tag is a code element, such as a type, method, or property. Documentation tools like [DocFX](https://dotnet.github.io/docfx/) and [Sandcastle](https://github.com/EWSoftware/SHFB) use the `cref` attributes to automatically generate hyperlinks to the page where the type or member is documented.
342352

343-
The following example shows `cref` attributes used in [\<see>](#see) tags.
353+
### href attribute
344354

345-
### href
355+
The `href` attribute means a reference to a web page. You can use it to directly reference online documentation about your API or library.
346356

347357
## Generic types and methods
348358

@@ -365,3 +375,10 @@ The `<typeparam>` tag should be used in the comment for a generic type or method
365375
- `TKey`: The name of the type parameter. Enclose the name in double quotation marks (" ").
366376

367377
Use this tag to enable consumers of the documentation file to format the word in some distinct way, for example in italics.
378+
379+
### User-defined tags
380+
381+
All the tags outlined above represent those that are recognized by the C# compiler. However, a user is free to define their own tags.
382+
Tools like Sandcastle bring support for extra tags like [\<event>](https://ewsoftware.github.io/XMLCommentsGuide/html/81bf7ad3-45dc-452f-90d5-87ce2494a182.htm) and [\<note>](https://ewsoftware.github.io/XMLCommentsGuide/html/4302a60f-e4f4-4b8d-a451-5f453c4ebd46.htm),
383+
and even support [documenting namespaces](https://ewsoftware.github.io/XMLCommentsGuide/html/BD91FAD4-188D-4697-A654-7C07FD47EF31.htm).
384+
Custom or in-house documentation generation tools can also be used with the standard tags and multiple output formats from HTML to PDF can be supported.

0 commit comments

Comments
 (0)