rust-lang / rust-lang/rust

rustdoc: add link prefix which would allow overwriting explicit links with item links

Open
#127,086 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-rustdoc-js A-rustdoc-ui C-feature-request T-rustdoc
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Many crates use #![doc = include_str("../README.md")] to reduce doc duplication. Unfortunately, it means that we have provide explicit item links:

This crate provides the [`foobar`] function.

[`foobar`]: https://docs.rs/foobar/latest/foobar/fn.foobar.html

It works fine when README is rendered on GitHub or crates.io, but when docs generated by rustdoc we get external item links, which causes a number of issues (e.g. when docs generated offline).

It would be nice if rustdoc recognized a special link prefix which would allow it to overwrite explicit links with auto-generated item links. For example:

This crate provides the [`foobar`][rustdoc:foobar] function.

[rustdoc:foobar]: https://docs.rs/foobar/latest/foobar/fn.foobar.html

[link][rustdoc:item] would be translated to [link](link-to-item) and [rustdoc::item]: explicit-link would be ignored by rustdoc.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named in the issue. Start by tracing rustdoc's handling of explicit Markdown reference links and item-link resolution, then compare the README example with generated rustdoc output. Done means the proposed prefix behavior is specified and covered for both link forms, including offline-generated documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.