diff --git a/CHANGELOG.md b/CHANGELOG.md index 30ad5b0..9e9e766 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) @@ -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) diff --git a/README.md b/README.md index 9775743..ff3e00e 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,34 @@ Format markdown code snippets using your favorite code formatters. +## Table of contents + + + +- [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) + + + ``` diff --git a/codegen/src/readme/mod.rs b/codegen/src/readme/mod.rs index e3501bc..41bb912 100644 --- a/codegen/src/readme/mod.rs +++ b/codegen/src/readme/mod.rs @@ -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 { @@ -50,6 +51,14 @@ pub fn generate(plugins: Vec, commands: Vec) -> 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(()) diff --git a/codegen/src/readme/table_of_contents.rs b/codegen/src/readme/table_of_contents.rs new file mode 100644 index 0000000..82db018 --- /dev/null +++ b/codegen/src/readme/table_of_contents.rs @@ -0,0 +1,11 @@ +pub fn generate() -> anyhow::Result { + 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) +}