Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dox to latest version and fix some documentation issues #12024

Merged
merged 46 commits into from Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
46073dd
chore: add yarn.lock to ignore
hasezoey Jun 30, 2022
f0fa4b5
chore: upgrade "dox" to "0.4.4"
hasezoey Jun 30, 2022
a889e3a
chore: upgrade "dox" to "0.4.5"
hasezoey Jun 30, 2022
5de8b9a
chore(docs/source/api.js): add log of file when "parseComments" errors
hasezoey Jun 30, 2022
aa297ba
style: fix empty "returns" jsdoc for "syncIndexes"
hasezoey Jun 30, 2022
b4c26a4
style: fix empty "returns" jsdoc for "buildBulkWriteOperations"
hasezoey Jun 30, 2022
c42bdba
chore: upgrade "dox" to "0.5.3"
hasezoey Jun 30, 2022
dce32d5
style: properly define Document Arrays in jsdoc
hasezoey Jun 30, 2022
7155089
style: remove function definition from "VirtualType.get" and "Virtual…
hasezoey Jun 30, 2022
c22e7cf
style: add jsdoc tags "memberOf" and "instance" to "Mongoose.prototyp…
hasezoey Jun 30, 2022
97b47c3
style: add jsdoc tag "memberOf" to "Model.prototype.increment"
hasezoey Jun 30, 2022
a6c9834
style: add jsdoc tag "memberOf" to "QueryCursor.prototype.map"
hasezoey Jun 30, 2022
0354bb5
style: change jsdoc tag "memberOf" to point to the correct member for…
hasezoey Jun 30, 2022
48beee1
style: add jsdoc tag "memberOf" to "AggregationCursor.prototype.map"
hasezoey Jun 30, 2022
7646125
style: properly set jsdoc tag "function" for "SchemaType.prototype.ca…
hasezoey Jun 30, 2022
82a8c03
style: remove and add some jsdoc tags for "SchemaType.prototype.castF…
hasezoey Jun 30, 2022
cb8e66a
style: move jsdoc comment to proper function ("DocumentArrayPath.set")
hasezoey Jun 30, 2022
953853f
style: replace all "@param {*}" with "@param {Any}" to match other cases
hasezoey Jun 30, 2022
e57594c
style: remove "- " before description to be more consistent
hasezoey Jun 30, 2022
1719bf6
style: remove extra parameters from "@static"
hasezoey Jun 30, 2022
590f0ff
style: move jsdoc comment to proper function ("SubdocumentPath.set")
hasezoey Jun 30, 2022
dbc078b
chore: upgrade "dox" to "0.8.1"
hasezoey Jun 30, 2022
728d967
chore: upgrade "dox" to "0.9.1"
hasezoey Jun 30, 2022
96e1ffd
chore(docs/source/api): change to use "isFunction" instead of directl…
hasezoey Jun 30, 2022
cfe7248
chore(docs/source/api): use "ctx.constructor" over "data.name" for "f…
hasezoey Jun 30, 2022
39a02a1
chore(docs/source/api): remove console.log of the "ctx"
hasezoey Jun 30, 2022
bb0bf63
Merge branch 'master' into updateDox
Uzlopak Jul 2, 2022
407fe61
style: update "syncIndexes" jsdoc to only have "Promise" as return ty…
hasezoey Jul 2, 2022
831d170
Merge branch 'master' into updateDox
hasezoey Jul 3, 2022
1384f27
chore(docs/source/api): basic handle jsdoc "@instance" tag
hasezoey Jul 3, 2022
a006214
chore(docs/source/api): rename "ctx.static" to "ctx.isStatic"
hasezoey Jul 3, 2022
17c7e63
chore(docs/source/api): move setting of "ctx.string" to after the tag…
hasezoey Jul 3, 2022
73f3400
style: update jsdoc "memberOf" for "MongooseMap.prototype.$isMongoose…
hasezoey Jul 3, 2022
6c0e316
style: set proper jsdoc "memberOf" path for "MongooseBuffer.mixin.*" …
hasezoey Jul 3, 2022
da57bf2
chore(docs/source/api): remove redundant setting of "isFunction" in "…
hasezoey Jul 3, 2022
9f73623
chore(docs/source/api): add more comments explaining what some things do
hasezoey Jul 3, 2022
fcb2bfc
chore(docs/source/api): add "void" to types in return, so it does not…
hasezoey Jul 3, 2022
cf6ad88
chore(docs/source/api): add some jsdoc-typescript types to help remem…
hasezoey Jul 3, 2022
ec947f6
chore(docs/source/api): add handling for "@deprecated" and property
hasezoey Jul 3, 2022
5d80579
style: properly escape "@type" type parameters
hasezoey Jul 4, 2022
906cb4f
style: fix missing next line in jsdoc for "Aggregate.prototype.lookup"
hasezoey Jul 4, 2022
e6776b3
chore(docs/source/api): re-add "null" to types when nullable
hasezoey Jul 4, 2022
a1eade6
style: update "Query.prototype.box" jsdoc to use proper "@param" tags
hasezoey Jul 4, 2022
4c7e85c
chore(docs/source/api): change "return" to overwrite "description" in…
hasezoey Jul 4, 2022
6a10d4f
style: add ":" to all jsdoc headers where missing
hasezoey Jul 4, 2022
1cc2293
Merge branch 'master' into updateDox
vkarpov15 Jul 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Expand Up @@ -48,4 +48,7 @@ docs/*.html
docs/tutorials/*.html
docs/typescript/*.html
docs/api/*.html
index.html
index.html

# yarn package-lock
yarn.lock
40 changes: 28 additions & 12 deletions docs/source/api.js
Expand Up @@ -47,9 +47,15 @@ const out = module.exports.docs;

const combinedFiles = [];
for (const file of files) {
const comments = dox.parseComments(fs.readFileSync(`./${file}`, 'utf8'), { raw: true });
comments.file = file;
combinedFiles.push(comments);
try {
const comments = dox.parseComments(fs.readFileSync(`./${file}`, 'utf8'), { raw: true });
comments.file = file;
combinedFiles.push(comments);
} catch (err) {
// show log of which file has thrown a error for easier debugging
console.error("Error while trying to parseComments for ", file);
throw err;
}
}

parse();
Expand Down Expand Up @@ -94,7 +100,10 @@ function parse() {
break;
case 'property':
ctx.type = 'property';

// somewhere since 6.0 the "string" property came back, which was gone with 4.5
let str = tag.string;

const match = str.match(/^{\w+}/);
if (match != null) {
ctx.type = match[0].substring(1, match[0].length - 1);
Expand All @@ -109,14 +118,18 @@ function parse() {
case 'static':
ctx.type = 'property';
ctx.static = true;
ctx.name = tag.string;
ctx.string = `${data.name}.${ctx.name}`;
// dont take "string" as "name" from here, because jsdoc definitions of "static" do not have parameters, also its defined elsewhere anyway
// ctx.name = tag.string;
ctx.string = `${ctx.constructor}.${ctx.name}`;
break;
case 'function':
ctx.type = 'function';
ctx.static = true;
ctx.name = tag.string;
ctx.string = `${data.name}.${ctx.name}()`;
ctx.string = `${ctx.constructor}.${ctx.name}`;
// extra parameter to make function definitions independant of where "@function" is defined
// like "@static" could have overwritten "ctx.string" again if defined after "@function"
ctx.isFunction = true;
break;
case 'return':
tag.return = tag.description ?
Expand Down Expand Up @@ -144,21 +157,27 @@ function parse() {
case 'method':
ctx.type = 'method';
ctx.name = tag.string;
ctx.string = `${ctx.constructor}.prototype.${ctx.name}()`;
ctx.string = `${ctx.constructor}.prototype.${ctx.name}`;
ctx.isFunction = true;
break;
case 'memberOf':
ctx.constructor = tag.parent;
ctx.string = `${ctx.constructor}.prototype.${ctx.name}`;
if (ctx.type === 'method') {
ctx.string += '()';
ctx.isFunction = true;
}
break;
case 'constructor':
ctx.string = tag.string + '()';
ctx.string = tag.string;
ctx.name = tag.string;
ctx.isFunction = true;
}
}

if (ctx.isFunction && !ctx.string.endsWith("()")) {
ctx.string = ctx.string + "()";
}

if (/\.prototype[^.]/.test(ctx.string)) {
ctx.string = `${ctx.constructor}.prototype.${ctx.name}`;
}
hasezoey marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -175,9 +194,6 @@ function parse() {
ctx.description = prop.description.full.
replace(/<br \/>/ig, ' ').
replace(/&gt;/ig, '>');
if (ctx.description.includes('function capitalize')) {
console.log('\n\n-------\n\n', ctx);
}
ctx.description = md.parse(ctx.description);

data.props.push(ctx);
Expand Down
2 changes: 1 addition & 1 deletion lib/connection.js
Expand Up @@ -1452,7 +1452,7 @@ Connection.prototype.setClient = function setClient(client) {
*
* @param {Object} options
* @param {Boolean} options.continueOnError `false` by default. If set to `true`, mongoose will not throw an error if one model syncing failed, and will return an object where the keys are the names of the models, and the values are the results/errors for each model.
* @returns
* @return {Promise|undefined} Returns `undefined` if callback is specified, returns a promise if no callback, when the Promise resolves the value is a list of the dropped indexes.
Uzlopak marked this conversation as resolved.
Show resolved Hide resolved
*/
Connection.prototype.syncIndexes = async function syncIndexes(options = {}) {
const result = {};
Expand Down
1 change: 1 addition & 0 deletions lib/cursor/AggregationCursor.js
Expand Up @@ -132,6 +132,7 @@ if (Symbol.asyncIterator != null) {
*
* @param {Function} fn
* @return {AggregationCursor}
* @memberOf AggregationCursor
* @api public
* @method map
*/
Expand Down
3 changes: 2 additions & 1 deletion lib/cursor/QueryCursor.js
Expand Up @@ -137,6 +137,7 @@ QueryCursor.prototype._read = function() {
*
* @param {Function} fn
* @return {QueryCursor}
* @memberOf QueryCursor
* @api public
* @method map
*/
Expand Down Expand Up @@ -320,7 +321,7 @@ QueryCursor.prototype._transformForAsyncIterator = function() {
* support async iterators.
*
* @method Symbol.asyncIterator
* @memberOf Query
* @memberOf QueryCursor
* @instance
* @api public
*/
Expand Down
24 changes: 12 additions & 12 deletions lib/error/index.js
Expand Up @@ -56,7 +56,7 @@ module.exports = exports = MongooseError;
* @see Error.messages #error_messages_MongooseError-messages
* @api public
* @memberOf Error
* @static messages
* @static
*/

MongooseError.messages = require('./messages');
Expand All @@ -73,7 +73,7 @@ MongooseError.Messages = MongooseError.messages;
*
* @api public
* @memberOf Error
* @static DocumentNotFoundError
* @static
Uzlopak marked this conversation as resolved.
Show resolved Hide resolved
*/

MongooseError.DocumentNotFoundError = require('./notFound');
Expand All @@ -84,7 +84,7 @@ MongooseError.DocumentNotFoundError = require('./notFound');
*
* @api public
* @memberOf Error
* @static CastError
* @static
*/

MongooseError.CastError = require('./cast');
Expand All @@ -96,7 +96,7 @@ MongooseError.CastError = require('./cast');
*
* @api public
* @memberOf Error
* @static ValidationError
* @static
*/

MongooseError.ValidationError = require('./validation');
Expand Down Expand Up @@ -131,7 +131,7 @@ MongooseError.ValidationError = require('./validation');
*
* @api public
* @memberOf Error
* @static ValidatorError
* @static
*/

MongooseError.ValidatorError = require('./validator');
Expand All @@ -143,7 +143,7 @@ MongooseError.ValidatorError = require('./validator');
*
* @api public
* @memberOf Error
* @static VersionError
* @static
*/

MongooseError.VersionError = require('./version');
Expand All @@ -155,7 +155,7 @@ MongooseError.VersionError = require('./version');
*
* @api public
* @memberOf Error
* @static ParallelSaveError
* @static
*/

MongooseError.ParallelSaveError = require('./parallelSave');
Expand All @@ -166,7 +166,7 @@ MongooseError.ParallelSaveError = require('./parallelSave');
*
* @api public
* @memberOf Error
* @static OverwriteModelError
* @static
*/

MongooseError.OverwriteModelError = require('./overwriteModel');
Expand All @@ -176,7 +176,7 @@ MongooseError.OverwriteModelError = require('./overwriteModel');
*
* @api public
* @memberOf Error
* @static MissingSchemaError
* @static
*/

MongooseError.MissingSchemaError = require('./missingSchema');
Expand All @@ -187,7 +187,7 @@ MongooseError.MissingSchemaError = require('./missingSchema');
*
* @api public
* @memberOf Error
* @static MongooseServerSelectionError
* @static
*/

MongooseError.MongooseServerSelectionError = require('./serverSelection');
Expand All @@ -198,7 +198,7 @@ MongooseError.MongooseServerSelectionError = require('./serverSelection');
*
* @api public
* @memberOf Error
* @static DivergentArrayError
* @static
*/

MongooseError.DivergentArrayError = require('./divergentArray');
Expand All @@ -210,7 +210,7 @@ MongooseError.DivergentArrayError = require('./divergentArray');
*
* @api public
* @memberOf Error
* @static StrictModeError
* @static
*/

MongooseError.StrictModeError = require('./strict');
2 changes: 1 addition & 1 deletion lib/error/messages.js
Expand Up @@ -16,7 +16,7 @@
*
* Click the "show code" link below to see all defaults.
*
* @static messages
* @static
* @receiver MongooseError
* @api public
*/
Expand Down
8 changes: 4 additions & 4 deletions lib/helpers/query/castUpdate.js
Expand Up @@ -155,12 +155,12 @@ function castPipelineOperator(op, val) {
* according to its schema.
*
* @param {Schema} schema
* @param {Object} obj - part of a query
* @param {String} op - the atomic operator ($pull, $set, etc)
* @param {Object} obj part of a query
* @param {String} op the atomic operator ($pull, $set, etc)
* @param {Object} options
* @param {Boolean|String} [options.strict]
* @param {Query} context
* @param {String} pref - path prefix (internal only)
* @param {String} pref path prefix (internal only)
* @return {Bool} true if this path has keys to update
* @api private
*/
Expand Down Expand Up @@ -451,7 +451,7 @@ const overwriteOps = {
*
* @param {SchemaType} schema
* @param {Object} val
* @param {String} op - the atomic operator ($pull, $set, etc)
* @param {String} op the atomic operator ($pull, $set, etc)
* @param {String} $conditional
* @param {Query} context
* @api private
Expand Down
4 changes: 3 additions & 1 deletion lib/index.js
Expand Up @@ -761,6 +761,8 @@ Mongoose.prototype.Aggregate = Aggregate;
/**
* The Mongoose Collection constructor
*
* @memberOf Mongoose
* @instance
* @method Collection
* @api public
*/
Expand Down Expand Up @@ -1044,7 +1046,7 @@ Mongoose.prototype.isObjectIdOrHexString = function(v) {
*
* @param {Object} options
* @param {Boolean} options.continueOnError `false` by default. If set to `true`, mongoose will not throw an error if one model syncing failed, and will return an object where the keys are the names of the models, and the values are the results/errors for each model.
* @returns
* @return {Promise|undefined} Returns `undefined` if callback is specified, returns a promise if no callback, when the Promise resolves the value is a list of the dropped indexes.
Uzlopak marked this conversation as resolved.
Show resolved Hide resolved
*/
Mongoose.prototype.syncIndexes = function(options) {
const _mongoose = this instanceof Mongoose ? this : mongoose;
Expand Down
11 changes: 6 additions & 5 deletions lib/model.js
Expand Up @@ -212,7 +212,7 @@ Model.prototype.baseModelName;
* @api public
* @fires error whenever any query or model function errors
* @memberOf Model
* @static events
* @static
*/

Model.events;
Expand Down Expand Up @@ -899,6 +899,7 @@ Model.prototype.$__version = function(where, delta) {
* })
*
* @see versionKeys https://mongoosejs.com/docs/guide.html#versionKey
* @memberOf Model
* @api public
*/

Expand Down Expand Up @@ -1453,7 +1454,7 @@ Model.createCollection = function createCollection(options, callback) {
* @param {Object} [options] options to pass to `ensureIndexes()`
* @param {Boolean} [options.background=null] if specified, overrides each index's `background` property
* @param {Function} [callback] optional callback
* @return {Promise|undefined} Returns `undefined` if callback is specified, returns a promise if no callback.
* @return {Promise|undefined} Returns `undefined` if callback is specified, returns a promise if no callback, when the Promise resolves the value is a list of the dropped indexes.
* @api public
*/

Expand Down Expand Up @@ -3613,7 +3614,7 @@ Model.bulkWrite = function(ops, options, callback) {
*
* `bulkSave` uses `bulkWrite` under the hood, so it's mostly useful when dealing with many documents (10K+)
*
* @param {[Document]} documents
* @param {Array<Document>} documents
* @param {Object} [options] options passed to the underlying `bulkWrite()`
* @param {ClientSession} [options.session=null] The session associated with this bulk write. See [transactions docs](/docs/transactions.html).
* @param {String|number} [options.w=1] The [write concern](https://docs.mongodb.com/manual/reference/write-concern/). See [`Query#w()`](/docs/api.html#query_Query-w) for more information.
Expand Down Expand Up @@ -3687,10 +3688,10 @@ function handleSuccessfulWrite(document, resolve, reject) {

/**
*
* @param {[Document]} documents The array of documents to build write operations of
* @param {Array<Document>} documents The array of documents to build write operations of
* @param {Object} options
* @param {Boolean} options.skipValidation defaults to `false`, when set to true, building the write operations will bypass validating the documents.
* @returns
* @return {Array<Promise>} Returns a array of all Promises the function executes to be awaited.
*/
Model.buildBulkWriteOperations = function buildBulkWriteOperations(documents, options) {
if (!Array.isArray(documents)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/query.js
Expand Up @@ -3865,7 +3865,7 @@ function _getOption(query, option, def) {
/*!
* Override mquery.prototype._findAndModify to provide casting etc.
*
* @param {String} type - either "remove" or "update"
* @param {String} type either "remove" or "update"
* @param {Function} callback
* @api private
*/
Expand Down
2 changes: 1 addition & 1 deletion lib/schema.js
Expand Up @@ -1874,7 +1874,7 @@ Schema.prototype.get = function(key) {
* The allowed index types
*
* @receiver Schema
* @static indexTypes
* @static
* @api public
*/

Expand Down
16 changes: 10 additions & 6 deletions lib/schema/SubdocumentPath.js
Expand Up @@ -314,24 +314,28 @@ SubdocumentPath.prototype.discriminator = function(name, schema, options) {
return this.caster.discriminators[name];
};

/*!
* ignore
*/

SubdocumentPath.defaultOptions = {};

/**
* Sets a default option for all SubdocumentPath instances.
*
* #### Example:
*
* // Make all numbers have option `min` equal to 0.
* mongoose.Schema.Embedded.set('required', true);
* mongoose.Schema.SubdocumentPath.set('required', true);
*
* @param {String} option - The option you'd like to set the value for
* @param {*} value - value for option
* @return {undefined}
* @param {String} option The option you'd like to set the value for
* @param {Any} value value for option
* @return {void}
* @function set
* @static
* @api public
*/

SubdocumentPath.defaultOptions = {};

SubdocumentPath.set = SchemaType.set;

/*!
Expand Down