I want to convert all C# enums to markdown documentation. I am still considering two options: C# native way and custom grammar implementation. The second may lead to perfect implementation but I have not touched the bison for tens of years.
One C# way is described here: https://dzone.com/articles/converting-c-enums-to-javascript
public static MvcHtmlString EnumToString<T>(this HtmlHelper helper)
{
var values = Enum.GetValues(typeof(T)).Cast<int>();
var enumDictionary = values.ToDictionary(value => Enum.GetName(typeof(T), value)); return new MvcHtmlString(JsonConvert.SerializeObject(enumDictionary));
}
Good point is that I can use this method to generate a MD file. Unfortunatelly C# API does not provide a method to get the enum documentation:
/// <summary>pecial forces cars</summary>
C = 1,
Is there a way to overcome this limimation? Can reflection provide the field documentation? I cannot find such method.
I have read Parser for C# and it seems that Roslyn may be helpful too. Would it be a good approach? It is a C# compiler so I worry it is too heavy weight for my use case.