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

Impossible to generate JSON documentation from cargo rustdoc #2182

Closed
utkarshkukreti opened this issue Nov 29, 2015 · 4 comments
Closed

Impossible to generate JSON documentation from cargo rustdoc #2182

utkarshkukreti opened this issue Nov 29, 2015 · 4 comments

Comments

@utkarshkukreti
Copy link

It seems like cargo unconditionally creates a directory and adds a -o argument making it impossible to generate JSON documentation of a crate.

Maybe cargo should not append the -o argument if the extra opts supplied by the user includes -o? or maybe cargo doc should have an option to generate JSON documentation?

➜  /tmp  cargo new foo
➜  /tmp  cd foo
➜  foo git:(master) ✗ cargo rustdoc --verbose -- -w json
 Documenting foo v0.1.0 (file:///private/tmp/foo)
     Running `rustdoc src/lib.rs --crate-name foo -o /private/tmp/foo/target/doc -w json -L dependency=/private/tmp/foo/target/debug -L dependency=/private/tmp/foo/target/debug/deps`
thread '<unnamed>' panicked at 'failed to write json: Is a directory (os error 21)', ../src/librustdoc/lib.rs:298
Could not document `foo`.

Caused by:
  Process didn't exit successfully: `rustdoc src/lib.rs --crate-name foo -o /private/tmp/foo/target/doc -w json -L dependency=/private/tmp/foo/target/debug -L dependency=/private/tmp/foo/target/debug/deps` (exit code: 101)
➜  foo git:(master) ✗ cargo rustdoc --verbose -- -w json -o doc.json
 Documenting foo v0.1.0 (file:///private/tmp/foo)
     Running `rustdoc src/lib.rs --crate-name foo -o /private/tmp/foo/target/doc -w json -o doc.json -L dependency=/private/tmp/foo/target/debug -L dependency=/private/tmp/foo/target/debug/deps`
Option 'output' given more than once.
Could not document `foo`.

Caused by:
  Process didn't exit successfully: `rustdoc src/lib.rs --crate-name foo -o /private/tmp/foo/target/doc -w json -o doc.json -L dependency=/private/tmp/foo/target/debug -L dependency=/private/tmp/foo/target/debug/deps` (exit code: 1)
@utkarshkukreti
Copy link
Author

Would you accept a PR adding the --output-format flag to cargo doc?

@alexcrichton
Copy link
Member

This is kinda similar to how you can't specify -o and --out-dir to cargo rustc, so I'm not sure what the best way to handle this would be.

@obi1kenobi
Copy link
Member

This is perhaps able to be closed as fixed, since cargo rustdoc -- -Zunstable-options --output-format json works fine on nightly at the moment.

@weihanglo
Copy link
Member

This is perhaps able to be closed as fixed, since cargo rustdoc -- -Zunstable-options --output-format json works fine on nightly at the moment.

Thanks for the triage. We track making --output-format an option in #12103. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants