Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustdoc should be able to build documentation from compiled crates #2206

Open
brson opened this issue Apr 14, 2012 · 10 comments
Open

rustdoc should be able to build documentation from compiled crates #2206

brson opened this issue Apr 14, 2012 · 10 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. P-low Low priority T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@brson
Copy link
Contributor

brson commented Apr 14, 2012

rustdodcs are built from attributes which are (should be) stored in the crate metadata. rustdoc should be able to construct the crate documentation from the crate metadata with nearly the same fidelity as from the original source.

@ghost ghost assigned brson Apr 19, 2012
@msullivan
Copy link
Contributor

Part of #5413, I suppose.

@emberian
Copy link
Member

#8125

This is not yet implemented by rustdoc_ng.

@catamorphism
Copy link
Contributor

Low, not 1.0

@alexcrichton
Copy link
Member

Note that all of the infrastructure is in place for doing this, there's just a few more wires to put in place.

lifthrasiir added a commit to lifthrasiir/rust that referenced this issue Dec 6, 2014
This commit uses an existing foreign inlining facility to implement
the doc generation from compiled crates. At the highest level,
this is a *huge* hack since the metadata doesn't provide everything
we need to generate docs.

Fixes rust-lang#2206. Will fix rust-lang#15309 once integrated with Makefile.
@flaper87
Copy link
Contributor

Triage bump: Still an issue. Priorities and tags seem correct to me. (cc @steveklabnik to make sure he's notified when things change here)

@steveklabnik
Copy link
Member

Triage: no changes here.

@steveklabnik steveklabnik added T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. and removed T-tools labels May 18, 2017
@steveklabnik
Copy link
Member

Triage: no changes, but this is certainly desired, especially with cargo check, that didn't exist the last time this was commented on.

@jyn514
Copy link
Member

jyn514 commented Mar 25, 2021

Triage: no changes, but this is certainly desired, especially with cargo check, that didn't exist the last time this was commented on.

I think cargo check is a little misleading - rustdoc already reads cargo check metadata for dependencies, which you can see from experimenting a little with cargo:

$ cargo doc
 Documenting inner v0.1.0 (/home/joshua/src/rust/test-rustdoc/inner)
    Checking inner v0.1.0 (/home/joshua/src/rust/test-rustdoc/inner)
 Documenting outer v0.1.0 (/home/joshua/src/rust/test-rustdoc/outer)
    Finished dev [unoptimized + debuginfo] target(s) in 2.10s
$ touch src/lib.rs
$ cargo doc
 Documenting outer v0.1.0 (/home/joshua/src/rust/test-rustdoc/outer)
    Finished dev [unoptimized + debuginfo] target(s) in 0.69s

and documenting also shares the same metadata cache as checking:

$ cargo check
    Checking hello-world v0.1.0 (/home/joshua/src/rust/test-rustdoc/hello-world)
    Finished dev [unoptimized + debuginfo] target(s) in 0.49s
$ cargo doc
 Documenting hello-world v0.1.0 (/home/joshua/src/rust/test-rustdoc/hello-world)
    Finished dev [unoptimized + debuginfo] target(s) in 0.67s
$ rm -r target
$ cargo doc
 Documenting hello-world v0.1.0 (/home/joshua/src/rust/test-rustdoc/hello-world)
    Finished dev [unoptimized + debuginfo] target(s) in 1.36s
$ cargo check
    Checking hello-world v0.1.0 (/home/joshua/src/rust/test-rustdoc/hello-world)
    Finished dev [unoptimized + debuginfo] target(s) in 0.11s

I guess my question is what this would be useful for? It seems weird to want to document a crate without having the source available. Rustdoc also has a bunch of subtle bugs about how metadata handling is different from HIR handling, which would suddenly start applying to the main crate instead of only on re-exports: https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+crate+label%3AA-cross-crate-reexports

@ehuss ehuss removed the T-dev-tools Relevant to the dev-tools subteam, which will review and decide on the PR/issue. label Jan 18, 2022
@bjorn3
Copy link
Member

bjorn3 commented Dec 13, 2022

and documenting also shares the same metadata cache as checking:

But it does still require compiling every crate twice. Once for crate metadata to be used when documenting crates that depend on the current crate and once to actually generate documentation for the current crate.

It seems weird to want to document a crate without having the source available.

Could be useful for closed-source crates. And as a side-effect clearly show just how much information is leaked in the crate metadata, which could help dissuade people from releasing crates as closed source rlibs that can then only be used by a single rustc version. And instead push them towards either making it source available or releasing it as a cdylib with a stable abi such that it can be used with any rustc version.

@jyn514
Copy link
Member

jyn514 commented Dec 14, 2022

as a side-effect clearly show just how much information is leaked in the crate metadata, which could help dissuade people from releasing crates as closed source rlibs that can then only be used by a single rustc version

Having a tool for this seems useful, but I don't know that rustdoc needs to be that tool. Rustdoc has already had several major expansions of scope.

Given the complexity of the implementation, the fact it will likely change various parts of the rendering (https://github.com/rust-lang/rust/issues?q=is%3Aopen+is%3Aissue+crate+label%3AA-cross-crate-reexports), and the unclear use cases, I think this would benefit from an RFC that explains why this functionality belongs in rustdoc.

celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. P-low Low priority T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants