Is it possible to inherit documentation from specific parameters?
Asked Answered
L

2

29

Visual Studio 2017, ReSharper 2017, C# project

I am trying to inherit the documentation of a method's parameter by using the select attribute, but it doesn't seem to work as expected.

According to this article ( http://tunnelvisionlabs.github.io/SHFB/docs-master/SandcastleBuilder/html/79897974-ffc9-4b84-91a5-e50c66a0221d.htm ) documentation can be filtered using the select attribute, and one of the examples show it being used as such:

 /// <example>
 /// <inheritdoc cref="MethodWithTwoExamples"
 ///     select="span[@id='Example 2']" />
 /// </example>

So in a similar fashion I try to filter the documentation this way:

/// <param name="generateStream"><inheritdoc cref="MyClass.MyMethod" select="param[@name='generateStream']"/></param>

but the problem with it is that Visul Studio Intellisense doesn't display the documentation of that specific parameter, but instead it shows the documentation of the first parameter of the method I'm trying to inherit the documentation from.

So my question is: is it possible to filter documentation down to a specific parameter of a method?

Ligroin answered 30/9, 2017 at 15:13 Comment(2)
Please check the VS 2017 Recommended Tags for Documentation Comments doc: learn.microsoft.com/en-us/dotnet/csharp/programming-guide/… and there is no such 'inheritdoc', sorry for this inconvenience, maybe you can try other tags like <see> that also can provide useful information.Fenn
@SaraLiu-MSFT <inheritdoc/> is currently on the page you linked to (under the heading "Reused documentation") - I guess the docs were updated after you posted in 2017?Krasnoff
I
52

What you are asking for is possible with Visual Studio 2019 (16.9.3). I had the same problem myself and found a discussion here:

https://github.com/doxygen/doxygen/issues/7356/#issuecomment-547905295

which pointed me to the right direction.

  • First, as select is deprecated, you have to use path instead.

  • Second, you have to prefix the XPath part with a slash (/) so that your XML doc will look like this:

    /// <param name="generateStream"><inheritdoc cref="MyClass.MyMethod" path="/param[@name='generateStream']"/></param>
    
Igniter answered 23/4, 2021 at 10:47 Comment(2)
Upvoted and imho should probably be marked as the accepted answer. I realize OP asked for VS2017 (which apparently doesn't support inheritdoc according to the comment) but aside from that, it provided me with exactly the information that I needed and couldn't find in MS documentation.Mersey
I'm trying to use <inheritdoc> inside a <param name=""> element, but referencing a property (rather than a param) - so the XML I needed was this: /// <param name="paramName"><inheritdoc cref="ClassName.PropertyName" path="/summary"/></param> and it works (in VS 2019 v16.11.26), thanks!Krasnoff
M
0

I don't think it is possible to show inherited documentation in IntelliSense at all due to this UserVoice item here.

Mikimikihisa answered 30/9, 2017 at 16:0 Comment(2)
That article dates back in 2013, I don't know what changed since then, but documentation inheritance surely works, I am using it a lot, I only have problems filtering it as the select attribute seems to get ignored.Ligroin
@Ligroin In VS2017 right now and it does not seem to work for me. Tooltips show no summaries for anything with /// <inheritdoc/>Fregger

© 2022 - 2024 — McMap. All rights reserved.