是否可以在 docs.rs 上查看功能文档?

Is it possible to see feature documentation on docs.rs?

我正在查看 documentation for gpio_cdev on docs.rs

该 crate 的可选功能之一是 async-tokio,它允许您编写异步代码来检查 GPIO 引脚。在 gpio_cdev github front page 上有一个使用 AsyncLineEventHandle.

的例子

我看到的问题是 docs.rs 文档完全没有提及 AsyncLineEventHandle 或与异步有关的任何内容。

docs.rs 网站上是否有显示可选功能文档的按钮? docs.rs 上是否从未记录过可选功能?还是由开发人员在 docs.rs 上包含可选功能的文档?我应该为此提交错误报告吗?

我想如果我使用 cargo doc 在本地生成文档,我就可以看到文档(尽管我还没有尝试过)。这是唯一的选择吗?

编辑:确认只要我启用了该功能,本地生成的文档就会显示异步部分。

Documentation in docs.rs is built ahead of time. It isn't generated on the fly。因此,没有按钮。

在文档构建期间打开或关闭的功能将取决于 crate 作者指定在 docs.rs 中用于文档编译的功能。查看 Cross-compiling section on the About/Builds page,也许可以将 PR 发送到 gpio_cdev 以在 docs.rs?

中的文档构建期间打开所有功能

可以使用 docs.rs attributes like #[cfg_attr(docsrs, doc(cfg(feature = "async-tokio")))] and to set the crate defaults to show features on docs.rs,在 gpio-cdev 的情况下,这是最近添加的,我们只是从那以后没有发布过版本。

正如您所发现的,您始终可以使用 cargo doc --open --all-features 以启用所有功能,并按照@nelsonjchen 的建议打开问题或 PR / 你必须让我们知道它丢失是很好的 ^_^