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

document-features fails when markdown headers (##) is used in a TOML string (was "docs.rs builds failing") #25

Closed
epage opened this issue Jul 10, 2024 · 7 comments

Comments

@epage
Copy link

epage commented Jul 10, 2024

[INFO] [stderr] warning: target filter specified, but no targets matched; this is a no-op
[INFO] [stderr]  Documenting snapbox v0.6.12 (/opt/rustwide/workdir)
[INFO] [stderr] error: Comment cannot be associated with a feature: "[Unreleased] - ReleaseDate"
[INFO] [stderr]   --> src/lib.rs:44:50
[INFO] [stderr]    |
[INFO] [stderr] 44 | #![cfg_attr(feature = "document-features", doc = document_features::document_features!())]
[INFO] [stderr]    |                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[INFO] [stderr]    |
[INFO] [stderr]    = note: this error originates in the macro `document_features::document_features` (in Nightly builds, run with -Z macro-backtrace for more info)

This happened on snapbox 0.6.12 (https://docs.rs/crate/snapbox/0.6.12/builds/1287788) and 0.6.11 but not before.

If you diff my package between 0.6.10 and 0.6.12, there are no relevant changes, see https://diff.rs/snapbox/0.6.10/0.6.12/Cargo.toml

In fact, [Unreleased] - ReleaseDate does not show up on a dedicated line in my ma
manifest but does show up in a nested TOML string (not on its own line)

However, I'm not able to reproduce this locally

$ RUSTFLAGS="--cfg docsrs" cargo +nightly doc --no-deps -F document-features

Anyone else seeing this?

@ogoffart
Copy link
Member

I can reproduce the problem locally from your snapbox repository if i first do the cargo package step.

cargo package
cd target/package/snapbox-0.6.12/
cargo  doc --no-deps -F document-features

(doesn't need nightly, this is rust 1.79)

But i can also reproduce with the version 0.6.10 of that crate and with older rust version. So i can understand why this fails, but i cannot understand how it worked before.
Anyway, i'll come with a fix

ogoffart added a commit that referenced this issue Jul 11, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Prospective fix for issue #25
@ogoffart
Copy link
Member

I made a "fix" but I realize it's not a fix because it wouldn't have an error anymore, but wouldn't also have any feature.

The strange thing is that there is a difference in the Cargo.toml which is not shown by the diff:

If you look at https://docs.rs/crate/snapbox/0.6.10/source/Cargo.toml , it contains:

[[package.metadata.release.pre-release-replacements]]
exactly = 1
file = "CHANGELOG.md"
replace = "<!-- next-header -->\n## [Unreleased] - ReleaseDate\n"
search = "<!-- next-header -->"

However, from https://docs.rs/crate/snapbox/0.6.11/source/Cargo.toml

[[package.metadata.release.pre-release-replacements]]
exactly = 1
file = "CHANGELOG.md"
replace = """
<!-- next-header -->
## [Unreleased] - ReleaseDate
"""
search = "<!-- next-header -->"

I don't understand why they are different. If I look at the .crate file downloaded by cargo in ~/.cargo/registry/cache/index.crates.io-6f17d22bba15001f/snapbox-0.6.10.crate , it does have the """ version. So why did docs.rs have a different version?
Do crates.io change the content of the archive, or did docs.rs somehow re-normalized the Cargo.toml?

(This difference makes the test in this condition being different:

if !cargo_toml.contains("\n##") && !cargo_toml.contains("\n#!") {
)

ogoffart added a commit that referenced this issue Jul 11, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
CC #25
@ogoffart
Copy link
Member

Fixed in 0.2.9

But the reason why the file Cargo.toml was different for docs.rs than what is in the crate package is still a mystery to me.

@ogoffart
Copy link
Member

The new version caused regression so i yanked it for now.

@ogoffart ogoffart reopened this Jul 11, 2024
@epage
Copy link
Author

epage commented Jul 11, 2024

Do crates.io change the content of the archive, or did docs.rs somehow re-normalized the Cargo.toml?

Looks like docs.rs is loading and rewriting the Cargo.toml file. Its losing the comment and field ordering. It seems that they were using an old toml version and, on upgrade, it started to match the string generation that cargo package does, making this problem visible.

@epage
Copy link
Author

epage commented Jul 11, 2024

@epage epage changed the title docs.rs builds failing document-features fails when markdown headers (##) is used in a TOML string (was "docs.rs builds failing") Jul 11, 2024
@ogoffart
Copy link
Member

should work now in 0.2.10

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

2 participants