我正在努力记录我们的显示和编辑模板(作为扩展,记录我们所有的CSHTML都是有益的).话虽如此,我从未见过任何记录CSHTML Razor Views的方法.
例如,我有这个CSHTML EditorTemplate:MoneyPicker.cshtml
@model Decimal?
@{
Layout = null;
}
@Html.TextBox(
"",
ViewData.TemplateInfo.FormattedModelValue,
new
{
type = "number",
@class = "form-control money-control",
placeholder = ViewData.ModelMetadata.Watermark ?? ViewData.ModelMetadata.DisplayName
} )
我知道它不是C#,但是有一些方法可以添加XML文档(或等效的):
///
/// Displays a text box wrapped with the money-picker wrappers, allowing javascript to show money buttons to pick the value.
///
/// A currency value
///
/// The input is a text box that has the type "number"
///
或者如果没有,有没有人找到某种方法来记录编辑器/显示模板,这些模板可以被某种类似于Asp.Net WebApi的api帮助页面的系统选中?理想情况下,它会更进一步,从父类型开始,并允许您深入到每个类型的属性编辑器等,但我只是想先开始小.
编辑:作为其中的一部分,我还希望生成模板的示例,而无需硬/手动编写所述示例,只是为了帮助澄清我的想法.
解决方法:
我也研究了这个,但我找不到任何记录View的方法,现在我刚刚记录了Controller中的Views:
///
/// This is an example of documentation for the View.
///
/// This is what I am returning.
public ActionResult CreateNewUser()
{
return View();
}
您可以使用以下方法为此生成文档: SandCastle(我更喜欢这个)或GhostDoc.
您也可以在视图中写下正常评论以获取解释.
@* This is a comment *@
标签:c,asp-net-mvc,razor,documentation
来源: https://codeday.me/bug/20190706/1393274.html