Skip to content

Look into ways to decouple some crate metadata from Cargo.toml #3167

@jtgeibel

Description

@jtgeibel

An outline of our current scheme for crate and version level metadata (with quoted fields coming from Cargo.toml:

  • Crate-wide metadata
    • description
    • homepage
    • documentation
    • repository
    • categories
    • keywords
    • badges (largely deprecated)
    • readme (we cache the most recent readme for search)
  • Version specific metadata
    • features
    • license
    • crate_size
    • published_by
    • authors

With the exception of authors, all of the version specific metadata is clearly immutably tied to the specific crate that was published under that name and version. For the crate-wide metadata, it can be annoying to be required to publish a new version to update these fields.

It would be nice if the crate-wide metadata was managed through the web interface (Edit: and eventually a stable API to support cargo integration and other tooling), instead of via Cargo.toml.

Suggestions

For optional fields, we can probably do something like:

  • If the latest stable doesn't specify the field, then it can be added/edited in the frontend UI. If the field is defined, the frontend can direct the user to first publish a new version without the field.
  • If a new stable release overwrites the field by adding it to Cargo.toml, then we overwrite the value and return the previous contents in a warning to the user. (If this was a mistake, then the user has to publish a new crate that is otherwise a no-op. This is a bit unfortunate, but seems better than forcing a new publish to change any piece of metadata.)

The only required crate-wide field is description. I don't see changing this as high-priority, so we can focus on the optional fields.

A few additional notes

We've had bugs in the past where publishing 0.2.1 and backporting to 0.1.12 would overwrite metadata unexpectedly if they were published in that order. Off the top of my head, I don't know exactly how we handle pre-releases and metadata updates. My point is, saving the metadata from the "right" release isn't entirely straightforward and might cause unexpected results. It would be nice if we could reduce the user impact of this complexity.

The documentation field is a bit interesting, because there is no way for a crate version to link directly to version specific information. We fixup any docs.rs links automatically in the frontend so that they automatically point to the correct version specific documentation (matching the behavior for when a value is not provided). This means that user can either have automatic version-specific links to docs.rs, or one link to their most recent 3rd party documentation for all their releases. (Edit: I think we could improve this field by supporting some type of {$version} placeholder where crates.io would automatically customize the URL for each release but it would only need to be set once globally for the crate and could be easily modified if a project's 3rd party documentation moves.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancement ✨Category: Adding new behavior or a change to the way an existing feature works

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions