Package Exports
- automd
Readme
🤖 automd
Your automated markdown maintainer!
[!NOTE] This project is in the early stages and under development.
🦴 Used by
Usage
Automd scans for the annotation comments within the markdown document and updates their contents using built-in generators.
The syntax is like this:
Using CLI
The easiest way to use automd is to use the CLI. You can install automd and add it to the build or release command in package.json or directly run npx automd in your project.
npx automd@latestBy default, the README.md file in the current working directory will be used as the target.
You can use --dir and --file arguments to customize the default behavior to operate on any other markdown file.
Configuration
You can specify configuration in .automdrc or automd.config (js, ts, mjs, cjs or json format) (powered by unjs/c12).
Example: automd.config.js
/** @type {import("automd").Config} */
export default {
file: "DOCS.md",
};Config
dir: Working directory (defaults to current working directory)- You can use
--dirto override with CLI
- You can use
file: The markdown file name or path (relative to dir)- You can use
--fileto override with CLI
- You can use
generators: A map of generator names to custom generators- You can use
automd.configto specify them
- You can use
Programmatic API
[WIP]
Generators
There are several available generators for automd each supporting different arguments.
See open issues for proposed generators and feel free to suggest any generator ideas to be included!
jsdocs
The jsdocs generator can automatically read through your code and extract and sync documentation of function exports leveraging JSDocs and TypeScript hints.
Internally it uses untyped and jiti loader for JSDocs parsing and TypeScript support.
Usage
<!-- automd:jsdocs" src="./src/index" -->
<!-- /automd -->(make sure to have some utility exports in src/index.ts annotated with JSDocs.)
Updated Result:
<!-- automd:jsdocs" src="./src/index" -->
### `add(a, b)`
Adds two numbers together.
**Example:**
```js
add(1, 2); // 3
```
<!-- /automd -->Arguments
src: Path to the source file. The default is./src/indexand can be omitted.headingLevel: Nested level for markdown group headings (default is2=>##). Note: Each function usesheadingLevel+1for the title in nested levels.group: Only render function exports annotated with@group name. By default, there is no group filter. Value can be a string or an array of strings.
pm-install
The pm-install generator generates commands for several JavaScript package managers.
Usage
<!-- automd:pm-install" name=package-name dev -->
<!-- /automd -->Updated Result:
<!-- automd:pm-install" name=package-name dev -->
```sh
# ✨ Auto-detect
npx nypm i -D package-name
# npm
npm install -D package-name
# yarn
yarn add -D package-name
# pnpm
pnpm install -D package-name
# bun
bun install -D package-name
```
<!-- /automd -->Arguments
name: The package name (by default tries to read from thenamefield inpackage.json).dev: Install as a dev dependency. (defaults tofalse).auto: Auto-detect package manager using unjs/nypm. (defaults totrue).
pm-x
The pm-x generator generates commands for running a package through JavaScript package managers.
Usage
<!-- automd:pm-x" name="package-name" usage="[files] <flags>" -->
<!-- /automd -->Updated Result:
<!-- automd:pm-x" name="package-name" usage="[files] <flags>" -->
```sh
# npm
npx package-name@latest [files] <flags>
# pnpm
pnpm dlx package-name@latest [files] <flags>
# bun
bunx package-name@latest [files] <flags>
```
<!-- /automd -->Arguments
name: The package name (by default tries to read from thenamefield inpackage.json).usage: An additional string appended at the end of each command suggesting usage. (defaults to"").
badges
The badges generator generates badges for npm version, npm downloads and some optional ones like codecov and bundle.
Usage
<!-- automd:badges name=defu codecov bundlephobia -->
<!-- /automd -->Updated Result:
<!-- automd:badges name=defu codecov bundlephobia -->
[](https://npmjs.com/package/defu)
[](https://npmjs.com/package/defu)
[](https://bundlephobia.com/package/defu)
[](https://codecov.io/gh/unjs/automd)
<!-- /automd -->Arguments
name: The npm package name. By default tries to infer frompackage.json.github: Github repository name. By default tries to infer frompackage.json.bundlephobia: Show bundle-phobia badge (requiresname).codecov: Enable codecov badge (requiresgithub).no-npmDownloads: Hide npm downloads badge.no-npmVersion: Hide npm version badge.provider: Can be one ofshields(for shields.io) orbadgen/badgenClassic(for badgen.net). Default isbadgen.
[!TIP] You can use additional
style,labelColorandcolorargs forshieldsprovider for example:provider=shields style=flat-square labelColor=f0db4f color=18181b.
Development
- Clone this repository
- Install the latest LTS version of Node.js
- Enable Corepack using
corepack enable - Install dependencies using
pnpm install - Run unit tests using
pnpm dev - Run playground test using
pnpm play
License
Made with 💛
Published under MIT License.