Search code examples
c#documentation-generationxml-documentationdocfx

How do you create code references with custom link text in documentation comments?


I am porting an application library from Java to C#. In the Java documentation, there are places that link to a particular code reference using custom text. For example:

Suffix --> {@link DataOutput#writeString String}

I tried using a similar approach in XML documentation comments...

Suffix --&gt; <see cref="DataOutput.WriteString(string)">String</see>

... but the whole link just vanishes from both Intellisense and the generated documentation when I try it that way. The question is, how do I construct similar code links with custom text using .NET XML documentation comments in C#? If there is no way to do it, what is the recommended workaround?

If it matters, we are experimenting with using the DocFx code generator.


Solution

  • You can use DocFX's cross reference syntax: [String](xref:DataOutput.WriteString(System.String)).

    See: http://dotnet.github.io/docfx/tutorial/links_and_cross_references.html#different-syntax-of-cross-reference