rustdoc_copy
Rustdoc comment copy helper.
The author of this crate is not good at English.
Forgive me if the document is hard to read.
Core items
doc_share- Copy rustdoc comment from other rustdoc comment.doc_file- Copy rustdoc comment from Markdown file.
Highlights
😊 Pros
- Partial copy is supported with various methods.
- Partial copy can work with references and definitions.
doc_filesupports heading level adjusting.doc_filesupports link copy guard (fordocs.rsURL inREADME.md).
🤔 Cons
- No root document sharing (expecting futrue Rust).
- No file update detecting (expecting futrue Rust).
- Miss copy of document (expecting futrue crates for Markdown).
Examples
Simple copy
use *;
/// This is my function.
Partial copy
use *;
/// This is my function.
///
/// # Some Notes
///
/// Message print only.
/// This is my function alias.
With members
use *;
/// This is my struct.
File copy
- src/lib.rs
//! Welcome to my crate API document.
doc_file!;
use *;
- README.md
# my_crate
This crate is ...
## Examples
```rust
use my_crate::some_func;
assert_eq!(some_func(), 42);
```
Tips
Document path
Document components is specified by path with following components.
-
Root module
-
Item module
ID Description No selection For no member item base Base item side::member Member item -
Section module (recursive)
ID Description No selection Root section sub::section Named section -
Parts macro
ID Description head!First block (Mrakdown heading fit this group) body!Subsequent blocks defs!Definitions (Root only) subs!All sub sections top!head!+body!all!top!+subs!+defs!
ID from title
Section identification by title has two subtly different styles.
-
Comon rule
- All uppercase characters are converted to lowercase.
- Special characters like puctuation and Emoji are ignored.
-
Global style
- This style is used in fragment key in
doc_file. - This style follows heading anchor rule of GFM.
- Spaces in the titles are replaced into hyphen ('
-'). - Sequential numers are used if same titles exist in the one document.
- This style is used in fragment key in
-
Local style
- This style is used in section ID in document path.
- This style follows naming rule of Rust module.
- Spaces in the titles are replaced into underscore ('
_'). - Sequential numbers are used if same title exists in sibling sections.
- Long ID or path can shorten with
useandaskeywords.
References and definitions
Up for partial copy, all links and images definitions are embeded to references.
About footnotes, use defs! macro. Because they lack embeding ability.
No root document shareing
At doc_share, root documents of Rust files are not supported. This is because
notation like #![doc_share(doc)] are not supported. (I wonder this issue will
be resolved by inner macro attribute in the future.)
No file update detecting
At doc_file, argument file is not tracked on real time from IDE. Therefore,
error detection and autocompletion at IDE is based on old Markdown headings.
This state will remain until rebuild. (I wonder this issue will be resolved
by proc_macro::tracked::path in the future.)
Miss copy of document
The content of documents may change slightly when copied. This is the impact of the crate for CommonMark that this crate depends on. The crate is high precision, but currently, not perfect. Therefore, when using elaborate notation, please inspect the outputs by yourself.
Common compile error
The path of root module for documentation must be accessible without
preceding paths. In other words, if that identifier is in another module,
use keyword is required.
- Compilation successed
use *;
use doc;
- Compilation failed!
use *;
// use my_mod::doc; // <---- 🚧 Shorthand path is not used.
// <---- 👈 Full path is used.
History
See CHANGELOG.