Giter Club home page Giter Club logo

cargo-onedoc's Introduction

cargo-onedoc

Crates.io Version Docs.rs Latest Build Status

๐Ÿ“ Generate README.md from doc comments.

Only write your documentation once! This crate provides a Cargo subcommand that can generate Markdown files from your Rust doc comments.

Features

This tool can take one or more Markdown files and/or Rust source files and output a single Markdown file.

When converting between Rustdoc Markdown and CommonMark, the following changes are made.

Headings

Headings are increased by one level. E.g. # becomes ##. For example:

//! ## MSRV
//!
//! Currently the minimum supported version is 1.51.0.

Will become

### MSRV

Currently the minimum supported version is 1.51.0.

Codeblocks

Bare codeblocks are fenced as Rust codeblocks e.g. ```rust. Leading # comments from codeblocks are removed. For example the following doc comment

//! ```
//! # fn main() {
//! println!("Hello, world!");
//! # }
//! ```

Will become

```rust
println!("Hello, world!");
```

Intradoc links

Intra doc links are converted based on the the links section of the config. For example assuming the following config:

[links]
"String" = "https://doc.rust-lang.org/stable/std/string/struct.String.html"

The following doc comment

//! Render the template to a [`String`].

Will become

Render the template to a [`String`](https://doc.rust-lang.org/stable/std/string/struct.String.html).

Config

This tool can be configured using a onedoc.toml file. There are two main sections doc and links.

doc

The doc section is used to specify the input files and the output file. The input field is a list of files to read. The output field is the file to write to. The template field is the template file to use. Here is an example from the sheldon repository.

[[doc]]
input = [
    "docs/src/Installation.md",
    "docs/src/Getting-started.md",
    "docs/src/Command-line-interface.md",
    "docs/src/Configuration.md",
]
output = "README.md"
template = "docs/README_TEMPLATE.md"

links

The links is used to specific intra doc link mapping. This is needed because this tool does not figure out the correct link to use. This is simply a mapping of the link text to the URL.

[links]
"Display" = "https://doc.rust-lang.org/stable/std/fmt/trait.Display.html"

License

This project is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.

cargo-onedoc's People

Contributors

rossmacarthur avatar

Stargazers

 avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.