#cargo-subcommand #rustdoc #cargo #github-actions #create-file #generate-markdown #doc2readme

bin+lib cargo-doc2readme

cargo subcommand to create a readme file containing the rustdoc comments from your code

24 releases

0.5.0 Nov 10, 2024
0.4.2 May 13, 2024
0.4.1 Apr 24, 2024
0.4.0 Mar 24, 2024
0.0.5 Jun 18, 2021

#100 in Cargo plugins

Download history 4/week @ 2024-08-25 1/week @ 2024-09-01 7/week @ 2024-09-08 16/week @ 2024-09-22 2/week @ 2024-09-29 1/week @ 2024-10-06 7/week @ 2024-10-13 1/week @ 2024-10-20 8/week @ 2024-10-27 7/week @ 2024-11-03 126/week @ 2024-11-10 19/week @ 2024-11-17

160 downloads per month

Apache-2.0

80KB
2K SLoC

cargo-doc2readme License: Apache-2.0 cargo-doc2readme on crates.io Source Code Repository Rust Version: 1.61.0

cargo doc2readme is a cargo subcommand to create a readme file to display on GitHub or crates.io, containing the rustdoc comments from your code.

Installation

If you are using ArchLinux, you can install cargo-doc2readme from the AUR:

yay -S cargo-doc2readme

On other Operating Systems, make sure you have Rust installed (using your distributions package manager, but if your package manager is garbage or you are running Windows, try rustup) and then run the following command:

cargo install cargo-doc2readme

Usage

To generate your readme, simply run

cargo doc2readme

This will output the readme to a file called README.md, using README.j2 or the built-in template.

If you want to run this using GitHub Actions, you can use the pre-built docker image:

readme:
  runs-on: ubuntu-latest
  steps:
    - uses: actions/checkout@v3
    - uses: docker://ghcr.io/msrd0/cargo-doc2readme
      with:
        entrypoint: cargo
        args: doc2readme --check

This will use the latest stable Rust version available when the latest release of cargo doc2readme was created. If you need a newer/nightly Rust compiler, use the ghcr.io/msrd0/cargo-doc2readme:nightly docker image instead.

Features

  • parse markdown from your rustdoc comments and embed it into your readme
  • use existing crates to parse Rust and Markdown
  • support your [CustomType] rustdoc links
  • default, minimalistic readme template with some useful badges
  • custom readme templates

Non-Goals

  • verbatim copy of your markdown
  • easy readability of the generated markdown source code

Similar tools

cargo readme is a similar tool. However, it brings its own Rust code parser that only covers the 95% use case. Also, it does not support Rust path links introduced in Rust 1.48, making your readme ugly due to GitHub showing the unsupported links as raw markdown, and being less convenient for the reader that has to search docs.rs instead of clicking on a link.

Stability Guarantees

This project adheres to semantic versioning. All versions will be tested against the latest stable rust version at the time of the release. All non-bugfix changes to the rustdoc input processing and markdown output or the default readme template are considered breaking changes, as well as any non-backwards-compatible changes to the command-line arguments or to these stability guarantees. All other changes, including any changes to the Rust code, or bumping the MSRV, are not considered breaking changes.

Dependencies

~10–24MB
~329K SLoC