Skip to content

Commit

Permalink
docs: improve auto format
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Feb 21, 2024
1 parent f59c5a6 commit 1fc788a
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 49 deletions.
7 changes: 5 additions & 2 deletions .config/automd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default <Config>{
.join(" ")
.trim();

const input = `<!-- automd:${generator} ${argsString} -->\n<!-- /automd -->`;
const input = `<!-- automd:${generator}${argsString ? ` ${argsString}` : ""} -->\n<!-- /automd -->`;
const output = (await transform(input)).contents;
return {
contents: `### Input\n\n${_mdCode(input)}\n\n### Output\n\n${_mdCode(output)}`,
Expand All @@ -35,6 +35,9 @@ export default <Config>{
function _mdCode(md: string) {
return md
.split("\n")
.map((l) => ` ${l}`)
.map((l) => {
l = l.trim();
return l ? ` ${l}` : "";
})
.join("\n");
}
4 changes: 2 additions & 2 deletions docs/2.generators/badges.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ The `badges` generator generates badges for the latest npm version, npm download
### Output

<!-- automd:badges color="yellow" license name="defu" codecov bundlephobia packagephobia -->

[![npm version](https://flat.badgen.net/npm/v/defu?color=yellow)](https://npmjs.com/package/defu)
[![npm downloads](https://flat.badgen.net/npm/dm/defu?color=yellow)](https://npmjs.com/package/defu)
[![bundle size](https://flat.badgen.net/bundlephobia/minzip/defu?color=yellow)](https://bundlephobia.com/package/defu)
[![install size](https://flat.badgen.net/packagephobia/publish/defu?color=yellow)](https://packagephobia.com/result?p=defu)
[![codecov](https://flat.badgen.net/codecov/c/github/unjs/automd?color=yellow)](https://codecov.io/gh/unjs/automd)
[![license](https://flat.badgen.net/github/license/unjs/automd?color=yellow)](https://github.com/unjs/automd/blob/main/LICENSE)

<!-- /automd -->

<!-- /automd -->
Expand Down
4 changes: 2 additions & 2 deletions docs/2.generators/contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ The `contributors` generator generates an image of contributors using [contrib.r
### Output

<!-- automd:contributors author="pi0" license="MIT" -->

Published under the [MIT](https://github.com/unjs/automd/blob/main/LICENSE) license.
Made by [@pi0](https://github.com/pi0) and [community](https://github.com/unjs/automd/graphs/contributors) 💛
<br><br>
<a href="https://github.com/unjs/automd/graphs/contributors">
<img src="https://contrib.rocks/image?repo=unjs/automd" />
</a>

<!-- /automd -->

<!-- /automd -->
Expand Down
10 changes: 5 additions & 5 deletions docs/2.generators/fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ The `fetch` generator fetches a URL (using [unjs/ofetch](https://ofetch.unjs.io)
### Output

<!-- automd:fetch url="gh:unjs/automd/main/test/fixture/TEST.md" -->

## The Lazy Coder's Guide to Programming

Programming can be hard. But fear not! With the power of copy-paste, you can conquer any coding challenge without breaking a sweat. Just remember: if it works once, it'll work a thousand times. Who needs original code anyway?

When your code doesn't work, don't blame yourself. It's clearly the compiler's fault for not understanding your genius. Remember, the more error messages you get, the closer you are to becoming a programming master.

Why waste time solving problems when someone else has already done it for you? Stack Overflow is your best friend, your mentor, and your savior. Just make sure to upvote the answers that save your bacon.

<!-- /automd -->

<!-- /automd -->
Expand Down
10 changes: 5 additions & 5 deletions docs/2.generators/file.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ The `file` generator reads a file and inlines it's contents.
### Output

<!-- automd:file src="/test/fixture/TEST.md" -->

## The Lazy Coder's Guide to Programming

Programming can be hard. But fear not! With the power of copy-paste, you can conquer any coding challenge without breaking a sweat. Just remember: if it works once, it'll work a thousand times. Who needs original code anyway?

When your code doesn't work, don't blame yourself. It's clearly the compiler's fault for not understanding your genius. Remember, the more error messages you get, the closer you are to becoming a programming master.

Why waste time solving problems when someone else has already done it for you? Stack Overflow is your best friend, your mentor, and your savior. Just make sure to upvote the answers that save your bacon.

<!-- /automd -->

<!-- /automd -->
Expand Down
22 changes: 11 additions & 11 deletions docs/2.generators/jsdocs.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@ Internally it uses [untyped](https://untyped.unjs.io/) and [jiti](https://github
### Output

<!-- automd:jsdocs src="/test/fixture/src/example" -->

### `add(a, b)`

Adds two numbers together.

**Example:**

```js
add(1, 2); // 3
```

### `object`

#### `key`

An object key

##### `subkey`

- **Type**: `string`
- **Default**: `"value"`

A subkey

<!-- /automd -->

<!-- /automd -->
Expand Down
14 changes: 7 additions & 7 deletions docs/2.generators/jsimport.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ The `jsimport` generator generates JavaScript usage example to be imported.
### Output

<!-- automd:jsimport cjs cdn name="pkg" imports="foo,bar" -->

**ESM** (Node.js, Bun)

```js
import { foo, bar } from "pkg";
```

**CommonJS** (Legacy Node.js)

```js
const { foo, bar } = require("pkg");
```

**CDN** (Deno, Bun and Browsers)

```js
import { foo, bar } from "https://esm.sh/pkg";
```

<!-- /automd -->

<!-- /automd -->
Expand Down
12 changes: 6 additions & 6 deletions docs/2.generators/pm-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ The `pm-install` or `pm-i` generator generates installation commands for several
### Output

<!-- 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 -->

<!-- /automd -->
Expand Down
8 changes: 4 additions & 4 deletions docs/2.generators/pm-x.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ The `pm-x` generator generates commands for running/executing a package through
### Output

<!-- automd:pm-x version="latest" name="package-name" args="\"[files]" <flags>" -->

```sh
# npm
npx package-name@latest "[files]

# pnpm
pnpm dlx package-name@latest "[files]

# bun
bunx package-name@latest "[files]
```

<!-- /automd -->

<!-- /automd -->
Expand Down
10 changes: 5 additions & 5 deletions docs/2.generators/with-automd.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ The `with-automd` generator generates a benner that notifies docs are updated wi

### Input

<!-- automd:with-automd -->
<!-- automd:with-automd -->
<!-- /automd -->

### Output

<!-- automd:with-automd -->
<!-- automd:with-automd -->

---

_🤖 auto updated with [automd](https://automd.unjs.io)_

<!-- /automd -->

<!-- /automd -->
Expand Down

0 comments on commit 1fc788a

Please sign in to comment.