-
Notifications
You must be signed in to change notification settings - Fork 274
Description
It would be very helpful to be able to register a callback function that is called whenever the parser encounters a reference link it doesn't have a definition for.
If I'm not mistaken, it should suffice to add a new constructor Parse::with_ref_link_callback(text, fn) and call fn, if set, here instead of returning None directly:
Please let me know if this is something you want to do in this project, and what your preferred API would look like.
Context
@QuietMisdreavus and @Manishearth are currently working on implement Rust RFC 1946 "Intra rustdoc links" in rust-lang/rust#47046.
The RFC's goal is to make it easy to link to Rust items in doc comments, and the main way to do that is by adding "implied ref links": You can write a doc comment containing
This calls [foo()] with the given [::bar::Baz].
and rustdoc will generate the correct links to the function foo and the type Baz.
Rustdoc will soon use pulldown-cmark, and our goal is to land this feature once it does. Sadly, the current API of pulldown will return links without definitions as text events, so we can't dynamically generate and add these links. Adding all link definitions up front is not viable, as there may be links to external crates, which means the number of possible definitions is infinite.