Detects properties common for each doc-object and adds them
165118
function add_shared(hash, customTags, doc_map) {
    hash = utils.merge(hash, {
      "inheritable" : !!doc_map["inheritable"],
      "inheritdoc" : extract(doc_map, "inheritdoc"),
      "related" : extract(doc_map, "related"),
      "see" : extract(doc_map, "see"),
      "private" : extract(doc_map, "private") !== null ? true : false,
      "experimental" : extract(doc_map, "experimental") !== null ? true : false,
      "ignore" : extract(doc_map, "ignore") !== null ? true : false,
      "author" : extract_plural(doc_map["author"] || []),
      "version" : extract(doc_map, "version"),
      "since" : extract(doc_map, "since"),
      "todo" : extract(doc_map, "todo")
    });

    if (customTags !== undefined) {
      var custom = {};
      _.each(customTags, function(tag) {
        var text = extract(doc_map, tag);
        if (text !== null) {
          custom[tag] = text.doc.length > 0 ? text.doc : true;
        }
      });

      hash = utils.merge(hash, custom);
    }

    return hash;
}
705348
function addJSONProperties(jsonData, propertiesGroups, filePath, currentNamesPath) {

        var i,
            group,
            propertyDefinition,
            propertyDefinitionWithoutObjectName,
            propertyName,
            data;

        if (currentNamesPath === undefined) {
            currentNamesPath = '';
        }

        // get all values
        for (i in jsonData) {

            // add to group if is a simply object
            if (jsonData[i] instanceof Array || jsonData[i] == null || typeof jsonData[i] !== 'object' || grunt.util._.isEmpty(jsonData[i])) {

                // find group
                propertyDefinition = (currentNamesPath ? currentNamesPath + '.' + i : i)
                    .replace(/^[^.]+\./, '');
                group = propertiesUtils.getGroup(propertyDefinition, propertiesGroups);

                if (!group) {
                    grunt.log.error('Object ' + propertyDefinition + ' without init file');
                    return;
                }

                grunt.verbose.ok(propertyDefinition);

                // generate property data
                propertyDefinitionWithoutObjectName = propertyDefinition
                    .replace(group.pattern, '')
                    .replace(/^\./, '');
                propertyName = propertyDefinitionWithoutObjectName
                    .replace(/^prototype\./i, '');

                data = {
                    name:     propertyName,
                    comment:  '',

                    type:     'object',
                    isPublic: propertiesUtils.isPublic(propertyName),
                    isFromPrototype: propertiesUtils.isFromPrototype(propertyDefinitionWithoutObjectName),
                    filePath: filePath
                };


                // string -> "string"
                // true   -> true
                switch (typeof jsonData[i]) {
                case 'object':
                    if (jsonData[i] != null) {
                        data.source = JSON.stringify(jsonData[i]);
                    }
                    break;
                case 'string':
                    data.source = '"' + jsonData[i].split('"').join('\\"') + '"';
                    break;
                }
                if (data.source === undefined) {
                    data.source = '' + jsonData[i];
                }

                // add property data to prototype or inline array
                group[(data.isFromPrototype ? 'prototypeProperties' : 'inlineProperties')].push(data);
            } else {
                // is object
                // add attributeName to path and try to add
                addJSONProperties(jsonData[i], propertiesGroups, filePath, currentNamesPath ? currentNamesPath + '.' + i : i);
            }
        }
    }
1299202
def define_property(obj, name, fget=None, fset=None, fdel=None, doc=None):
    """"""
    if hasattr(fget, '__get__'):  # can pass a property declaration too
        prop = fget
    else:
        prop = property(fget, fset, fdel, doc)
    cls = obj.__class__
    obj.__class__ = type(cls.__name__, (cls, ), {
        '__doc__': cls.__doc__,
        name: prop
    })
111613
function Doc(text, file, line, options) {
  if (typeof text == 'object') {
    for ( var key in text) {
      this[key] = text[key];
    }
  } else {
    this.text = text;
    this.file = file;
    this.line = line;
  }
  this.options = options || {};
  this.scenarios = this.scenarios || [];
  this.requires = this.requires || [];
  this.param = this.param || [];
  this.properties = this.properties || [];
  this.methods = this.methods || [];
  this.events = this.events || [];
  this.links = this.links || [];
  this.anchors = this.anchors || [];
}
504797
function collectProperties (schemaObj, props) {
    if (schemaObj.properties) {
      for (var property in schemaObj.properties) {
        if (schemaObj.properties.hasOwnProperty(property)) {
          props[property] = schemaObj.properties[property];
        }
      }
    }
    if (schemaObj.allOf) {
      schemaObj.allOf.forEach(function (parent) {
        collectProperties(parent, props);
      });
    }
  }
191822
def _update_property_keys(cls):
        """"""
        for attr_name, config_prop in cls._iter_config_props():
            if config_prop.property_key is None:
                config_prop.property_key = attr_name
572939
function addCustomFeatureProperties(entity) {
  for (var i = 0; i < customProperties.length; i++) {
    if (entity.propertyNames.indexOf(customProperties[i]) === -1) {
      entity.addProperty(customProperties[i]);
    }
  }
}
29274
function modifyProperties(schema, paths) {
  if (!paths.length) { return; }

  const options = paths[0].options;

  /**
  * Modify document enum (string) properties to an object, with (original) value and
  * values (enumValues)
  *
  */
  function populatePropertyFor (documents, next) {
    if (this._mongooseOptions.lean) {
      asArray(documents).forEach(function(doc) {
        paths.forEach(function(path) {
          try {
            const splitted = path.path.split('.');
            const key      = splitted.shift();
            const insert   = { values: path.enumValues };
            const value    = doc[key];

            insert.value = determineValue(splitted, value);
            doc[key]     = nest(splitted, insert);
          } catch (error) { return next(error); }
        });
      });
    }

    next();
  }

  /**
  * If a document is modified, this method will locate the value on updates and assign it to the
  * appropriate property, allowing for proper validations later.
  * @param <Function>: next - function that notifies mongoose this middleware is complete
  */
  function reformatUpdateProperty(next) {
    const document = this._update['$set'];

    if (document) {
      paths.forEach(function(path) {
        try {
          const splitted = path.path.split('.');
          const key      = splitted.shift();

          if (document[key] === undefined) { return; }

          const value   = determineValue(splitted, document[key]);

          document[key] = nest(splitted, value);
        } catch (error) { return next(error); }
      });
    }

    next();
  }

  /**
  * If a document is modified, this method will locate the value before save/validation and assign it to the
  * appropriate property, allowing for proper validations later.
  * @param <Function>: next - function that notifies mongoose this middleware is complete
  */
  function reformatProperty(next) {
    const self = this;
    paths.forEach(function(path) {
      try {
        const splitted = path.path.split('.');
        const key      = splitted.shift();
        const value    = determineValue(splitted, self[key]);

        self[key]      = nest(splitted, value);
      } catch (error) { return next(error); }
    });

    next();
  }

  /**
  * Setup handlers for modifying properties -- ['find', 'findOne']
  */
  options.modify.on.forEach(function(on) {
    schema.post(on, populatePropertyFor);
  });

  schema.pre((options.validateBeforeSave ? 'validate' : 'save'), reformatProperty);

  /*
  * Setup handlers for updating documents (there may be more to consider)
  */
  ['update', 'findOneAndUpdate'].forEach(function(on) {
    schema.pre(on, reformatUpdateProperty);
  });
}
360943
void setDocNames(List<Annotation> docs)
  {

    container = new IndexedContainer();

    container.addContainerProperty(PROP_DOC_NAME, String.class, "n/a");
    MetaColumns metaCols = generateMetaColumns();

    for (MetaDataCol metaDatum : metaCols.visibleColumns)
    {
      container.
        addContainerProperty(metaDatum.getColName(), String.class, "n/a");
    }

    for (MetaDataCol metaDatum : metaCols.sortColumns)
    {
      container.
        addContainerProperty(metaDatum.getColName(), String.class, "n/a");
    }

    container.addContainerProperty("corpus path", String.class, "n/a");
    container.addContainerProperty("info", Button.class, null);
    container.addContainerProperty("visualizer", Panel.class, null);

    for (Annotation a : docs)
    {
      String doc = a.getName();

      // reverse path and delete the brackets and set a new separator:
      // corpus > ... > subcorpus > document
      List<String> pathList = a.getAnnotationPath();
      if (pathList == null)
      {
        pathList = new LinkedList<>();
      }

      Collections.reverse(pathList);
      String path = StringUtils.join(pathList, " > ");

      // use corpus path for row id, since it should be unique by annis db schema
      Item row = container.addItem(path);
      if(row != null)
      {
        row.getItemProperty(PROP_DOC_NAME).setValue(doc);

        // add the metadata columns.
        for (MetaDataCol metaDataCol : metaCols.visibleColumns)
        {
          String value = generateCell(a.getAnnotationPath(), metaDataCol);
          row.getItemProperty(metaDataCol.getColName()).setValue(value);
        }

        for (MetaDataCol metaDataCol : metaCols.sortColumns)
        {
          if (!metaCols.visibleColumns.contains(metaDataCol))
          {
            // corpusName() holds the corpus path
            String value = generateCell(a.getAnnotationPath(), metaDataCol);
            row.getItemProperty(metaDataCol.getColName()).setValue(value);
          }
        }

        row.getItemProperty("corpus path").setValue(path);
        row.getItemProperty("visualizer").setValue(generateVisualizerLinks(doc));
        row.getItemProperty("info").setValue(generateInfoButtonCell(doc));
      }
    }
    setContainerDataSource(container);
    Object[] metaDataColNames = new Object[metaCols.visibleColumns.size()];

    for (int i = 0; i < metaDataColNames.length; i++)
    {
      metaDataColNames[i] = metaCols.visibleColumns.get(i).getColName();
    }

    Object[] columnNames = ArrayUtils.addAll(ArrayUtils.addAll(new Object[]
    {
      "document name"
    }, metaDataColNames), new Object[]
    {
      "corpus path", "visualizer", "info"
    });

    setVisibleColumns(columnNames);

    for (Object colName : columnNames)
    {
      setColumnHeader((String) colName, (String) colName);
    }

    sortByMetaData(metaCols.sortColumns);
  }
970785
function(theArray, doc) {
    if ( typeof common.fieldMatching(theArray, "id", doc.id) != ('undefined' || null)) {
        return common.fieldMatching(theArray, "id", doc.id); 
    }
    else {
        return null;
    };           
}
304669
function applyPropDoclets(props, propName) {
  let prop = props[propName];
  let doclets = prop.doclets;
  let value;

  // the @type doclet to provide a prop type
  // Also allows enums (oneOf) if string literals are provided
  // ex: @type {("optionA"|"optionB")}
  if (doclets.type) {
    value = cleanDocletValue(doclets.type);
    prop.type.name = value;

    if (value[0] === '(') {
      value = value.substring(1, value.length - 1).split('|');

      prop.type.value = value;
      prop.type.name = value.every(isLiteral) ? 'enum' : 'union';
    }
  }

  // Use @required to mark a prop as required
  // useful for custom propTypes where there isn't a `.isRequired` addon
  if (doclets.required) {
    prop.required = true;
  }

  // Use @defaultValue to provide a prop's default value
  if (doclets.defaultValue) {
    prop.defaultValue = cleanDocletValue(doclets.defaultValue);
  }
}
45035
def define_properties(obj, props):
    """"""
    cls = obj.__class__
    dct = {
        '__doc__': cls.__doc__
    }

    for name, defn in list(props.items()):
        if is_callable(defn):
            defn = property(defn)
        elif not hasattr(defn, '__get__'):
            defn = property(*defn)
        dct[name] = defn

    obj.__class__ = type(cls.__name__, (cls, ), dct)
728795
function detect_doc(docs, customTags) {
    var ignore_tags = _.union(["param", "return", "author", "version", 
                               "cancelable", "bubbles", "since", "inherits", "todo", "deprecated"], customTags);
    var doc_tags = _.filter(docs, function(tag) { return !_.include(ignore_tags, tag["tagname"]) && !subproperty(tag) });
    return _.compact(_.map(doc_tags, function(tag) { return tag["doc"] })).join(" ");
}
1102212
function includeReferences(include, doc) {
  _.each(include, function (keypath) {
    var parts = keypath.split('.')
    var key = parts.shift()

    if (_.has(doc, key) && _.isString(doc[key])) {
      var ref = doc[key].split(':')
      doc[key] = getDocument({ collection: ref[0], id: ref[1] })

      if (parts.length > 0) {
        includeReferences(parts.slice(1), doc[key])
      }
    }
  })
}
177543
def _generate_union_properties(self, fields):
        """"""
        for field in fields:
            # void types do not need properties to store additional state
            # information
            if not is_void_type(field.data_type):
                doc = self.process_doc(
                    field.doc, self._docf) if field.doc else undocumented
                warning_str = (
                    ' @note Ensure the `is{}` method returns true before accessing, '
                    'otherwise a runtime exception will be raised.')
                doc += warning_str.format(fmt_camel_upper(field.name))
                self.emit_wrapped_text(
                    self.process_doc(doc, self._docf), prefix=comment_prefix)
                self.emit(fmt_property(field=field))
                self.emit()
284902
def process_object(self, obj):
        """"""
        document = self.document_class(meta={'id': self.generate_id(obj)})

        for field in document._doc_type.mapping:  # pylint: disable=protected-access
            if field in ['users_with_permissions', 'groups_with_permissions', 'public_permission']:
                continue  # These fields are handled separately

            try:
                # use get_X_value function
                get_value_function = getattr(self, 'get_{}_value'.format(field), None)
                if get_value_function:
                    setattr(document, field, get_value_function(obj))  # pylint: disable=not-callable
                    continue

                # use `mapping` dict
                if field in self.mapping:
                    if callable(self.mapping[field]):
                        setattr(document, field, self.mapping[field](obj))
                        continue

                    try:
                        object_attr = dict_dot(obj, self.mapping[field])
                    except (KeyError, AttributeError):
                        object_attr = None

                    if callable(object_attr):
                        # use method on object
                        setattr(document, field, object_attr(obj))
                    else:
                        # use attribute on object
                        setattr(document, field, object_attr)
                    continue

                # get value from the object
                try:
                    object_value = dict_dot(obj, field)
                    setattr(document, field, object_value)
                    continue
                except KeyError:
                    pass

                raise AttributeError("Cannot determine mapping for field {}".format(field))

            except Exception:  # pylint: disable=broad-except
                logger.exception(
                    "Error occurred while setting value of field '%s' in '%s' Elasticsearch index.",
                    field, self.__class__.__name__,
                    extra={'object_type': self.object_type, 'obj_id': obj.pk}
                )

        permissions = self.get_permissions(obj)
        document.users_with_permissions = permissions['users']
        document.groups_with_permissions = permissions['groups']
        document.public_permission = permissions['public']

        self.push_queue.append(document)
82236
def apply_defaults(self, instance):
        """"""
        for field, spec in self.doc_spec.iteritems():
            field_type = spec['type']
            if field not in instance:
                if 'default' in spec:
                    default = spec['default']
                    if callable(default):
                        instance[field] = default()
                    else:
                        instance[field] = copy.deepcopy(default)
            # Determine if a value already exists for the field
            if field in instance:
                value = instance[field]

                # recurse into nested docs
                if isinstance(field_type, Schema) and isinstance(value, dict):
                    field_type.apply_defaults(value)

                elif isinstance(field_type, Array) and isinstance(field_type.contained_type, Schema) and isinstance(value, list):
                    for item in value:
                        field_type.contained_type.apply_defaults(item)