Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/electrovir/markdown-code-example-inserter
Syncs code examples with markdown documentation.
https://github.com/electrovir/markdown-code-example-inserter
automatic code examples insert inserter interpolator markdown readme snippet
Last synced: 3 months ago
JSON representation
Syncs code examples with markdown documentation.
- Host: GitHub
- URL: https://github.com/electrovir/markdown-code-example-inserter
- Owner: electrovir
- License: cc0-1.0
- Created: 2021-10-08T10:54:23.000Z (about 3 years ago)
- Default Branch: dev
- Last Pushed: 2024-09-25T20:34:12.000Z (3 months ago)
- Last Synced: 2024-10-05T04:24:31.395Z (3 months ago)
- Topics: automatic, code, examples, insert, inserter, interpolator, markdown, readme, snippet
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/markdown-code-example-inserter
- Size: 1.28 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-CC0
Awesome Lists containing this project
README
# markdown-code-example-inserter
Syncs markdown documentation with code examples.
# Install
Via [npm](https://www.npmjs.com/package/markdown-code-example-inserter):
```bash
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:
```html
```
[Here's an example](https://raw.githubusercontent.com/electrovir/markdown-code-example-inserter/main/test-files/full-package-example/README.md) from the GitHub repo. And here is the same file [with the code examples inserted](https://github.com/electrovir/markdown-code-example-inserter/blob/main/test-files/full-package-example/README.expect.md).
## CLI
```bash
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):
```bash
npx md-code "./*.md"
```### Check only
Use `--check`.
Check if the given files are updated, don't write anything.
```bash
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:
```bash
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`.
```bash
npx md-code "./**/*.md" --ignore "./test-files/**/*"
```Multiple `--ignore` patterns can be used:
```bash
npx md-code "./**/*.md" --ignore "./test-files/**/*" -ignore "./test-files/**/*"
````node_modules` is automatically ignored.
### Turn off logging
Use `--silent`
```bash
npx md-code --silent file1.md
```