Skip to content

[feature] include files linked in the README #5

Description

@PicoJr

Hello,

given the following dummy cargo layout:

.
├── Cargo.lock
├── Cargo.toml
├── dummy.txt
├── img
│  └── dummy.png
├── README.md
├── src
│  └── main.rs
└── target

and the following README.md:

───────┬──────────────────────────────────────────────
       │ File: README.md
───────┼──────────────────────────────────────────────
   1   │ # Dummy
   2   │ 
   3   │ ![dummy.png](img/dumy.png)
───────┴──────────────────────────────────────────────

Cargo diet does not keep the img/dummy.png.

❯ cargo diet -n
┌───────────────┬─────────────┐
│ File          │ Size (Byte) │
├───────────────┼─────────────┤
│ img/dummy.png │           0 │
│ .gitignore    │           8 │
│ dummy.txt     │        1998 │
└───────────────┴─────────────┘
Saved 87% or 2.0 KB in 3 files (of 2.3 KB and 6 files in entire crate)

The following change WOULD be made to Cargo.toml:
Diff - removed / added + :
[…skipped 3 lines…]

edition = "2018"
+include = ["src/main.rs", "README.md"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[…skipped 3 lines…]

Assuming the readme field is set to README.md it means the crate's README on crates.io will have a broken link.

Would it be possible to also include local files linked in the README?

It would require tokenizing the README, extract urls, filter out non local urls, add those urls to "include".

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions