【发布时间】:2019-06-25 10:03:42
【问题描述】:
我正在使用 Doxygen 从 C# 代码生成一些 API 文档。
XML cmets 如下所示:
/// <summary>
/// Some summary text.
/// </summary>
/// <remarks>
/// Some remarks.
/// </remarks>
/// <param name="type">Type param</param>
/// <param name="id">ID param</param>
/// <response code="200"> OK</response>
/// <response code="400"> Bad Request</response>
/// <response code="500"> Internal Server Error</response>
Doxygen 为响应代码行生成的 HTML 如下所示:
<p><response code="200"> OK</response> <response code="400"> Bad Request</response> <response code="500"> Internal Server Error</response> </p>
所以响应代码行在生成的页面中呈现如下:
<response code="200"> OK</response> <response code="400"> Bad Request</response> <response code="500"> Internal Server Error</response>
当我希望它们像这样渲染时:
<response code="200"> OK</response>
<response code="400"> Bad Request</response>
<response code="500"> Internal Server Error</response>
我们无法更改格式化 XML cmets 中响应代码的方式,因为我们的 Swagger 工具依赖于这种格式。
- 我不能使用别名,因为它不能进行文本匹配。它必须类似于 \response 或 @response。
- 我尝试使用自定义 CSS 插入一些中断,但这不起作用,因为我们正在处理编码文本。
- 我还尝试使用自定义 HTML 标头强制它呈现为 HTML5,但这也没有任何区别。
【问题讨论】:
-
是否有定义
<response>标签的权威文本,目前doxygen无法识别它,因为t不是C#标准Ecma-334中定义的标签。 -
@albert 我不这么认为。它只是在服务的 Swagger UI 中显示的自定义标签。我们不想为 Doxygen 调整它们,因为 (1) 它会导致它们在 Swagger 中被忽略或显示不正确,以及 (2) 即使它们在 Swagger 中工作,我们也必须在许多地方更新它们。 Doxygen 可以按原样处理它们的解决方案是可取的。
-
从更新后的描述中,我不知道您可以接受什么。像
response{2}=\htmlonly <response code="\1">\2</response>这样的ALIASES和像\response{200,OK}这样的呼叫是否可以接受? -
如果我正确理解别名,定义像 response="something" 这样的别名意味着 Doxygen 将在输入文件中查找 "@response" 的实例并将它们替换为文本 "something"。输入文件实际上包含“
-
.cs 源文件中的原始文件?是的。我很欣赏这些建议。我会尝试这些。