- Mastering Rust
- Rahul Sharma Vesa Kaihlavirta
- 143字
- 2021-07-02 13:35:26
Generating and viewing documentation
To generate documentation, we can use the cargo doc command in our project directory. It generates docs in the target/doc/ directory with a bunch of HTML files and predefined stylesheets. By default, it generates docs for a crate's dependencies too. We can tell Cargo to ignore generating docs for dependencies by running cargo doc --no-deps.
To view the documentation, one can spawn a HTTP server by navigating inside the target/doc directory. Python's simple HTTP server can come in handy here. However, there's a better way to do this! Passing the --open option to cargo doc will open the documentation page directly in your default browser.
cargo doc can be combined with cargo watch to get a seamless experience in writing documentation and getting live feedback on the generated page for any documentation changes you do on your project.
推薦閱讀
- C語言程序設計習題解析與上機指導(第4版)
- Raspberry Pi for Secret Agents(Third Edition)
- 程序員修煉之道:通向務實的最高境界(第2版)
- Java編程技術與項目實戰(第2版)
- 移動互聯網軟件開發實驗指導
- 現代C++編程實戰:132個核心技巧示例(原書第2版)
- 移動增值應用開發技術導論
- 寫給程序員的Python教程
- C語言從入門到精通
- IBM RUP參考與認證指南
- Professional JavaScript
- Improving your Penetration Testing Skills
- Python編程基礎與數據分析
- Storm Real-Time Processing Cookbook
- Kubernetes進階實戰(第2版)