generate class spec
333276
function GENERATE_CLASS(name, description, namespace, parent) {
  return GENERATE_DOC(description + '\n' 
    + '@class ' + name + '\n'
    + (namespace ? ('@module ' + namespace + '\n') : '')
    /*
    TODO: leave out until figure out what swig does with inheritance
    + (parent ? ('@extends ' + parent + '\n') : '')
    */
  );
}
992330
def _generate_struct_class(self, ns, data_type):
        # type: (ApiNamespace, Struct) -> None
        """"""
        self.emit(self._class_declaration_for_type(ns, data_type))
        with self.indent():
            self._generate_struct_class_init(ns, data_type)
            self._generate_struct_class_properties(ns, data_type)
            self._generate_struct_or_union_class_custom_annotations()

        self._generate_validator_for(data_type)
        self.emit()
315758
def create_new_spec(class_or_module, dry_run, rails_mode, file_path, spec_path)
      # These names are used in ERB template, don't delete.
      # rubocop:disable Lint/UselessAssignment
      methods_to_generate = class_or_module.method_list.select { |m| m.visibility == :public }
      c = class_or_module
      self_path = to_string_value_to_require(file_path)
      # rubocop:enable Lint/UselessAssignment

      erb = RSpecKickstarter::ERBFactory.new(@full_template).get_instance_for_new_spec(rails_mode, file_path)
      code = erb.result(binding)

      if dry_run
        puts "----- #{spec_path} -----"
        puts code
      else
        if File.exist?(spec_path)
          puts "#{spec_path} already exists."
        else
          FileUtils.mkdir_p(File.dirname(spec_path))
          File.open(spec_path, 'w') { |f| f.write(code) }
          puts "#{spec_path} created."
        end
      end
    end
144449
function GENERATE_ENUM(name, spec, parent) {
  return GENERATE_DOC(spec.description + '\n'
    + '@property ' + name + '\n'
    + '@type Enum ' + spec.type + '\n'
    + '@for ' + (parent ? parent : 'common') + '\n');
}
512257
def generate_product_class_template(
      class_name, module_indent, has_module, require_rb, mnames)
      module_name, class_name = ModuleClassSeparator.separate(class_name)
      methods_template = Generators::ProductMethodTemplate.generate(
        mnames, module_indent)
      fields = get_fields(mnames, module_indent)
      module_start, module_end = module_start_end(has_module, module_name)
      ERB.new(Constants::PRODUCT_CLASS_TEMPLATE).result(binding)
    end
948000
def _get_spec(tree_base, spec, template, saltenv='base'):
    '''
    
    '''
    spec_tgt = os.path.basename(spec)
    dest = os.path.join(tree_base, 'SPECS', spec_tgt)
    return __salt__['cp.get_url'](
        spec,
        dest,
        saltenv=saltenv)
1274594
function specs() {
    var routes = {};

    // Reducing the app's recursive stack
    function reduceStack(path, items, item) {
      var nextPath;

      if (item.handle && item.handle.stack) {
        nextPath = join(path, (item.path || helpers.unescapeRegex(item.regexp) || ''));
        return items.concat(item.handle.stack.reduce(reduceStack.bind(null, nextPath), []));
      }

      if (item.route) {
        nextPath = join(path, (item.route.path || ''));
        return items.concat(item.route.stack.reduce(reduceStack.bind(null, nextPath), []));
      }

      return items.concat({
        handle: item.handle,
        path: path
      });
    }

    // Filtering the actions coming from dolman
    app._router.stack
      .reduce(reduceStack.bind(null, ''), [])
      .map(function(item) {
        return {
          route: routesMap.get(item.handle),
          path: item.path
        };
      })
      .filter(function(item) {
        return item.route && item.route.name;
      })
      .forEach(function(item) {
        var route = item.route,
            method = [].concat(route.method || route.methods)[0];

        var routeData = {
          path: item.path,
          name: route.name,
          method: !method || method === 'ALL' ? 'GET' : method
        };

        ['description'].forEach(function(k) {
          if (route[k])
            routeData[k] = route[k];
        });

        routes[route.name] = routeData;
      });

    return {
      formats: ['json'],
      methods: routes
    };
  }
434005
def getSpec(cls):
    
    spec = cls.getBaseSpec()
    p, o = _getAdditionalSpecs()
    spec["parameters"].update(p)
    spec["parameters"].update(o)

    return spec
490488
function GENERATE_METHOD(name, spec, parent) {
  name = name.replace(/!+$/, '');
  return GENERATE_DOC(spec.description + '\n'
    + '@method ' + name + '\n'
    + (parent ? ('@for ' + parent + '\n') : '@for common\n')
    + _.reduce(spec.params, function(memo, paramSpec, paramName) {
        return memo + '@param {' + GENERATE_TYPE(paramSpec.type) + '} ' + paramName + ' ' + paramSpec.description + '\n'; 
      }, '')
    + ( !_.isEmpty(spec.return) ? ('@return {' + GENERATE_TYPE(spec.return.type) + '} ' + spec.return.description + '\n') : ''));
}
155054
def generate_classes(self, items):
        ""
        classes = super().generate_classes([o[1] for o in items])
        classes = ['background'] + list(classes)
        return classes
1002993
function GENERATE_CLASSES(classes) {
  var docs = {};
  _.each(classes, function(classSpec, parentClass) {
    var constructor =  classSpec.methods[parentClass];
    _.extend(docs, GENERATE_METHOD(parentClass, constructor ? constructor : { params: {}, return: {}, description: '' } ));
    if (_.has(docs, parentClass)) {
      _.each(classSpec.enums, function(enumSpec, enumName) {
        _.extend(docs[parentClass], GENERATE_ENUM(enumName, enumSpec));
      });
      docs[parentClass].prototype = {};
      _.each(_.omit(classSpec.methods, parentClass), function(methodSpec, methodName) {
        _.extend(docs[parentClass].prototype, GENERATE_METHOD(methodName, methodSpec));
      });
      _.each(classSpec.variables, function(variableSpec, variableName) {
        _.extend(docs[parentClass].prototype, GENERATE_VARIABLE(variableName, variableSpec));
      });
    }
  });
  return docs;
}
217793
def auto_param_specs(self):
        
        for spec in self.study_class.parameter_specs():
            if spec.name not in self._name_map:
                yield spec
1315958
private void generateClassFiles(ClassTree classtree) throws DocletException {
        SortedSet<PackageElement> packages = configuration.typeElementCatalog.packages();
        for (PackageElement pkg : packages) {
            generateClassFiles(configuration.typeElementCatalog.allClasses(pkg), classtree);
        }
    }
362820
public function generatePropertyMapClass()
    {
        $classMap = array();

        foreach($this->elementClassFinder as $classFile)
        {
            /** @var \Symfony\Component\Finder\SplFileInfo $classFile */
            $className = str_replace(array('\\', 'src/', '/', '.php'), array('/', '', '\\', ''), $classFile->getRelativePathname());

            if (false !== strpos($className, 'Abstract') || false !== strpos($className, 'Interface'))
                continue;

            $namespacedClassName = $this->elementClassNamespace.$className;
            $reflectionClass = new \ReflectionClass($namespacedClassName);
            $classMap[$namespacedClassName] = $this->createMapEntry($reflectionClass);
        }

        foreach($this->resourceClassFinder as $classFile)
        {
            /** @var \Symfony\Component\Finder\SplFileInfo $classFile */
            $className = str_replace(array('\\', 'src/', '/', '.php'), array('/', '', '\\', ''), $classFile->getRelativePathname());

            if (false !== strpos($className, 'Abstract') || false !== strpos($className, 'Interface'))
                continue;

            $namespacedClassName = $this->resourceClassNamespace.$className;
            $reflectionClass = new \ReflectionClass($namespacedClassName);
            $classMap[$namespacedClassName] = $this->createMapEntry($reflectionClass);
        }

        $outputFile = $this->outputDir.$this->outputClassName.'.php';

        $data = str_replace("\n  ", "\n        ", var_export($classMap, true));
        $now = date('Y-m-d e');
        $outputString = <<<PHP
<?php

/**
 * This class is automatically generated by php-fhir-object-mapper, do not edit!
 *
 * Created: {$now}
 */
class {$this->outputClassName} implements \\ArrayAccess {

    /** @var array */
    private \$_classMap = {$data};

    public function offsetSet(\$offset, \$value) {
        throw new \\BadMethodCallException('You may not add objects to this map post-creation.');
    }

    public function offsetExists(\$offset) {
        return isset(\$this->_classMap[\$offset]);
    }

    public function offsetUnset(\$offset) {
        throw new \\BadMethodCallException('You may not remove objects from this map post-creation.');
    }

    public function offsetGet(\$offset) {
        if (isset(\$this->_classMap[\$offset]))
            return \$this->_classMap[\$offset];

        throw new \OutOfRangeException('No FHIR class named "'.\$offset.'" exists in this map.');
    }
}
PHP;
        return (bool)file_put_contents($outputFile, $outputString);
    }
980822
def _make_class(cls, **kwargs):
    """"""
    kwargs = {k: (v if v is not None else getattr(cls, k, None))
              for k, v in kwargs.items()}
    # The class name contains a hash of the custom parameters.
    name = cls.__name__ + '_' + _hash(kwargs)
    if name not in _CLASSES:
        logger.log(5, "Create class %s %s.", name, kwargs)
        cls = type(name, (cls,), kwargs)
        _CLASSES[name] = cls
    return _CLASSES[name]
1006206
def make_tokenizer(specs):
    """"""

    def compile_spec(spec):
        name, args = spec
        return name, re.compile(*args)

    compiled = [compile_spec(s) for s in specs]

    def match_specs(specs, str, i, position):
        line, pos = position
        for type, regexp in specs:
            m = regexp.match(str, i)
            if m is not None:
                value = m.group()
                nls = value.count(u'\n')
                n_line = line + nls
                if nls == 0:
                    n_pos = pos + len(value)
                else:
                    n_pos = len(value) - value.rfind(u'\n') - 1
                return Token(type, value, (line, pos + 1), (n_line, n_pos))
        else:
            errline = str.splitlines()[line - 1]
            raise LexerError((line, pos + 1), errline)

    def f(str):
        length = len(str)
        line, pos = 1, 0
        i = 0
        while i < length:
            t = match_specs(compiled, str, i, (line, pos))
            yield t
            line, pos = t.end
            i += len(t.value)

    return f
1214994
public Class<?> generateClass(String name, Modifiers modifiers, Class<?>[] interfaces, Class<?> superClass, BSHBlock block, Type type, CallStack callstack, Interpreter interpreter) throws EvalError {
        // Delegate to the static method
        return generateClassImpl(name, modifiers, interfaces, superClass, block, type, callstack, interpreter);
    }