Skip to content

fix(generate): show help output when no arguments or config are provided#853

Open
bmuenzenmeyer wants to merge 3 commits into
mainfrom
generate-help
Open

fix(generate): show help output when no arguments or config are provided#853
bmuenzenmeyer wants to merge 3 commits into
mainfrom
generate-help

Conversation

@bmuenzenmeyer

@bmuenzenmeyer bmuenzenmeyer commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Description

When using doc-kit, i tried npx doc-kit generate only to get the reported error. We can do better.

Made with assistance by Claude Code Sonnet - verified manually.

We don't have any test coverage of this file, which I retained that pattern.

Validation

Before

npm run run generate

> @node-core/doc-kit@1.3.10 run
> node bin/cli.mjs generate

[14:02:51.573] ERROR: Cannot read properties of undefined (reading 'join')
TypeError: Cannot read properties of undefined (reading 'join')
    at runGenerators (file:///Users/brian/Documents/doc-kit/src/generators.mjs:99:30)
    at file:///Users/brian/Documents/doc-kit/bin/commands/generate.mjs:65:13
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
    at async Command.<anonymous> (file:///Users/brian/Documents/doc-kit/bin/u

After

npm run run generate   

> @node-core/doc-kit@1.3.10 run
> node bin/cli.mjs generate

Usage: @node-core/doc-kit generate [options]

Generate API docs

Options:
  --config-file <path>         Config file
  -i, --input <patterns...>    Input file patterns (glob)
  -t, --target <generator...>  Target generator(s) (choices: "json-simple", "legacy-html", "legacy-html-all", "man-page",
                               "legacy-json", "legacy-json-all", "addon-verify", "api-links", "orama-db", "llms-txt",
                               "sitemap", "web")
  --ignore <patterns...>       Ignore file patterns (glob)
  -o, --output <directory>     The output directory
  -p, --threads <number>       Number of threads to use (minimum: 1)
  --chunk-size <number>        Number of items to process per worker thread (minimum: 1)
  -v, --version <semver>       Target Node.js version
  -c, --changelog <url>        Changelog URL or path
  --git-ref                    Git ref URL
  --index <url>                index.md URL or path
  --minify                     Minify?
  --type-map <url>             Type map URL or path
  -h, --help                   display help for command

Related Issues

closes #852

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run node --run test and all tests passed.
  • I have check code formatting with node --run format & node --run lint.
  • I've covered new added functionality with unit tests if necessary.

@bmuenzenmeyer bmuenzenmeyer requested a review from a team as a code owner June 24, 2026 14:01
@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api-docs-tooling Ready Ready Preview Jun 24, 2026 7:16pm

Request Review

@cursor

cursor Bot commented Jun 24, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Small CLI validation and docs change with tests; no generator or config merge behavior is altered once valid options are provided.

Overview
Running doc-kit generate with no --target and no --config-file used to fail deep in runGenerators with a confusing undefined .join error. The generate command now calls assertRunnableOptions up front so that case fails immediately with a clear message directing users to doc-kit generate --help.

The README generate section documents that one of those options is required. Unit tests cover the new guard for missing options, --target, and --config-file.

Reviewed by Cursor Bugbot for commit 40d5928. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.36585% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.80%. Comparing base (b5cf0a0) to head (40d5928).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
bin/commands/generate.mjs 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #853      +/-   ##
==========================================
+ Coverage   84.60%   84.80%   +0.19%     
==========================================
  Files         176      177       +1     
  Lines       15858    16214     +356     
  Branches     1411     1467      +56     
==========================================
+ Hits        13417    13750     +333     
- Misses       2431     2454      +23     
  Partials       10       10              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

web Generator

File Base Head Diff
addons.js 305.26 KB 305.26 KB +7.00 B (+0.00%)
assert.js 448.95 KB 448.95 KB +7.00 B (+0.00%)
async_context.js 213.43 KB 213.43 KB +7.00 B (+0.00%)
async_hooks.js 191.51 KB 191.52 KB +7.00 B (+0.00%)
buffer.js 1.08 MB 1.08 MB +7.00 B (+0.00%)
child_process.js 455.00 KB 455.01 KB +7.00 B (+0.00%)
cli.js 314.94 KB 314.95 KB +7.00 B (+0.00%)
cluster.js 188.56 KB 188.57 KB +7.00 B (+0.00%)
console.js 99.13 KB 99.14 KB +7.00 B (+0.01%)
crypto.js 1.22 MB 1.22 MB +7.00 B (+0.00%)
debugger.js 88.91 KB 88.91 KB +7.00 B (+0.01%)
deprecations.js 294.99 KB 295.00 KB +7.00 B (+0.00%)
dgram.js 179.27 KB 179.28 KB +7.00 B (+0.00%)
diagnostics_channel.js 303.25 KB 303.26 KB +7.00 B (+0.00%)
dns.js 261.77 KB 261.77 KB +7.00 B (+0.00%)
documentation.js 4.84 KB 4.85 KB +7.00 B (+0.14%)
domain.js 85.64 KB 85.65 KB +7.00 B (+0.01%)
dtls.js 82.81 KB 82.82 KB +7.00 B (+0.01%)
embedding.js 33.39 KB 33.40 KB +7.00 B (+0.02%)
environment_variables.js 11.70 KB 11.70 KB +7.00 B (+0.06%)
errors.js 362.34 KB 362.35 KB +7.00 B (+0.00%)
esm.js 131.90 KB 131.91 KB +7.00 B (+0.01%)
events.js 539.11 KB 539.12 KB +7.00 B (+0.00%)
ffi.js 97.13 KB 97.14 KB +7.00 B (+0.01%)
fs.js 1.27 MB 1.27 MB +7.00 B (+0.00%)
globals.js 122.78 KB 122.79 KB +7.00 B (+0.01%)
http.js 687.23 KB 687.24 KB +7.00 B (+0.00%)
http2.js 803.03 KB 803.04 KB +7.00 B (+0.00%)
https.js 155.41 KB 155.42 KB +7.00 B (+0.00%)
inspector.js 114.89 KB 114.90 KB +7.00 B (+0.01%)
intl.js 32.41 KB 32.42 KB +7.00 B (+0.02%)
module.js 331.70 KB 331.70 KB +7.00 B (+0.00%)
modules.js 146.23 KB 146.24 KB +7.00 B (+0.00%)
n-api.js 711.14 KB 711.15 KB +7.00 B (+0.00%)
net.js 294.67 KB 294.68 KB +7.00 B (+0.00%)
os.js 103.20 KB 103.21 KB +7.00 B (+0.01%)
packages.js 145.83 KB 145.84 KB +7.00 B (+0.00%)
path.js 91.92 KB 91.92 KB +7.00 B (+0.01%)
perf_hooks.js 353.78 KB 353.79 KB +7.00 B (+0.00%)
permissions.js 34.79 KB 34.79 KB +7.00 B (+0.02%)
process.js 695.92 KB 695.92 KB +7.00 B (+0.00%)
punycode.js 23.41 KB 23.42 KB +7.00 B (+0.03%)
querystring.js 26.14 KB 26.14 KB +7.00 B (+0.03%)
quic.js 442.59 KB 442.59 KB +7.00 B (+0.00%)
readline.js 217.31 KB 217.32 KB +7.00 B (+0.00%)
repl.js 205.07 KB 205.08 KB +7.00 B (+0.00%)
report.js 184.70 KB 184.71 KB +7.00 B (+0.00%)
single-executable-applications.js 80.17 KB 80.18 KB +7.00 B (+0.01%)
sqlite.js 254.82 KB 254.82 KB +7.00 B (+0.00%)
stream.js 854.40 KB 854.40 KB +7.00 B (+0.00%)
stream_iter.js 456.16 KB 456.16 KB +7.00 B (+0.00%)
string_decoder.js 26.63 KB 26.63 KB +7.00 B (+0.03%)
synopsis.js 11.39 KB 11.40 KB +7.00 B (+0.06%)
test.js 921.62 KB 921.63 KB +7.00 B (+0.00%)
timers.js 93.30 KB 93.30 KB +7.00 B (+0.01%)
tls.js 312.25 KB 312.25 KB +7.00 B (+0.00%)
tracing.js 72.75 KB 72.75 KB +7.00 B (+0.01%)
tty.js 43.05 KB 43.05 KB +7.00 B (+0.02%)
typescript.js 21.57 KB 21.57 KB +7.00 B (+0.03%)
url.js 331.00 KB 331.00 KB +7.00 B (+0.00%)
util.js 745.90 KB 745.90 KB +7.00 B (+0.00%)
v8.js 345.20 KB 345.21 KB +7.00 B (+0.00%)
vfs.js 43.09 KB 43.09 KB +7.00 B (+0.02%)
vm.js 432.13 KB 432.14 KB +7.00 B (+0.00%)
wasi.js 37.79 KB 37.79 KB +7.00 B (+0.02%)
webcrypto.js 423.06 KB 423.06 KB +7.00 B (+0.00%)
webstreams.js 280.37 KB 280.37 KB +7.00 B (+0.00%)
worker_threads.js 394.12 KB 394.13 KB +7.00 B (+0.00%)
zlib.js 359.52 KB 359.53 KB +7.00 B (+0.00%)

Comment thread bin/commands/generate.mjs Outdated
Comment on lines +64 to +68
// Running `generate` with no arguments or config has nothing to do, so
// show the help output instead of failing later with an opaque error.
if (Object.keys(opts).length === 0) {
command.help();
}

@avivkeller avivkeller Jun 24, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we just make certain arguments required instead?

i.e., --target OR --config-file MUST be provided.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved via 1ef7ca1

@bmuenzenmeyer bmuenzenmeyer requested a review from avivkeller June 24, 2026 18:46

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1ef7ca1. Configure here.

Comment thread src/utils/configuration/index.mjs
Comment thread bin/commands/generate.mjs
Comment on lines +67 to 69
assertRunnableOptions(opts);

const config = await setConfig(opts);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

swap these statements and call assertRunnableOptions on the config, checking that target and input is passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Running doc-kit generate with no arguments or config should generate help

2 participants