是否可以使用
docfx
下的 Markdown 更改表格的布局?
例如,由于列之间的间距,下表的可读性不太好。事件没有交替行颜色:
| Property | Description |
|---|---|
| URL | `/api/<version>/auth/login` |
| Method | `post` |
| Success | Http status *200* |
| Failure | Http-status *400/500* |
| Content/Media-Type | `application/json` |
| Authorization | *no* |
| Roles | - |
这就是
doxfx
中的样子:
某种预期行为:
我们将扩展默认模板:
创建文件:
(Project Folder)\template\styles\main.js
默认的 DocFX 模板使用 Bootstrap 和 JQuery,因此在 main.js 中添加以下内容:
$(document).ready(function ()
{
$("table").addClass("table table-bordered table-striped table-condensed");
})
这使得 Markdown 表格与 Api 文档中的表格相同。 要使用 Bootstrap 表格样式,请参阅 http://www.w3schools.com/bootstrap/bootstrap_tables.asp
现在,我们将此模板添加到 docfx.json 中:
在 docfx.json 中,将
"template": ["default"]
替换为 "template": ["default", "template"]
。
以防万一有人像我一样使用 DocFx 的新版本,例如 2024 年的 2.75.3。只需修改上述同一文件夹中的 main.css 即可。我也不喜欢桌子的默认外观和感觉,因为它们看起来非常平淡。所以我改变了标题并给出了柔和的条纹颜色。希望这有帮助。
.table.table > thead > tr > th {
background-color: black;
color: white;
}
.table.table > tbody > tr:nth-child(odd) > td {
background-color: #f2f1f0;
}