-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-external_doc`#![feature(external_doc)]``#![feature(external_doc)]`P-mediumMedium priorityMedium priorityT-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.Relevant to the dev-tools subteam, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language teamT-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Description
RFC PR: rust-lang/rfcs#1990
RFC text: https://github.com/rust-lang/rfcs/blob/master/text/1990-external-doc-attribute.md
Summary of how to use this:
- Add
#![feature(external_doc)]
to your crate. - Add a file
"src/some-docs.md"
with some docs to your crate. - Add an attribute
#[doc(include = "some-docs.md")]
to something that needs some docs. The file path is relative tolib.rs
, so if you want adoc
folder to live alongsidesrc
, then all your paths inside thedoc(include)
attributes need to begin with../doc
.
Summary of current status:
- Initial implementation landed in rustdoc: include external files in documentation (RFC 1990) #44781, on 2017-11-22.
- Updates based on conversation in this thread landed in tweaks and fixes for doc(include) #46858, on 2017-12-21.
- Please use this in your own projects and comment in this thread if something goes wrong! (Or even if it goes well! Knowing it's working as intended is great!)
Current tasks:
(promote the "failed to load file" warnings to proper lints?)(Make them hard errors instead, per the RFC tweaks and fixes for doc(include) #46858)Ensure line number info is properly preserved in doctest errorsTo pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
kornelski, MatthieuBizien, LPGhatguy, ozkriff, jonas-schievink and 26 more
Metadata
Metadata
Assignees
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)B-unstableBlocker: Implemented in the nightly compiler and unstable.Blocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCF-external_doc`#![feature(external_doc)]``#![feature(external_doc)]`P-mediumMedium priorityMedium priorityT-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.Relevant to the dev-tools subteam, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language teamT-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
matklad commentedon Oct 16, 2017
cc @joshtriplett
At today's Cargo meeting, and interesting question was raised how Cargo should check if it should rebuild the docs when an external file with docs changes.
Here's some info on how dependency-tracking works today:
When doing
cargo build
, Cargo passes an--emit=deb-info
flag torustc
, which causes it to emit dep-info files with.d
extension, which lists what files were used for compilation (remember, only crate roots are explicitly mentioned in Cargo.toml). These files then used in fingerprint.rs to compute the fingerprint.Curiously,
cargo doc
does not emit dep-info at all, and fingerpint.rs does not use depinfo when doingdoc
. Instead it asks Source for fingerprint which for the local repository boils down to listing all files in a directory with Cargo.toml.TL;DR:
touch Readme.md
today causescargo doc
to rebuild docs for the current crate, which might not be the most efficient thing to do, but which should work with external documentation, unless it is fetched from a placeoutside
of Cargo package.joshtriplett commentedon Oct 16, 2017
@matklad So, it sounds like the current behavior is correct but could be made more efficient. That's better than being incorrect.
matklad commentedon Oct 17, 2017
There's an edge case where it might not do rebuild when it should, if in
src/lib.rs
you have something likeOr
That is, if you touch files outside of the Cargo package directory.
Other than that yes, current behavior is correct!.
169 remaining items