-
Notifications
You must be signed in to change notification settings - Fork 630
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
Relative URLs in subdirectory readmes #3484
Comments
Relative links are not rendered properly on crates.io; see rust-lang/crates.io#3484
@rustbot claim I started looking at this. Unfortunately, as @clehner determined, it seems that crates.io doesn't have enough information at time of render to determine the subdirectory that the README is in. relevant code: crates.io/src/controllers/krate/publish.rs Line 189 in d04dc22
and relevant code where "readme_file" is determined in cargo
Not sure this helps here - as the homepage isn't necessarily on github/etc showing code.
This definitely doesn't seem like something we'd want to expose as something to fill in the Cargo.toml. Seems that cargo should be able to infer it. Perhaps it could be inferred by cargo and added here. Still seems like if it's possible to do this with less complexity, we should see if we can.
Again - something we could have cargo infer and send on the network to crates.io Proposal: crates.io already gets the
This would handle readmes not in root (eg docs/README.md), but only if the Cargo.toml was in the repo root As a bonus, if we want to handle Cargo.toml that aren't in the repo root, we can
|
Added unit tests to confirm things work. Manually tested end to end and confirmed that the rendered page has a properly working relative link as long as the Cargo.toml is in the root of the repo. We'll need to update cargo as mentioned in rust-lang#3484 in order to support Cargo.toml that aren't in the root of the repo
Added unit tests to confirm things work. Manually tested end to end and confirmed that the rendered page has a properly working relative link as long as the Cargo.toml is in the root of the repo. We'll need to update cargo as mentioned in rust-lang#3484 in order to support Cargo.toml that aren't in the root of the repo
I took a stab at this in #3861 |
Also took a stab at this in |
Added unit tests to confirm things work. Manually tested end to end and confirmed that the rendered page has a properly working relative link as long as the Cargo.toml is in the root of the repo. We'll need to update cargo as mentioned in rust-lang#3484 in order to support Cargo.toml that aren't in the root of the repo
Added unit tests for publishing with - cargo.toml in root + readme in root - cargo.toml in root + readme in subdir - cargo.toml in subdir + readme next to it - cargo.toml in subdir + readme in root (../README) Should fix rust-lang/crates.io#3484 in combination with rust-lang/crates.io#3861
Added unit tests for publishing with - cargo.toml in root + readme in root - cargo.toml in root + readme in subdir - cargo.toml in subdir + readme next to it - cargo.toml in subdir + readme in root (../README) Should fix rust-lang/crates.io#3484 in combination with rust-lang/crates.io#3861
Added unit tests to confirm things work. Manually tested end to end and confirmed that the rendered page has a properly working relative link as long as the Cargo.toml is in the root of the repo. We'll need to update cargo as mentioned in rust-lang#3484 in order to support Cargo.toml that aren't in the root of the repo
Leverage readme_path to support relative paths from readme's not at root Added unit tests to confirm things work. Manually tested end to end and confirmed that the rendered page has a properly working relative link as long as the Cargo.toml is in the root of the repo. We'll need to update cargo as mentioned in #3484 in order to support Cargo.toml that aren't in the root of the repo
controllers::krate::publish: Move reading of tarball up from uploader to publish Pull upward hex_cksum and verify_tarball to publish to the point before readme rendering - so that readme can leverage information from tarball. Additionally, it will avoid rendering readme for failure cases where the tarball doesn't verify. Will be useful to access cargo_vcs_info earlier on (for #3484)
During readme markdown rendering, links with relative URLs in a crate's readme are resolved relative to the repository root, even if the crate and its readme file are in a subdirectory of the repository. This breaks consistency with how relative URLs are resolved in the source site - relative to the file in the subdirectory.
An example of a repository with multiple crates in subdirectories (using absolute URLs in the readmes):
https://github.com/RustCrypto/elliptic-curves/
An example of a crate published from a subdirectory using relative URLs in the readme which are rendered broken:
https://crates.io/crates/ssi-contexts/0.0.2
while in the source code they are working:
https://github.com/spruceid/ssi/blob/ssi-contexts%2F/v0.0.2/contexts/README.md
It would be nice if relative URLs could be used in subdirectory readmes. Possible solutions:
homepage
property rather than therepository
property.readme_url
metadata field, to use as the base URL for resolution.repository_path
metadata field that would be the path of the crate in the repository - where the readme is assumed to reside - for use in evaluating relative URLs in the readme.The text was updated successfully, but these errors were encountered: