3.0.3 • Published 6 months ago

markdown-code-example-inserter v3.0.3

Weekly downloads
-
License
(MIT or CC0 1.0)
Repository
github
Last release
6 months ago

markdown-code-example-inserter

Syncs markdown documentation with code examples.

Install

Via npm:

npm i -D markdown-code-example-inserter

It's recommended to install this package as a dev dependency as it is a build-step operation.

Usage

Markdown files

Add an HTML comment that starts with the following text: example-link:. Then after that text, include a file path to the example file:

<!-- example-link: src/readme-examples/do-thing.ts -->

Here's an example from the GitHub repo. And here is the same file with the code examples inserted.

CLI

npx md-code file1.md file2.md [...moreFiles]

Any of the file names can be a glob. Put the glob in quotes if you wish to prevent your shell from expanding it (this package will expand the glob):

npx md-code "./*.md"

Check only

Use --check.

Check if the given files are updated, don't write anything.

npx md-code file1.md --check

Force an index file

Use --index.

Force an index file for imports that should be rewritten with your package name:

npx md-code file1.md --index path/to/index.ts file2.md [...moreFiles]

The index file is used to replace relative imports with package name imports. Like changing import from '../../index' to import from 'my-package'.

Ignore a pattern

Use --ignore.

npx md-code "./**/*.md" --ignore "./test-files/**/*"

Multiple --ignore patterns can be used:

npx md-code "./**/*.md" --ignore "./test-files/**/*" -ignore "./test-files/**/*"

node_modules is automatically ignored.

Turn off logging

Use --silent

npx md-code --silent file1.md
3.0.3

6 months ago

3.0.2

7 months ago

3.0.1

7 months ago

2.0.4

9 months ago

3.0.0

9 months ago

2.0.3

10 months ago

2.0.2

10 months ago

2.0.1

10 months ago

2.0.0

10 months ago

1.0.0

1 year ago

0.3.3

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.12

3 years ago

0.1.13

3 years ago

0.1.10

3 years ago

0.1.11

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.4

4 years ago

0.1.5

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago

0.0.0

4 years ago