我想记录我的木箱并在文档中包含一个表格:
//! Demonstrating MarkDown tables.
//!
//! | Foo | Bar | Baz | Qux |
//! | --- | --- | --- | --- |
//! | Hail the turbofish `::<>` | Ferris for president | I can't think of any more "funny" things | oopsie |
//!
使用 cargo doc
命令生成的文档如下图所示:
这就是我想要的。但是您可能已经注意到,源代码行非常长,超过了100个字符。像许多Rust项目一样,我希望保持所有行的长度不超过100个字符。因此,我尝试着对该行进行换行。
以下所有版本:
//! | Foo | Bar | Baz | Qux |
//! | --- | --- | --- | --- |
//! | Hail the turbofish `::<>` | Ferris for president
//! I can't think of any more "funny" things | oopsie |
//! | Foo | Bar | Baz | Qux |
//! | --- | --- | --- | --- |
//! | Hail the turbofish `::<>` | Ferris for president |
//! I can't think of any more "funny" things | oopsie |
//! | Foo | Bar | Baz | Qux |
//! | --- | --- | --- | --- |
//! | Hail the turbofish `::<>` | Ferris for president
//! | I can't think of any more "funny" things | oopsie |
//! | Foo | Bar | Baz | Qux |
//! | --- | --- | --- | --- |
//! | Hail the turbofish `::<>` | Ferris for president |
//! | I can't think of any more "funny" things | oopsie |
//! | Foo | Bar | Baz | Qux |
//! | --- | --- | --- | --- |
//! | Hail the turbofish `::<>` | Ferris for president \
//! I can't think of any more "funny" things | oopsie |
结果为:
我有哪些选项可以在我的文档中包含长表格行,而不违反行长度限制?
.md
文件,准备build.rs
将.md
->.rs
文件转换(在前面加上//!
或///
),然后使用include!
,b)等待rustc添加外部文档属性或c)使用rdoc的nightly版本。 - zrzka