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

Implement intralinks for reference-style links #165

Closed smoelius closed 1 year ago

smoelius commented 1 year ago

Resolves #163

I did things a little differently than you suggested. I made MarkdownInlineLink look like this:

struct MarkdownInlineLink {
    text: String,
    inner: MarkdownLink,
}

struct MarkdownLink {
    raw_link: String,
}

This seemed sensible to me since:

  1. The existing MarkdownInlineLink methods did not use text and thus could become MarkdownLink methods.
  2. The markdown_link function could be modified to take a MarkdownLink as its first argument and thus be used in a new function, rewrite_reference_definitions, analogous to rewrite_markdown_links.

A point of note: rewrite_reference_definitions iterates using Parser::reference_definitions. However, the iterator that method returns retains a reference to the parser. As such, the code that would have gone into a markdown_reference_definitions_iterator function (analogous to markdown_inline_link_iterator) is instead inlined into rewrite_reference_definitions. Getting lifetimes to work for a markdown_reference_definitions_iterator function would seem to require non-trivial changes.

Hopefully, everything else is straightforward. Nits are welcome.

codecov-commenter commented 1 year ago

Codecov Report

Merging #165 (956d80a) into master (328d410) will increase coverage by 0.26%. The diff coverage is 100.00%.

:mega: This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master     #165      +/-   ##
==========================================
+ Coverage   90.17%   90.44%   +0.26%     
==========================================
  Files          13       13              
  Lines         957      984      +27     
==========================================
+ Hits          863      890      +27     
  Misses         94       94              
Impacted Files Coverage Δ
src/utils.rs 100.00% <ø> (ø)
src/transform/intralinks/mod.rs 92.94% <100.00%> (+0.66%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

orium commented 1 year ago

Looks good. Thanks.

smoelius commented 1 year ago

Thank you!