@vanillaes/jsdown 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <h1 align="center">JSDown</h1>
4
4
 
5
- <div align="center">📜 Markdown Doc Generator for JSDoc 📜</div>
5
+ <div align="center">📜 Markdown Documentation Generator for JSDoc 📜</div>
6
6
 
7
7
  <br />
8
8
 
@@ -18,6 +18,8 @@
18
18
 
19
19
  - **No Configuration**
20
20
  - Feed it JSDoc types and it spits out Markdown
21
+ - The following are ignored by default: `node_modules/`, `coverage/`, `vendor/`, `*.spec.js`, `*.min.js`, and hidden files.
22
+
21
23
 
22
24
  ## jsdown
23
25
 
@@ -25,7 +27,7 @@
25
27
 
26
28
  `jsdown [...options] [files...]`
27
29
 
28
- - `[files]` - File(s) to lint (default `**/!(*.spec|index).js`)
30
+ - `[files]` - File(s) to lint (default `**/!(index).js`)
29
31
 
30
32
  ### Usage
31
33
 
@@ -35,7 +37,7 @@ jsdown
35
37
 
36
38
  ```sh
37
39
  # generate documentation (matching a different file(s))
38
- lint-es '**/!(*.spec|index).cjs'
40
+ jsdown '**/!(*.spec|index).cjs'
39
41
  ```
40
42
 
41
43
  *Note: In Linux/OSX, matcher patterns must be delimited in quotes.*
package/bin/jsdown.js CHANGED
@@ -1,19 +1,23 @@
1
1
  #!/usr/bin/env node
2
2
  import { createDocs } from '../src/index.js'
3
3
  import { Command } from 'commander'
4
+ import { Package } from '@vanillaes/esmtk'
4
5
 
5
- import { createRequire } from 'node:module'
6
- const require = createRequire(import.meta.url)
7
- const pkg = require('../package.json')
8
-
6
+ const pkg = new Package()
9
7
  const program = new Command()
10
8
  .name('jsdown')
11
- .description('Markdown Doc Generator for JSDoc')
12
9
  .version(pkg.version, '-v, --version')
10
+ .usage(`jsdown [...options] [files...]
11
+ If [files...] is omitted, all JavaScript source files (**/*.js)
12
+ in the current working directory are converted, recursively.
13
+
14
+ Certain paths (node_modules/, coverage/, vendor/, *.min.js, *.spec.js,
15
+ hidden files) are automatically ignored.
13
16
 
14
- program
15
- .description('Lint file(s) matching the provided pattern (default *.spec.js)')
16
- .argument('[files]', 'file(s) to lint', '**/!(*.spec|index).js')
17
+ Paths in a project's .gitignore file are also automatically ignored.
18
+ `)
19
+ .description('Markdown Documentation Generator for JSDoc')
20
+ .argument('[files]', 'file(s) to document', '**/!(index).js')
17
21
  .action((files, options) => {
18
22
  createDocs(files, options)
19
23
  })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vanillaes/jsdown",
3
- "version": "0.1.1",
4
- "description": "Markdown Doc Generator for JSDoc",
3
+ "version": "0.1.3",
4
+ "description": "Markdown Documentation Generator for JSDoc",
5
5
  "keywords": [
6
6
  "ecmascript",
7
7
  "esm",
@@ -22,9 +22,9 @@
22
22
  ".": "./src/index.js"
23
23
  },
24
24
  "scripts": {
25
+ "jsdown": "node ./bin/jsdown.js",
25
26
  "test": "esmtk test",
26
27
  "lint": "esmtk lint",
27
- "type": "esmtk type",
28
28
  "typings": "esmtk typings",
29
29
  "clean": "esmtk clean --typings",
30
30
  "preview": "esmtk preview",
@@ -32,7 +32,7 @@
32
32
  "postversion": "git push --follow-tags"
33
33
  },
34
34
  "dependencies": {
35
- "@vanillaes/esmtk": "^1.8.0",
35
+ "@vanillaes/esmtk": "^2.0.0",
36
36
  "commander": "^14.0.3",
37
37
  "doctrine": "^3.0.0",
38
38
  "lodash-es": "^4.18.1"
package/src/jsdown.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { docdown } from './index.js'
2
- import { fileExists, match } from '@vanillaes/esmtk'
2
+ import { exists, readGitIgnore, match } from '@vanillaes/esmtk'
3
3
  import { mkdir, writeFile } from 'node:fs/promises'
4
4
  import { basename, dirname, join } from 'node:path'
5
5
 
@@ -9,7 +9,13 @@ import { basename, dirname, join } from 'node:path'
9
9
  * @param {object} options 'jsdown' options
10
10
  */
11
11
  export async function createDocs (files, options = {}) {
12
- const sources = await match(files)
12
+ const defaultIgnores = ['node_modules/', 'coverage/', 'vendor/', '**/*.spec.js', '**/*.min.js', '.*']
13
+ const gitIgnores = await readGitIgnore(process.cwd())
14
+ let ignores = [...defaultIgnores, ...gitIgnores]
15
+ // de-duplicate
16
+ ignores = [...new Set(ignores)]
17
+ const ignore = ignores.join(',')
18
+ const sources = await match(files, process.cwd(), ignore)
13
19
  sources.forEach(file => createDoc(file))
14
20
  }
15
21
 
@@ -28,8 +34,8 @@ async function createDoc (path) {
28
34
  const srcPath = join(process.cwd(), 'src') // TODO: make this configurable?
29
35
  const docPath = join(process.cwd(), 'docs') // TODO: make this configurable?
30
36
 
31
- const exists = await !fileExists(docPath)
32
- if (!exists) {
37
+ const dirExists = await exists(docPath)
38
+ if (!dirExists) {
33
39
  await mkdir(docPath, { recursive: true })
34
40
  }
35
41