Skip to content
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

Support intralinks to other item types #169

Open
1 of 4 tasks
orium opened this issue Mar 4, 2023 · 10 comments
Open
1 of 4 tasks

Support intralinks to other item types #169

orium opened this issue Mar 4, 2023 · 10 comments

Comments

@orium
Copy link
Owner

orium commented Mar 4, 2023

Currently not all item types can be used in intralinks:

@RReverser
Copy link

Supporting trait items would be very useful indeed, as it would complete coverage for all top-level items.

@orium
Copy link
Owner Author

orium commented May 13, 2023

You can links to traits, you just can't link to things inside traits, such as methods or associated types.

@RReverser
Copy link

You can links to traits, you just can't link to things inside traits, such as methods or associated types.

Hm that's not what I'm seeing, links to traits don't seem to work either and I'm getting warnings that they're not resolved.

@RReverser
Copy link

Just tried again and it's definitely not resolving my traits:

warning: Could not resolve definition of `crate::api::Focuser`.
warning: Could not resolve definition of `crate::api::ObservingConditions`.
warning: Could not resolve definition of `crate::api::Rotator`.
...

By the way, have you considered using rustdoc's API instead of resolving things manually? @LukeMathWalker did a great talk on it recently, but TLDR is that you can consume data already preprocessed by rustdoc via their JSON format, e.g. via https://crates.io/crates/rustdoc_json.

@orium
Copy link
Owner Author

orium commented May 13, 2023

Just tried again and it's definitely not resolving my traits

Can you point me to your project or give me a minimal example? I can't reproduce it:

$ cat -p src/main.rs
//! [Focuser](crate::api::Focuser)

mod api {
    trait Focuser {
    }
}

fn main() {
}
$ cargo rdme --force
$ cat -p README.md
<!-- cargo-rdme start -->

[Focuser](https://docs.rs/foo/latest/foo/api/trait.Focuser.html)

<!-- cargo-rdme end -->

There's limitation like symbol re-export not working (#5).

have you considered using rustdoc's API instead of resolving things manually?

Have to check that, but if it involves having rust nightly installed (and I'm guessing it does to access the compiler's api) I don't want to use it: I don't want users to have to install anything for cargo-rdme to work.

@RReverser
Copy link

There's limitation like symbol re-export not working (#5).

Ah maybe that's it, I'll recheck.

Have to check that, but if it involves having rust nightly installed (and I'm guessing it does to access the compiler's api) I don't want to use it: I don't want users to have to install anything for cargo-rdme to work.

I think it does for now but if it will support arbitrary rustdoc out of the box it seems worth it - it's easier to install nightly toolchain and do cargo +nightly install cargo-rdme than it is to rewrite docs just to account for cargo-rdme's limitations.

@RReverser
Copy link

RReverser commented May 13, 2023

it's easier to install nightly toolchain and do cargo +nightly install cargo-rdme than it is to rewrite docs just to account for cargo-rdme's limitations

Besides, you could probably even link it statically with the rustdoc crate and ship binaries on Cargo releases so users wouldn't have to build / install anything at all. Although that seems a more unstable route than relying on JSON output from the actual binary.

@RReverser
Copy link

I should probably also link to https://rust-lang.github.io/rfcs/2963-rustdoc-json.html which has a fairly detailed documentation of the format.

@RReverser
Copy link

There's limitation like symbol re-export not working (#5).

Ah I missed log at the top:

warning: Unable to find module file for module crate::api in directory "..."

I think the problem is that I'm using module with custom path via #[path = "..."] mod api; attribute.

@orium
Copy link
Owner Author

orium commented Aug 16, 2023

By the way, have you considered using rustdoc's API instead of resolving things manually? @LukeMathWalker did a great talk on it recently, but TLDR is that you can consume data already preprocessed by rustdoc via their JSON format, e.g. via crates.io/crates/rustdoc_json.

I decided to give it a go (#177). I'm implementing this in branch https://github.com/orium/cargo-rdme/tree/rustdoc-json. Very preliminary work, but it already passes 44 integration tests (and fail 7).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants