1.1.0 • Published 3 years ago

@handbook/markdown-source-import v1.1.0

Weekly downloads
62
License
MIT
Repository
github
Last release
3 years ago

@handbook/markdown-source-import

NPM TEST codecov

What does this do?

This tool gives two markdown comments.

For example,

# Source

<!-- source file.ts -->
<!-- /source -->

# List

<!-- index packages/**/*.md -->
<!-- /index -->

This tool will transform the markdown document into the below.

# Source

<!-- source file.ts -->

```ts
// file.ts
console.log('hello world');
```

<!-- /source -->

# List

<!-- index packages/**/*.md -->

- [packages/package1/README.md](packages/package1/README.md)
- [packages/package2/README.md](packages/package2/README.md)
- [packages/package3/README.md](packages/package3/README.md)

<!-- /index -->

Usage

Install

npm install @handbook/markdown-source-import --save-dev

Add a script to package.json

{
  "scripts": {
    "source-import": "markdown-source-import README.md src/**/*.md"
  }
}

And if you use husky or the other pre-commit hook.

{
  "husky": {
    "pre-commit": "markdown-source-import README.md src/**/*.md --git-add"
  }
}

Magic Comments

# Import Source

## Single file

<!-- source file.ts -->
<!-- /source -->

## Multiple files

<!-- source file1.ts file2.ts file3.ts -->
<!-- /source -->

## Glob

<!-- source tests/*.ts -->
<!-- /source -->

## `--pick` (only support js, jsx, ts, tsx)

<!-- source file.ts --pick "someFunction SomeType SomeClass" -->
<!-- /source -->

# Create Index

<!-- index src/**/*.md -->
<!-- /index -->

See more

  • @handbook/* This package is one of @handbook/* packages. Go to the project home and see more details.

Related Projects