Skip to content

dox does not support async function from ES2017 #198

@hasezoey

Description

@hasezoey

i have noticed that dox does not support async functions, examples:

when used as a static function:

/**
 * test1
 */
Class.test = async function() {
  // test
}

it is recognized as a property instead of method:

{
  tags: [],
  description: { full: 'test1', summary: 'test1', body: '' },
  isPrivate: false,
  isConstructor: false,
  isClass: false,
  isEvent: false,
  ignore: false,
  line: 4670,
  codeStart: 4673,
  code: 'Class.test = async function() {\n  // test\n}',
  ctx: {
    type: 'property',
    name: 'test',
    value: 'async function() {',
    string: 'Class.test',
    constructor: 'Class'
  }
}

and when used as a normal function:

/**
 * test2
 */
async function test2() {
  // test
}

it does not have a ctx:

{
  tags: [],
  description: { full: 'test2', summary: 'test2', body: '' },
  isPrivate: false,
  isConstructor: false,
  isClass: false,
  isEvent: false,
  ignore: false,
  line: 4684,
  codeStart: 4687,
  code: 'async function test2() {\n' +
    '  // test\n' +
    '}\n' +
    '\n' +
    'if (util.inspect.custom) {\n' +
    '  // Avoid Node deprecation warning DEP0079\n' +
    '  Model[util.inspect.custom] = Model.inspect;\n' +
    '}',
  ctx: false
}
the functions without async for comparison

when used as a static function:

/**
 * test1
 */
Class.test = function() {
  // test
}

is recognized as a method properly:

{
  tags: [],
  description: { full: 'test1', summary: 'test1', body: '' },
  isPrivate: false,
  isConstructor: false,
  isClass: false,
  isEvent: false,
  ignore: false,
  line: 4670,
  codeStart: 4673,
  code: 'Class.test = function() {\n  // test\n}',
  ctx: {
    type: 'method',
    name: 'test',
    string: 'Class.test()',
    constructor: 'Class'
  }
}

and when used as a normal function:

/**
 * test2
 */
function test2() {
  // test
}

it properly has a ctx:

{
  tags: [],
  description: { full: 'test2', summary: 'test2', body: '' },
  isPrivate: false,
  isConstructor: false,
  isClass: false,
  isEvent: false,
  ignore: false,
  line: 4677,
  codeStart: 4680,
  code: 'function test2() {\n  // test\n}',
  ctx: { type: 'function', name: 'test2', string: 'test2()' }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions