Skip to content

Commit 7891813

Browse files
authored
docs: improve md usage examples (#1199)
1 parent ba7139f commit 7891813

File tree

5 files changed

+37
-79
lines changed

5 files changed

+37
-79
lines changed

build/util.cjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ var proxyOverride = (origin, ...fallbacks) => new Proxy(origin, {
110110
return (_b = (_a = fallbacks.find((f) => key in f)) == null ? void 0 : _a[key]) != null ? _b : Reflect.get(target, key);
111111
}
112112
});
113-
var toCamelCase = (str) => str.toLowerCase().replace(/([a-z])[_-]+([a-z])/g, (_, p1, p2) => {
114-
return p1 + p2.toUpperCase();
115-
});
113+
var toCamelCase = (str) => str.toLowerCase().replace(/([a-z])[_-]+([a-z])/g, (_, p1, p2) => p1 + p2.toUpperCase());
116114
var parseBool = (v) => v === "true" || v !== "false" && v;
117115
var getLines = (chunk, next) => {
118116
const lines = ((next.pop() || "") + bufToString(chunk)).split(/\r?\n/);

docs/.vitepress/config.mts

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -78,34 +78,11 @@ export default defineConfig({
7878
{ text: 'Quotes', link: '/quotes' },
7979
{ text: 'Shell', link: '/shell' },
8080
{ text: 'TypeScript', link: '/typescript' },
81-
{ text: 'Markdown Scripts', link: '/markdown-scripts' },
81+
{ text: 'Markdown Scripts', link: '/markdown' },
8282
{ text: 'Known Issues', link: '/known-issues' },
8383
],
8484
},
8585
],
86-
87-
'/v7/': [
88-
{
89-
text: 'Docs (v7)',
90-
items: [
91-
{ text: 'Getting Started', link: '/v7/getting-started' },
92-
{ text: 'Process Promise', link: '/v7/process-promise' },
93-
{ text: 'API Reference', link: '/v7/api' },
94-
{ text: 'Configuration', link: '/v7/configuration' },
95-
{ text: 'CLI Usage', link: '/v7/cli' },
96-
],
97-
},
98-
{
99-
text: 'FAQ',
100-
link: '/v7/faq',
101-
items: [
102-
{ text: 'Quotes', link: '/v7/quotes' },
103-
{ text: 'TypeScript', link: '/v7/typescript' },
104-
{ text: 'Markdown Scripts', link: '/v7/markdown-scripts' },
105-
{ text: 'Known Issues', link: '/v7/known-issues' },
106-
],
107-
},
108-
],
10986
},
11087

11188
socialLinks: [{ icon: 'github', link: 'https://github.com/google/zx' }],

docs/markdown-scripts.md

Lines changed: 0 additions & 46 deletions
This file was deleted.

docs/markdown.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Markdown
1+
# Markdown Scripts
22

3-
Imagine a script with code blocks, comments, schemas, illustrations, etc. Markdown is right for this purpose.
4-
Combine `ts`, `js`, `bash` sections to produce a single script. For example:
3+
Imagine a script with code blocks, formatted comments, schemas, illustrations, etc. [Markdown](https://en.wikipedia.org/wiki/Markdown) is right for this purpose.
4+
Combine `ts`, `js`, `bash` sections to produce a single zx scenario. For example:
55

66
````text
77
# Some script
@@ -40,3 +40,32 @@ The rest is simple: just run via `zx` command:
4040
```bash
4141
zx script.md
4242
```
43+
44+
## Hints
45+
You can use imports here as well:
46+
47+
```js
48+
await import('chalk')
49+
```
50+
51+
`js`, `javascript`, `ts`, `typescript`, `sh`, `shell`, `bash` code blocks will be executed by zx.
52+
53+
```bash
54+
VAR=$(date)
55+
echo "$VAR" | wc -c
56+
```
57+
58+
Other kinds are ignored:
59+
60+
```css
61+
body .hero {
62+
margin: 42px;
63+
}
64+
```
65+
66+
The `__filename` will be pointed to **markdown.md**:
67+
68+
```js
69+
console.log(chalk.yellowBright(__filename))
70+
```
71+

src/util.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ export const proxyOverride = <T extends object>(
163163
}) as T
164164

165165
export const toCamelCase = (str: string) =>
166-
str.toLowerCase().replace(/([a-z])[_-]+([a-z])/g, (_, p1, p2) => {
167-
return p1 + p2.toUpperCase()
168-
})
166+
str
167+
.toLowerCase()
168+
.replace(/([a-z])[_-]+([a-z])/g, (_, p1, p2) => p1 + p2.toUpperCase())
169169

170170
export const parseBool = (v: string): boolean | string =>
171171
v === 'true' || (v !== 'false' && v)

0 commit comments

Comments
 (0)