webern / cargo-readme

Generate README.md from docstrings
Other
360 stars 57 forks source link

Workspace inheritance breaks cargo readme #81

Open leighmcculloch opened 1 year ago

leighmcculloch commented 1 year ago

Projects that use workspace inheritance, such as to replace a version in a crate toml with version.workspace = true cause cargo readme to error with:

Error: invalid type: map, expected a string for key `package.version` at line 9 column 21

Details about workspace inheritance: https://doc.rust-lang.org/cargo/reference/workspaces.html

robertbastian commented 1 year ago

Consider using the cargo_toml crate to parse Cargo.toml instead of doing it yourself

yassun7010 commented 10 months ago

Any progress on this Issue?

I am very interested in this issue.

alexspa commented 10 months ago

I experience similar problems receiving following errors:

$cargo readme
Error: TOML parse error at line 1, column 1
  |
1 | [package]
  | ^^^^^^^^^^
invalid type: map, expected a string
$cargo readme
Error: TOML parse error at line 1, column 1
  |
1 | [workspace]
  | ^
missing field `package``
joshlf commented 1 month ago

Chiming in as someone broken by this: https://github.com/google/zerocopy/pull/1884

schneems commented 3 weeks ago

Same. Inputs:

$ cat cargo.toml
[workspace]
resolver = "2"
members = [
    "usage",
    "cache_diff",
    "cache_diff_derive",
]

[workspace.package]
version = "0.1.0"
rust-version = "1.82"
edition = "2021"
license = "BSD-3-Clause"
repository = "https://github.com/schneems/cache_diff"
documentation = "https://docs.rs/cache_diff"
⛄️ 3.3.1 🚀 /Users/rschneeman/Documents/projects/cache_diff (main)
$ cat cache_diff/cargo.toml
[package]
name = "cache_diff"
description = "Generate clean, human readable diffs between two cache structs"
include = ["src/**/*", "LICENSE.md", "README.md"]
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
repository.workspace = true
documentation.workspace = true

[dependencies]
cache_diff_derive = { version = "0", optional = true, path = "../cache_diff_derive" }
bullet_stream = { version = "0", optional = true }

[features]
default = ["derive"]
derive = ["dep:cache_diff_derive"]

# Formats values with `bullet_stream::style::value` which includes ANSI colors
bullet_stream = ["derive", "dep:bullet_stream"]

Output:

$ cargo readme --project-root cache_diff > cache_diff/README.md
Error: TOML parse error at line 5, column 1
  |
5 | version.workspace = true
  | ^^^^^^^
invalid type: map, expected a string

You can reproduce with https://github.com/schneems/cache_diff/commit/fff7363cb17610674f10249b76e3aa22e553dd53

Edit: https://crates.io/crates/cargo-rdme works with this workspace