orium / cargo-rdme

Cargo command to create the README.md from your crate's documentation
Mozilla Public License 2.0
126 stars 5 forks source link

Intra-doc links are not stripped despite CLI flag #150

Closed jost-s closed 1 year ago

jost-s commented 1 year ago

I have multiple intra-doc links in a repo. To generate a readme, I execute

cargo rdme -w hdi --intralinks-strip-links

Expected

The intra-doc links are removed from the resulting readme.

Actual

Intra-doc links show up in the readme as is.

Repo used to produce the readme: https://github.com/holochain/holochain

The lib.rs intra-doc links are these for example:

//! The second fundamental part of integrity zomes is data validation. For every [operation](holochain_integrity_types::Op)
//! that is produced by an [action](holochain_integrity_types::Action), a
//! validation rule can be specified. Both data types and data values can be
//! validated.

In the generated readme they appear like:

The second fundamental part of integrity zomes is data validation. For every [operation](holochain_integrity_types::Op)
that is produced by an [action](holochain_integrity_types::Action), a
validation rule can be specified. Both data types and data values can be
validated.

This happens both with and without the --intralinks-strip-links flag.

orium commented 1 year ago

Currently cargo-rdme only supports intralinks of this format [⋯](crate::⋯), e.g. [operation](crate::holochain_integrity_types::Op) (that is documented in the README). Please try that and let me know how it works. I'll create an issue to address this limitation.

jost-s commented 1 year ago

I've seen that in the documentation, but didn't know how to apply it.

If I do [operation](crate::holochain_integrity_types::Op), it breaks the link in the generated Rust doc. Running cargo rdme like this produces a different result indeed. However, it always strips the link from operation, regardless of the flag being set or not.

orium commented 1 year ago

Rustdoc does not recognized it because Op is not defined in crate::holochain_integrity_types::Op. cargo-rdme automatically strips intralinks that it does not know where they point to (and emits a warning).

The actual path is [operation](crate::prelude::holochain_integrity_types::Op) and that should work with both rustdoc and cargo-rdme in strip intralinks mode (it won't be able to generate the intralink because it points to another crate, which is not supported currently).

jost-s commented 1 year ago

Thank you for investigating this! I was not resolving the path correctly.

It works indeed now as expected and described. Stripping the links is preferred over invalid links, so I'll refactor all links and strip them for the time being.