mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
fix: make the --readme flag usable
+ fix(jsdoc): resolve the path to the README file + fix(jsdoc-cli): don't treat --readme as a boolean
This commit is contained in:
parent
495093600d
commit
fa693fdd85
@ -76,7 +76,6 @@ module.exports = {
|
||||
},
|
||||
readme: {
|
||||
alias: 'R',
|
||||
boolean: true,
|
||||
description: 'The `README` file to include in the documentation.',
|
||||
normalize: true,
|
||||
requiresArg: true
|
||||
|
||||
@ -5,21 +5,25 @@ function validate(name, opts) {
|
||||
name = `--${name}`;
|
||||
|
||||
if (!opts.description) {
|
||||
throw new TypeError(`${name} is missing its description.`);
|
||||
throw new TypeError(`${name} is missing its description`);
|
||||
}
|
||||
|
||||
if (opts.array && opts.boolean) {
|
||||
throw new TypeError(`${name} can be an array or a boolean, but not both.`);
|
||||
throw new TypeError(`${name} can be an array or a boolean, but not both`);
|
||||
}
|
||||
|
||||
if (opts.requiresArg && opts.boolean) {
|
||||
throw new TypeError(`${name} can require an argument or be a boolean, but not both`);
|
||||
}
|
||||
|
||||
try {
|
||||
ow(opts.coerce, ow.optional.function);
|
||||
} catch (e) {
|
||||
throw new TypeError(`The coerce value for ${name} is not a function.`);
|
||||
throw new TypeError(`The coerce value for ${name} is not a function`);
|
||||
}
|
||||
|
||||
if (opts.choices && !opts.requiresArg) {
|
||||
throw new TypeError(`${name} specifies choices, but not requiresArg.`);
|
||||
throw new TypeError(`${name} specifies choices, but not requiresArg`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ const { config } = require('@jsdoc/core');
|
||||
const Engine = require('@jsdoc/cli');
|
||||
const env = require('jsdoc/env');
|
||||
const { EventBus, log } = require('@jsdoc/util');
|
||||
const path = require('path');
|
||||
const stripBom = require('strip-bom');
|
||||
const stripJsonComments = require('strip-json-comments');
|
||||
const Promise = require('bluebird');
|
||||
@ -32,7 +33,6 @@ module.exports = (() => {
|
||||
// TODO: docs
|
||||
cli.setVersionInfo = () => {
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// allow this to throw--something is really wrong if we can't read our own package file
|
||||
const info = JSON.parse(stripBom(fs.readFileSync(path.join(env.dirname, 'package.json'),
|
||||
@ -260,6 +260,11 @@ module.exports = (() => {
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve the path to the README.
|
||||
if (env.opts.readme) {
|
||||
env.opts.readme = path.resolve(env.opts.readme);
|
||||
}
|
||||
|
||||
props.packageJson = packageJson;
|
||||
|
||||
return sourceFiles;
|
||||
@ -348,7 +353,6 @@ module.exports = (() => {
|
||||
|
||||
cli.generateDocs = () => {
|
||||
let message;
|
||||
const path = require('path');
|
||||
const taffy = require('taffydb').taffy;
|
||||
|
||||
let template;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user