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

cargo doc doesn't generate documentation for binary crate #1865

Closed
6D65 opened this issue Aug 1, 2015 · 7 comments
Closed

cargo doc doesn't generate documentation for binary crate #1865

6D65 opened this issue Aug 1, 2015 · 7 comments

Comments

@6D65
Copy link

6D65 commented Aug 1, 2015

Hi,

I'm not sure this is expected, though there's a mention in the rust book about cargo test for documentation working only with library crates. I don't see the reason why it wouldn't generate the documentation for a binary crate too.

Am I missing something?

@6D65 6D65 changed the title cargo doc doesn't generate documentation for binary project cargo doc doesn't generate documentation for binary crate Aug 1, 2015
@steveklabnik
Copy link
Member

/cc @alexcrichton , who knows the reason. There is one, but I always forget

@alexcrichton
Copy link
Member

This is actually just cargo test, a normal cargo doc does indeed generate documentation. Rustdoc inherently can't document a binary because it needs to link to a library to get the functions. This sort of thing would need to be fixed in rustdoc first unfortunately.

@BartMassey
Copy link
Contributor

As far as I can tell cargo doc (as well as rustdoc proper) does not extract any documentation for functions in main.rs in a binary crate, although it does extract the container documentation for the crate itself. It would be really nice to be able to provide internal documentation for a program via rustdoc.

@BenSandeen
Copy link

@BartMassey I'm having the same problem; cargo doc is most definitely not generating documentation of the main.rs file in my binary crate, either.

@omarabid
Copy link

omarabid commented Jun 3, 2018

@alexcrichton documenting binaries could be useful for open source projects

@BartMassey
Copy link
Contributor

@omarabid: This ancient incantation still works for documenting a binary crate, although it gives grim deprecation warnings:

cargo rustdoc --open -- --no-defaults \
  --passes collapse-docs   \
  --passes unindent-comments \
  --passes strip-priv-imports

This works without warnings, but included a useless top-level "Re-exports" section which clutters up the front page:

cargo rustdoc --open -- --document-private-items

I've added a comment to Rust Issue #44136 to this effect.

@bubolex
Copy link

bubolex commented Jul 3, 2018

--document-private-items is the best answer to this issue :)
Thank you @BartMassey

LiamRotchford5671 added a commit to SimonBartonPSU/Fractal-Generator that referenced this issue Aug 7, 2019
- We were running into the issue where if you just run cargo doc --open it would generate just a black html page despite all of our /// comments
- We're not sure what is going wrong here but we found a source talking about the visabilty needing to be public but everything we have is public?
- we found a work around here rust-lang/cargo#1865 from Bart Massey himself
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants