- Mastering Rust
- Rahul Sharma Vesa Kaihlavirta
- 251字
- 2021-07-02 13:35:26
Writing documentation
To write documentation, we have special symbols for marking the start of documentation comments (doc comments hereafter). Docs are written in a similar fashion, the way we write comments, but they are treated differently compared to ordinary comments and are parsed by rustdoc. The doc comments are divided into two levels and use separate symbols to mark the start of the doc comment:
- Item level: These comments are meant for items within the module such as structs, enum declarations, functions, trait constants, and so on. They should appear above the item. For single-line comments, they start with ///, while multi-line comments begin with /** and end with */.
- Module level: These are comments that appear at the root level, i.e., main.rs, lib.rs, or any other module, and use //! to mark the start of a line comment – or /*! for multi-line comments – before ending them with */. They are suitable for giving a general overview of your crate and example usage.
Within the doc comment, you can write docs using the usual markdown syntax. It also supports writing valid Rust code within backticks (```let a = 23;```), which becomes part of documentation tests.
The preceding notation for writing comments is actually a syntatic sugar for the #[doc="your doc comment"] attribute. These are called doc attributes. When rustdoc parses the /// or /** lines, it converts them into these doc attributes. Alternatively, you can also write docs using these doc attributes.
- HoloLens Beginner's Guide
- 圖解Java數(shù)據(jù)結(jié)構(gòu)與算法(微課視頻版)
- BeagleBone Media Center
- DevOps入門與實(shí)踐
- DevOps Automation Cookbook
- Java程序員面試算法寶典
- 信息安全技術(shù)
- C語言程序設(shè)計(jì)上機(jī)指導(dǎo)與習(xí)題解答(第2版)
- Scala for Machine Learning(Second Edition)
- 零代碼實(shí)戰(zhàn):企業(yè)級(jí)應(yīng)用搭建與案例詳解
- QPanda量子計(jì)算編程
- 深入實(shí)踐DDD:以DSL驅(qū)動(dòng)復(fù)雜軟件開發(fā)
- Ext JS 4 Plugin and Extension Development
- Learning Unreal Engine Game Development
- SAS編程演義