Auto-generating documentation and Inheritence

时间:2015-09-01 22:33:24

标签: c# asp.net-web-api documentation xml-documentation asp.net-web-api-helppages

I have the base API controller:

 public class BaseController<T> : ApiController
{
    /// <summary>
    /// Method GetByYear in Base class
    /// </summary>
    /// <param name="year"></param>
    /// <returns></returns>
    public virtual IQueryable<T> GetByYear(int year)
    {
        return null;
    }
}

and child that just inherited method GetByYear from base:

public class HouseController : BaseController<House>
{
    /// <summary>
    /// Method Test
    /// </summary>
    /// <returns></returns>
    public string Test()
    {
        return "Test";
    }
}

I use Help page to create auto documentation. And in result I get:

enter image description here

I want to get a description of the two methods.
How can I get XML comments to the method GET in child class without overriding?
Or should I copy it to my child class?

When I use <inheritdoc /> in HouseController I get the same result as above, and I do not want to override each method when it is not needed:

     /// <inheritdoc />
    public override IQueryable<House> GetByYear(int year)
    {
        return base.GetByYear(year);
    }

Another question: How can I use ghostdoc with default Help page?

2 个答案:

答案 0 :(得分:1)

You can use /// <inheritdoc />.

答案 1 :(得分:0)

It may depend on the program that turns XML comments to actual documentation, but MSDN's, for example, just replicates the base documentation, noting that it is inherited from the base class. So you do not need to replicate the documentation on derived members (unless they are overridden and behave differently, thus requiring different documentation)