@vanillaes/jsdown 0.1.2 → 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 +1 -1
- package/bin/jsdown.js +11 -5
- package/package.json +2 -2
- package/src/jsdown.js +8 -4
package/README.md
CHANGED
package/bin/jsdown.js
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createDocs } from '../src/index.js'
|
|
3
3
|
import { Command } from 'commander'
|
|
4
|
-
import {
|
|
4
|
+
import { Package } from '@vanillaes/esmtk'
|
|
5
5
|
|
|
6
|
-
const pkg =
|
|
6
|
+
const pkg = new Package()
|
|
7
7
|
const program = new Command()
|
|
8
8
|
.name('jsdown')
|
|
9
|
-
.description('Markdown Doc Generator for JSDoc')
|
|
10
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.
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
Certain paths (node_modules/, coverage/, vendor/, *.min.js, *.spec.js,
|
|
15
|
+
hidden files) are automatically ignored.
|
|
16
|
+
|
|
17
|
+
Paths in a project's .gitignore file are also automatically ignored.
|
|
18
|
+
`)
|
|
19
|
+
.description('Markdown Documentation Generator for JSDoc')
|
|
14
20
|
.argument('[files]', 'file(s) to document', '**/!(index).js')
|
|
15
21
|
.action((files, options) => {
|
|
16
22
|
createDocs(files, options)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vanillaes/jsdown",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Markdown Documentation Generator for JSDoc",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecmascript",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"postversion": "git push --follow-tags"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@vanillaes/esmtk": "^
|
|
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 {
|
|
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
|
|
|
@@ -10,7 +10,11 @@ import { basename, dirname, join } from 'node:path'
|
|
|
10
10
|
*/
|
|
11
11
|
export async function createDocs (files, options = {}) {
|
|
12
12
|
const defaultIgnores = ['node_modules/', 'coverage/', 'vendor/', '**/*.spec.js', '**/*.min.js', '.*']
|
|
13
|
-
const
|
|
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(',')
|
|
14
18
|
const sources = await match(files, process.cwd(), ignore)
|
|
15
19
|
sources.forEach(file => createDoc(file))
|
|
16
20
|
}
|
|
@@ -30,8 +34,8 @@ async function createDoc (path) {
|
|
|
30
34
|
const srcPath = join(process.cwd(), 'src') // TODO: make this configurable?
|
|
31
35
|
const docPath = join(process.cwd(), 'docs') // TODO: make this configurable?
|
|
32
36
|
|
|
33
|
-
const
|
|
34
|
-
if (!
|
|
37
|
+
const dirExists = await exists(docPath)
|
|
38
|
+
if (!dirExists) {
|
|
35
39
|
await mkdir(docPath, { recursive: true })
|
|
36
40
|
}
|
|
37
41
|
|