How to use the doctrine.Syntax function in doctrine

To help you get started, we’ve selected a few doctrine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dignifiedquire / clean-documentation-theme / test / utils.spec.js View on Github external
/* eslint-env mocha */
'use strict'

const Syntax = require('doctrine').Syntax
const expect = require('chai').expect
const remark = require('remark')

const Utils = require('../lib/utils')

describe('utils', () => {
  const u = new Utils({hljs: {highlightAuto: false}}, [])

  describe('md', () => {
    it('renders remark asts', () => {
      expect(
        u.md(
          remark().parse(
            'Converts from `Result` to `?Error`'
          )
        )
github angelozerr / tern.java / core / ternjs / node_modules / tern-closure / lib / comment.js View on Github external
var t =
            this.getExpressionAval(typeManager, subExpr, reason, innerType);
        if (t) {
          types.push(t);
        }
      }, this);
      return typeManager.getUnionType(types);
    case doctrine.Syntax.RestType:
      // TODO: Expose varargs #20.
      return this.getExpressionAval(
          typeManager, typeExpr.expression, reason, innerType);
    case doctrine.Syntax.RecordType:
    case doctrine.Syntax.FieldType:
      // TODO: Handle records #15.
      return null;
    case doctrine.Syntax.FunctionType:
      // TODO: Handle functions #16.
      return null;
    case doctrine.Syntax.TypeApplication:
      // TODO: Handle more exotic type applications?
      // We support type applications for array and object values. In those
      // cases, only the last applied type (the value type) is meaningful.
      return this.getExpressionAval(typeManager, typeExpr.expression, reason,
          this.getExpressionAval(typeManager,
              typeExpr.applications[typeExpr.applications.length - 1],
              reason, innerType));
    case doctrine.Syntax.NullLiteral:
    case doctrine.Syntax.UndefinedLiteral:
    case doctrine.Syntax.NullableLiteral:
    case doctrine.Syntax.AllLiteral:
    case doctrine.Syntax.VoidLiteral:
      // No type to apply.
github angelozerr / tern.java / core / tern.core / node_modules / tern / node_modules / tern-closure / lib / comment.js View on Github external
var t =
            this.getExpressionAval(typeManager, subExpr, reason, innerType);
        if (t) {
          types.push(t);
        }
      }, this);
      return typeManager.getUnionType(types);
    case doctrine.Syntax.RestType:
      // TODO: Expose varargs #20.
      return this.getExpressionAval(
          typeManager, typeExpr.expression, reason, innerType);
    case doctrine.Syntax.RecordType:
    case doctrine.Syntax.FieldType:
      // TODO: Handle records #15.
      return null;
    case doctrine.Syntax.FunctionType:
      // TODO: Handle functions #16.
      return null;
    case doctrine.Syntax.TypeApplication:
      // TODO: Handle more exotic type applications?
      // We support type applications for array and object values. In those
      // cases, only the last applied type (the value type) is meaningful.
      return this.getExpressionAval(typeManager, typeExpr.expression, reason,
          this.getExpressionAval(typeManager,
              typeExpr.applications[typeExpr.applications.length - 1],
              reason, innerType));
    case doctrine.Syntax.NullLiteral:
    case doctrine.Syntax.UndefinedLiteral:
    case doctrine.Syntax.NullableLiteral:
    case doctrine.Syntax.AllLiteral:
    case doctrine.Syntax.VoidLiteral:
      // No type to apply.
github mapbox / mapbox-gl-js / docs / _theme / lib / format_parameters.js View on Github external
'use strict';

var formatMarkdown = require('./format_markdown');
var Syntax = require('doctrine').Syntax;

/**
 * Format a parameter name. This is used in formatParameters
 * and just needs to be careful about differentiating optional
 * parameters
 *
 * @param {Object} param a param as a type spec
 * @returns {string} formatted parameter representation.
 */
function formatParameter(param, short) {
  if (short) {
    return param.type.type == Syntax.OptionalType ? '[' + param.name + ']' : param.name;
  } else {
    return param.name + ': ' + formatMarkdown.type(param.type).replace(/\n/g, '');
  }
}
github Aratramba / pug-doc / lib / arguments.js View on Github external
var doctrine = require("doctrine");
var doctrineSyntax = doctrine.Syntax;
var codeBlock = require("indented-code-block");

var TYPE_MAPPING = {};
TYPE_MAPPING[doctrineSyntax.RecordType] = "Object";

var NAME_REGEX = /(\s|\[|^)(\w+((-+|\.)\w+)*)($|\s+?|\-|=|\]).*$/;

/**
 * Get JSDoc type
 */

function getJSDocType(tag) {
  var type = tag.type;

  if (type) {
    if (type.elements) {
github documentationjs / documentation / default-theme / lib / format_parameters.js View on Github external
'use strict';

var formatMarkdown = require('./format_markdown');
var Syntax = require('doctrine').Syntax;

/**
 * Format a parameter name. This is used in formatParameters
 * and just needs to be careful about differentiating optional
 * parameters
 *
 * @param {Object} param a param as a type spec
 * @returns {string} formatted parameter representation.
 */
function formatParameter(param, short) {
  if (short) {
    return param.type.type == Syntax.OptionalType ? '[' + param.name + ']' : param.name;
  } else {
    return param.name + ': ' + formatMarkdown.type(param.type).replace(/\n/g, '');
  }
}