Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: table of contents #534

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [Unreleased](https://github.com/hougesen/mdsf/compare/v0.3.0...HEAD)

- docs: table of contents [`#534`](https://github.com/hougesen/mdsf/pull/534)
- docs: tool table [`#533`](https://github.com/hougesen/mdsf/pull/533)
- build(cargo-dist): bump to 0.25.1 [`#532`](https://github.com/hougesen/mdsf/pull/532)
- build(deps): bump anyhow from 1.0.91 to 1.0.92 [`#531`](https://github.com/hougesen/mdsf/pull/531)
Expand All @@ -16,6 +17,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- ci: run codegen twice [`#526`](https://github.com/hougesen/mdsf/pull/526)
- feat: support unimport [`#525`](https://github.com/hougesen/mdsf/pull/525)
- feat: support ptop [`#524`](https://github.com/hougesen/mdsf/pull/524)
- chore: set version to 0.3.1-dev [`84a4a02`](https://github.com/hougesen/mdsf/commit/84a4a0258ddc16d089a3e01edd4eaaf23d67f49c)

#### [v0.3.0](https://github.com/hougesen/mdsf/compare/v0.2.7...v0.3.0)

Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,34 @@ Format markdown code snippets using your favorite code formatters.

<!-- <a href="https://codecov.io/gh/hougesen/mdsf"><img src="https://codecov.io/gh/hougesen/mdsf/branch/main/graph/badge.svg"/></a> -->

## Table of contents

<!-- START_SECTION:toc -->

- [mdsf](#mdsf)
- [Table of contents](#table-of-contents)
- [Installation](#installation)
- [Linux & MacOS](#linux--macos)
- [Windows](#windows)
- [Cargo](#cargo)
- [npm/npx](#npmnpx)
- [Homebrew](#homebrew)
- [Usage](#usage)
- [Verify code is formatted](#verify-code-is-formatted)
- [Configuration](#configuration)
- [Tools](#tools)
- [Commands](#commands)
- [Shell completions](#shell-completions)
- [Bash](#bash)
- [Bash](#bash-1)
- [Fish](#fish)
- [PowerShell](#powershell)
- [Elvish](#elvish)
- [Acknowledgement](#acknowledgement)
- [Alternatives to mdsf](#alternatives-to-mdsf)

<!-- END_SECTION:toc -->

<!-- START_SECTION:base-command-help -->

```
Expand Down
9 changes: 9 additions & 0 deletions codegen/src/readme/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::tools::{GeneratedCommand, Tool};

mod command_help;
mod command_table;
mod table_of_contents;
mod tool_table;

pub fn pad_right(mut input: String, len: usize, update: char) -> String {
Expand Down Expand Up @@ -50,6 +51,14 @@ pub fn generate(plugins: Vec<Tool>, commands: Vec<GeneratedCommand>) -> anyhow::
readme = update_readme(&readme, "supported-tools", &tool_table)?;
}

std::fs::write("./README.md", &readme)?;

{
let t = table_of_contents::generate()?;

readme = update_readme(&readme, "toc", &t)?;
}

std::fs::write("./README.md", readme)?;

Ok(())
Expand Down
11 changes: 11 additions & 0 deletions codegen/src/readme/table_of_contents.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pub fn generate() -> anyhow::Result<String> {
let output = std::process::Command::new("npx")
.arg("--yes")
.arg("markdown-toc")
.arg("README.md")
.output()?;

let toc = String::from_utf8(output.stdout)?;

Ok(toc)
}
Loading