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

Interaction of rustdocflags in config.toml and dependencies #1

Open
JohnScience opened this issue Dec 30, 2021 · 3 comments
Open

Interaction of rustdocflags in config.toml and dependencies #1

JohnScience opened this issue Dec 30, 2021 · 3 comments

Comments

@JohnScience
Copy link

JohnScience commented Dec 30, 2021

Thank you so much for this wonderful repo!

I was trying to add a markdown file with LaTeX that I exported from evcxr Jupyter notebook (.ipynb) into a crate that had several dependencies. So far it seems that rustdocflags is invasive and applies to ALL crates for which rustdoc builds documentation. As a result, building documentation fails because as error suggests

error: error reading `./src/docs-header.html`: The system cannot find the path specified. (os error 3)

none of the crates-dependencies have docs-header.html in their ./src/ directory.

How to reproduce the error

The error can be reproduced by adding a dependency to Cargo.toml

[package]
name = "rust-latex-doc-minimal-example"
version = "0.2.0"
authors = ["Vicente Ramirez Perea <victe@ramper.net>"]
edition = "2018"
description = "Minimal crate example for getting latex in docs."
readme = "crates-io.md"
homepage = "https://github.com/victe/rust-latex-doc-minimal-example"
repository = "https://github.com/victe/rust-latex-doc-minimal-example"

license = "CC0-1.0"
categories = ["development-tools", "mathematics", "science"]
keywords = ["latex", "rustdoc", "docs"]

[dependencies]
num-traits = "0.2.14" # example of a dependency

[package.metadata.docs.rs]
rustdoc-args = [ "--html-in-header", "./src/docs-header.html" ]

Output

PS C:\Users\demen\Documents\GitHub\rust-latex-doc-minimal-example> cargo doc
 Documenting num-traits v0.2.14
error: error reading `./src/docs-header.html`: The system cannot find the file specified. (os error 2)

error: could not document `num-traits`

Caused by:
  process didn't exit successfully: `rustdoc --crate-type lib --crate-name num_traits C:\Users\demen\.cargo\registry\src\github.com-1ecc6299db9ec823\num-traits-0.2.14\src\lib.rs --cap-lints allow -o C:\Users\demen\Documents\GitHub\rust-latex-doc-minimal-example\target\doc --cfg "feature=\"default\"" --cfg "feature=\"std\"" --error-format=json --json=diagnostic-rendered-ansi,future-incompat -C metadata=1018f75cfa6d9b1f -L dependency=C:\Users\demen\Documents\GitHub\rust-latex-doc-minimal-example\target\debug\deps --html-in-header ./src/docs-header.html --crate-version 0.2.14 --cfg has_i128 --cfg has_to_int_unchecked` (exit code: 1)
PS C:\Users\demen\Documents\GitHub\rust-latex-doc-minimal-example>
@JohnScience
Copy link
Author

JohnScience commented Dec 30, 2021

Screenshot 2021-12-30 052211

for docs.rs, only the root crate is documented, so all rustdocflags set in package.metadata.docs.rs are only applied to that crate

when running rustdoc locally, you can use cargo rustdoc -- to run a doc-build of the root crate using specific rustdocflags

(or alternatively RUSTDOCFLAGS= cargo doc --no-deps; but I find cargo rustdoc much more meaningful as "document this one crate with flags")

@JohnScience
Copy link
Author

Screenshot 2021-12-30 052949

@JohnScience
Copy link
Author

Screenshot 2021-12-30 053556

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

1 participant