webern / cargo-readme

Generate README.md from docstrings
Other
355 stars 57 forks source link

feature request: convert [`Foo`] to a link to the docs #70

Open dzfranklin opened 3 years ago

dzfranklin commented 3 years ago

I link to doc entries to document the entrypoints of my crate with [`Foo`], and rustdoc transforms them to links. It would be awesome if these were transformed to links to docs.rs.

oconnor663 commented 3 years ago

Making them an actual link would be fabulous. I would also be happy with just stripping the surrounding []. Does anyone know of a workaround for this in the meantime, to avoid needing to manually remove [] after generation?

survived commented 3 years ago

Looks like duplicate of #55

dajoha commented 3 years ago

I would also be happy with just stripping the surrounding []. Does anyone know of a workaround for this in the meantime, to avoid needing to manually remove [] after generation?

You can do it with this command:

sed -i 's/\[\(`[^`]*`\)]/\1/g' README.md

To do it more quickly, you can use this tiny Makefile:

.PHONY: readme

readme: README.md

README.md: src/lib.rs
    @ cargo readme > README.md
    @ sed -i 's/\[\(`[^`]*`\)]/\1/g' README.md

Just in case you don't know make: put the Makefile file at your project's root, then run make readme when you want to update your README.md file.