mdoc(5)
πΈ mdoc(5) β Mono Documentation XML Format πΈ
okay bestie, pull up a chair, because this is the manual page for mdoc, the Mono Documentation XML Format, and it's genuinely a whole vibe. π This is the format page β the file formats manual β so it's all about the XML schema that the Mono doc tools all share. it's giving "everything you ever wanted to know about doc XML" and honestly? we're obsessed. β¨
β¨ NAME β¨
mdoc β Mono Documentation XML Format π¦
π DESCRIPTION π
so the assorted Mono documentation programs generate or manipulate XML files following the mono documentation schema. here's the squad: π
mdoc updateβ Creates or updates mono documentation XML for a set of assemblies.mdoc validateβ Validates the mono documentation XML against the mono documentation XML schema.mdoc assembleβ Converts the mono documentation XML within a directory structure into a set of files for use withmonodoc(1).mdoc export-htmlβ Converts the mono documentation XML within a directory structure into a set of HTML files that can be viewed with a web browser.
All of these tools (and more) use the common XML schema described in this man page. no cap, every single one. π₯
π FILE/DIRECTORY STRUCTURE π
There are three sets of Mono documentation XML files:
index.xml: contains a list of all assemblies within the containing directory, and all types and namespaces within those assemblies. πns-*.xml: There is onens-*.xmlfile for each namespace within the assembly; these files are siblings toindex.xml.
Examples of ns-*.xml files include: ns-System.xml, ns-System.Collections.xml, and ns-.xml (for the root namespace, though it is recommended to NOT place types into the root namespace, as monodoc(1) doesn't display them).
The ns-*.xml files contain per-namespace documentation.
NamespaceName/TypeName.xml: These files are within a dotted NamespaceName directory, and TypeName is the name of the type.
Examples include: RootType.xml (if the type has no namespace), System/String.xml, System.Collections/IEnumerable.xml, and System.Collections.Generic/List1+Enumerator.xml(the ``1 `` is the number of generic type parameters the type accepts, and everything after the + is a nested type).
Thus, typical directory contents would resemble:
index.xml
ns-System.xml
ns-System.Collections.Generic.xml
System/String.xml
System.Collections.Generic/List`1.xml
π DOCUMENTATION FORMAT π
π index.xml File Format π
The index.xml file contains a list of the assemblies nested under the directory containing index.xml and all namespaces and types within those assemblies. It looks something like this:
<Overview>
<Assemblies>
<Assembly Name="mscorlib" Version="2.0.0.0" />
<!-- other <Assembly/> elements... -->
</Assemblies>
<Remarks>To be added.</Remarks>
<Copyright>To be added.</Copyright>
<Types>
<Namespace Name="System">
<Type Name="String" />
<!-- Other <Type/> elements -->
</Namespace>
<Namespace Name="System.Collections.Generic">
<Type Name="List`1" DisplayName="List<T>" />
<!-- Other <Type/> elements -->
</Namespace>
<!-- other <Namespace/> elements -->
</Types>
<Title>DocTest</Title>
</Overview>
Most of this is maintained automatically, in particular the /Overview/Assemblies and /Overview/Types elements. π€ (not you having to touch it, bestie β the tooling handles it.)
The //Namespace/@Name attribute corresponds to a directory which contains files named //Type/@Name.xml, while the //Type/@DisplayName attribute contains a C# type name (if //Type/@DisplayName isn't found, then //Type/@Name is used as the display name). There should also be a ns-[//Namespace/@Name].xml file.
There are three elements of interest to authors: /Overview/Remarks, /Overview/Copyright, and /Overview/Title, which contain assembly-level documentation. These elements can contain any of the following XML elements (documented in the Documentation XML Elements section): block, code, example, list, para, paramref, typeparamref, see, and ul. βοΈ
π¦ ns-*.xml File Format π¦
The ns-*.xml files contain namespace documentation:
<Namespace Name="System">
<Docs>
<summary>To be added.</summary>
<remarks>To be added.</remarks>
</Docs>
</Namespace>
The /Namespace/Docs/summary and /Namespace/Docs/remarks elements should contain namespace documentation.
The remarks and summary elements are documented in the Documentation XML Elements section. π
β¨ NamespaceName/TypeName.xml File Format β¨
The mono documentation format is similar to the Ecma documentation format, as described in ECMA-335 3rd Edition, Partition IV, Chapter 7. The principal difference from the ECMA format is that each type gets its own file, within a directory identical to the namespace of the type. There is a lot of information that is maintained automatically by mdoc(1); Most of the information within the documentation should not be edited. This includes the type name (/Type/@FullName), implemented interfaces (/Type/Interfaces), member information (/Type/Members/Member/@MemberName, /Type/Members/Member/MemberSignature, /Type/Members/Member/MemberType, /Type/Members/Member/Parameters, etc.). π (hands off those, fr fr.)
<Type Name="DocAttribute" FullName="Mono.DocTest.DocAttribute">
<TypeSignature Language="C#" Value="public class DocAttribute : Attribute" />
<AssemblyInfo>
<AssemblyName>DocTest</AssemblyName>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Attribute</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute>
<AttributeName>System.AttributeUsage(System.AttributeTargets.All)</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>To be added.</summary>
<remarks>To be added.</remarks>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public DocAttribute (string docs);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyVersion>0.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="docs" Type="System.String" />
</Parameters>
<Docs>
<param name="docs">To be added.</param>
<summary>To be added.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
</Type>
The only elements that normally need to be edited are children of the //Docs elements, which usually contain the text To be added. The /Type/Docs element contains type-level documentation, while the /Type/Members/Member/Docs element contains per-member documentation. π
The //Docs elements can contain the following elements: altcompliant, altmember, example, exception, param, permission, remarks, returns, since, summary, threadsafe, typeparam, and value.
β οΈ Nested types are not members; they are types, and are documented in their own file. Consequently, theNamespaceName/TypeName.xmlfiles are not recursive; you do not store a<Type/>element within a<Type/>element. like, don't do it bestie, it's not the move. π
π Documentation XML Elements π
The contents of the Docs element is identical in semantics and structure to the inline C# documentation format, consisting of these elements (listed in ECMA-334 3rd Edition, Annex E, Section 2). The following are used within the element descriptions:
CREFβ Refers to a class (or member) reference, and is a string in the format described below in the CREF FORMAT section.TEXTβ Non-XML text, and XML should not be nested.XMLβ Only XML elements should be nested (which indirectly may contain text), but non-whitespace text should not be an immediate child node.XML_TEXTβ Free-form text and XML, so that other XML elements may be nested.
The following elements are used in documentation:
<altmember cref="CREF" />β<altmember/>is a top-level element, and should be nested directly under the<Docs/>element. π«
Allows an entry to be generated for the See Also section. Use <see/> to specify a link from within text.
<altmember cref="P:System.Exception.Message" />
<block subset="SUBSET" type="TYPE">XML_TEXT</block>β Create a block of text, similar in concept to a paragraph, but is used to create divisions within the text. To some extent, a<block/>is equivalent to the HTML<h2/>tag.
SUBSET should always be the value "none".
TYPE specifies the heading and formatting to use. Recognized types are:
behaviorsβ Creates a section with the headingOperation.noteβ Creates a section with the headingNote:.overridesβ Creates a section with the headingNote to Inheritors.usageβ Creates a section with the headingUsage.
The block element can contain the following elements: block, c, code, list, para, paramref, see, subscript, sup, and typeparamref.
<c>XML_TEXT</c>β Set text in a code-like font (similar to the HTML<tt/>element). β¨
The c element can contain the following elements: code, para, paramref, see, and typeparamref.
<code lang="LANGUAGE" src="SOURCE">TEXT</code>β Display multiple lines of text in a code-like font (similar to the HTML<pre/>element).
LANGUAGE is the language this code block is for. For example, if LANGUAGE is C#, then TEXT will get syntax highlighting for the C# language within the Mono Documentation Browser. π₯
SOURCE is only interpreted by mdoc-update(1). If the src attribute is present when mdoc-update(1) is run, then SOURCE is a file (relative to mdoc-update(1)'s --out directory) that should be inserted as the value for TEXT. The contents of TEXT will be ignored by mdoc-update(1) and replaced on every invocation. SOURCE can also contain an "anchor", e.g. src="path/to/file.cs#RegionMarker". If an anchor is present, and LANGUAGE is C#, then #region RegionMarker will be searched for, and the contents between the #region and the following #endregion will be inserted as the value for TEXT element. π
<example>XML_TEXT</example>β Indicates an example that should be displayed specially. For example:
<example>
<para>An introductory paragraph.</para>
<code lang="C#">
class Example {
public static void Main ()
{
System.Console.WriteLine ("Hello, World!");
}
}
</code>
</example>
The example element can contain the following elements: c, code, list, para, and see.
<exception cref="CREF">XML_TEXT</exception>
Identifies an exception that can be thrown by the documented member. π (we love a dramatic exit)
<exception/> is a top-level element, and should be nested directly under the <Docs/> element.
CREF is the exception type that is thrown, while XML_TEXT contains the circumstances that would cause CREF to be thrown.
<exception cref="T:System.ArgumentNullException">
<paramref name="foo" /> was <see langword="null" />.
</exception>
The exception element can contain the following elements: block, para, paramref, see, and typeparamref.
<format type="TYPE">XML_TEXT</format>
The <format/> element is an "escape hatch," for including (possibly XML) content that is not valid mdoc(5) content. It's the moral equivalent of perlpod(1) =begin format blocks. πͺβ¨
TYPE is the mime type of XML_TEXT. mdoc(5) processors may skip <format/> blocks if they use a type that isn't supported.
For example:
<format type="text/html">
<table width="100%">
<tr><td style="color:red">Hello, world!</td></tr>
</table>
</format>
would cause the embedded HTML <table/> element to be inserted inline into the resulting HTML document when mdoc-export-html(1) processes the file. (Likewise, it may be skipped if processed by another program.)
<format/> is intended to simplify importing documentation from existing documentation sources. It should not be relied upon, if at all possible.
<list>XML</list>
Create a list or table of items. <list/> makes use of nested <item>XML</item>, <listheader>XML</listheader>, <term>XML_TEXT</term>, and <description>XML_TEXT</description> elements. π
Lists have the syntax:
<list type="bullet"> <!-- or type="number" -->
<item><term>Bullet 1</term></item>
<item><term>Bullet 2</term></item>
<item><term>Bullet 3</term></item>
</list>
Tables have the syntax:
<list type="table">
<listheader> <!-- listheader bolds this row -->
<term>Column 1</term>
<description>Column 2</description>
<description>Column 3</description>
</listheader>
<item>
<term>Item 1-A</term>
<description>Item 1-B</description>
<description>Item 1-C</description>
</item>
<item>
<term>Item 2-A</term>
<description>Item 2-B</description>
<description>Item 2-C</description>
</item>
</list>
The item and description elements can each contain text and the following elements: block, c, para, paramref, see, sup, and typeparamref.
<para>XML_TEXT</para>
Insert a paragraph of XML_TEXT. For example,
<para>
This is a paragraph of text.
</para>
The para element can contain the following elements: block, c, example, link, list, onequarter, paramref, see, sub, sup, typeparamref, and ul.
<param name="NAME">XML_TEXT</param>
<param/> is a top-level element, and should be nested directly under the <Docs/> element.
Describes the parameter NAME of the current constructor, method, or property:
<param name="count">
A <see cref="T:System.Int32" /> containing the number
of widgets to process.
</param>
The param element can contain the following elements: block, c, example, para, paramref, see, and typeparamref.
<paramref name="NAME" />
Indicates that NAME is a parameter. π«Ά
This usually renders NAME as italic text, so it is frequently (ab)used as an equivalent to the HTML <i/> element. See the <exception/> documentation (above) for an example.
<permission cref="CREF">XML_TEXT</permission>
Documents the security accessibility requirements of the current member. π
<permission/> is a top-level element, and should be nested directly under the <Docs/> element.
CREF is a type reference to the security permission required, while XML_TEXT is a description of why the permission is required.
<permission cref="T:System.Security.Permissions.FileIOPermission">
Requires permission for reading and writing files. See
<see cref="F:System.Security.Permissions.FileIOPermissionAccess.Read" />,
<see cref="F:System.Security.Permissions.FileIOPermissionAccess.Write" />.
</permission>
The permission element can contain the following elements: block, para, paramref, see, and typeparamref.
<remarks>XML_TEXT</remarks>
Contains detailed information about a member. π
<remarks/> is a top-level element, and should be nested directly under the <Docs/> element.
<remarks>
Insert detailed information here.
</remarks>
The remarks element can contain the following elements: block, c, code, example, list, para, paramref, see, and typeparamref.
<returns>XML_TEXT</returns>
<returns/> is a top-level element, and should be nested directly under the <Docs/> element.
Describes the return value of a method:
<returns>
A <see cref="T:System.Boolean" /> specifying whether
or not the process can access
<see cref="P:Mono.Unix.UnixFileSystemInfo.FullName" />.
</returns>
The returns element can contain the following elements: c, format, list, para, paramref, see, and typeparamref.
<see cref="CREF" />, <see langword="LANGWORD" />
Creates a link to the specified member within the current text:
<see cref="M:Some.Namespace.With.Type.Method" />
or specifies that LANGWORD is a language keyword:
<see langword="null" />
<seealso cref="CREF" />
Do not use seealso, use altmember. π That's it, that's the whole vibe. Straight from the source.
<since version="VERSION" />
<since/> is a top-level element, and should be nested directly under the <Docs/> element.
Permits specification of which version introduced the specified type or member.
<since version="Gtk# 2.4" />
This generally isn't required, as the //AssemblyInfo/AssemblyVersion elements track which assembly versions contain type or member.
<summary>XML_TEXT</summary>
<summary/> is a top-level element, and should be nested directly under the <Docs/> element.
Provides a (brief!) overview about a type or type member. β¨ Like, the trailer, not the whole movie.
This is usually displayed as part of a class declaration, and should be a reasonably short description of the type/member. Use <remarks/> for more detailed information.
The summary element can contain the following elements: block, list, para, paramref, see, and typeparamref.
<typeparam name="NAME">XML_TEXT</typeparam>
<typeparam/> is a top-level element, and should be nested directly under the <Docs/> element.
This is used to document a type parameter for a generic type or generic method.
NAME is the name of the type parameter, while XML_TEXT contains a description of the parameter (what it's used for, what restrictions it must meet, etc.).
<typeparam name="T">
The type of the underlying collection
</typeparam>
The typeparam element can contain the following elements: block, c, para, paramref, see, and typeparamref.
<typeparamref name="NAME">
Used to indicate that NAME is a type parameter.
<value>XML_TEXT</value>
<value/> is a top-level element, and should be nested directly under the <Docs/> element.
Allows a property to be described.
<value>
A <see cref="T:System.String" /> containing a widget name.
</value>
The value element can contain the following elements: block, c, example, list, para, paramref, see, and typeparamref.
β¨ CREF FORMAT β¨
okay bestie, so CREFs β String IDs β are literally how you point at a type or a member of a type. The official deets live in ECMA-334 3rd Edition, Annex E.3.1. A CREF is built like: a member type prefix, then the full type name (namespace + name, joined by .), and then maybe the member name and extra stuff if needed. slay β¨
Member type prefixes:
C:β this CREF points at a constructor. The parameter list is optional and goes in parentheses right after the type name:C:System.String(System.Char,System.Int32).E:β this CREF points at an event. The event name follows the type name:E:System.AppDomain.AssemblyLoad.F:β this CREF points at a field. The field name follows the type name:F:System.Runtime.InteropServices.DllImportAttribute.SetLastError.M:β points at a constructor or a method. Constructors can append.ctorto the type name (instead of using theC:constructor format above), while methods append the method name and an optional count of the number of generic parameters. Both constructors and methods can append the method parameter list in parentheses.
Examples:
M:System.Object..ctor,
M:System.String..ctor(System.Char[]),
M:System.String.Concat(System.Object),
M:System.Array.Sort``1(``0[]),
M:System.Collections.Generic.List`1..ctor,
M:System.Collections.Generic.List`1.Add(`0).
N:β points at a namespace, e.g.N:System.P:β points at a property. If the property is an indexer or takes parameters, the parameter types are appended to the property name and enclosed in parentheses:P:System.String.Length,P:System.String.Chars(System.Int32).T:β points at a type, with the number of generic types appended:T:System.String,T:System.Collections.Generic.List`1,T:System.Collections.Generic.List`1.Enumerator.
To make matters more interesting, generic types & members have two representations: the "unbound" representation (shown in examples above), in which class names have the count of generic parameters appended to their name. There is also a "bound" representation, in which the binding of generic parameters is listed within { and } or < and >. (Use of < and > is less common, as within an XML document their escaped character entities must instead be used, leading to < and >.)
Unbound:
T:System.Collections.Generic.List`1T:System.Collections.Generic.Dictionary`2
Bound:
T:System.Collections.Generic.List{System.Int32}T:System.Collections.Generic.List<System.Int32>T:System.Collections.Generic.List<System.Int32>T:System.Predicate{System.Action{System.String}}
As you can see, bound variants can be arbitrarily complex (just like generics). no cap π
Furthermore, if a generic parameter is bound to the generic parameter of a type or method, the "index" of the type/method's generic parameter is used as the binding, so given
class FooType {
public static void Foo<T> (System.Predicate<T> predicate)
{
}
}
The CREF for this method is M:FooType.Foo``1(System.Predicate{``0}), ``0 is the 0th generic parameter index which is bound to System.Predicate<T>.
π SEE ALSO π
go peek at mdoc(1) and monodocer(1) bestie π
π MAILING LISTS π
Visit http://lists.ximian.com/mailman/listinfo/mono-docs-list for details. fr fr π
π WEB SITE π
Visit http://www.mono-project.com for details. iconic β¨
That's the mdoc(5) manual page, bestie. Source/version: mdoc(5). Periodt. π π¦
π¦ where this page comes from
- alpine 3.24: mono-doc 6.14.1-r1 Β· MIT
- arch rolling: mono 6.12.0.206-1 Β· GPL AND LGPL2.1 AND MPL
- debian bookworm: monodoc-base 6.8.0.105+dfsg-3.3+deb12u1 Β· MIT
- debian trixie: monodoc-base 6.12.0.199+dfsg-6 Β· MIT
- epel 10: monodoc 6.14.1-1.el10_2 Β· MIT
- epel 9: monodoc 6.12.0-5.el9 Β· MIT
- fedora 43: monodoc 6.12.0-21.fc43 Β· MIT
- fedora 44: monodoc 6.14.1-3.fc44 Β· MIT
- fedora 44: monodoc 6.14.1-4.fc44 Β· MIT
- nixos 26.05: mono 6.14.1
- nixpkgs unstable: mono 6.14.1
- opensuse-leap 16.0: monodoc-core 6.12.0-bp160.1.1 Β· LGPL-2.1-only
- opensuse-leap 16.0: monodoc-core 6.12.0-bp160.1.1 Β· LGPL-2.1-only
- opensuse-leap 16.0: monodoc-core 6.12.0-bp160.1.1 Β· LGPL-2.1-only
- opensuse-leap 16.0: monodoc-core 6.12.0-bp160.1.1 Β· LGPL-2.1-only
- ubuntu jammy: monodoc-base 6.8.0.105+dfsg-3.2 Β· MIT
- ubuntu noble: monodoc-base 6.8.0.105+dfsg-3.6ubuntu2 Β· MIT
- ubuntu questing: monodoc-base 6.12.0.199+dfsg-6
- ubuntu resolute: mono-devel 6.14.1+ds2-2 Β· MIT
- ubuntu stonking: mono-devel 6.14.1+ds2-3 Β· MIT
- (C) 2008 Jonathan Pryor
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms