The module constructor

@constructor
@param {string} moduleId 模块的Id.
@param {Compiler} ctx 整个Compiler的上下文环境，提供必要的api和保存一些全局的数据.
@param {CombineConfig=} combineConfig combine配置信息.
499492
function Module(moduleId, ctx, combineConfig) {
    this.moduleId = moduleId;
    this.compiler = ctx;
    this.combineConfig = combineConfig || ctx.getCombineConfig(moduleId);
    this.definition = null;
    this.prepare();
}
315008
function createJsModule(source) {
    var compilerOptions = {
        compilerOptions: {
            target: ts.ScriptTarget.ES5,
            module: ts.ModuleKind.CommonJS,
            alwaysStrict: false
        }
    };
    var transpiled = ts.transpileModule(source, compilerOptions);
    return transpiled.outputText;
}
1158635
function(obj, id) {
            if (!obj) {
                return;
            }

            if (typeof obj == 'function') {
                obj.prototype.__moduleId__ = id;
                return;
            }

            if (typeof obj == 'string') {
                return;
            }

            obj.__moduleId__ = id;
        }
1137260
function(module) {
	try {
		var div = WireIt.cn('div', {className: "WiringEditor-module"});
		
		if(module.description) {
			div.title = module.description;
		}
		
      if(module.container.icon) {
         div.appendChild( WireIt.cn('img',{src: module.container.icon}) );
      }
      div.appendChild( WireIt.cn('span', null, null, module.name) );

      var ddProxy = new WireIt.ModuleProxy(div, this);
      ddProxy._module = module;

		// Get the category element in the accordion or create a new one
		var category = module.category || "main";
		var el = Dom.get("module-category-"+category);
		if( !el ) {
			this.modulesAccordionView.addPanel({
				label: category,
				content: "<div id='module-category-"+category+"'></div>"
			});
			this.modulesAccordionView.openPanel(this.modulesAccordionView._panels.length-1);
			el = Dom.get("module-category-"+category);
		}
		
		el.appendChild(div);
	}catch(ex){ console.log(ex);}
 	}
1041039
function createInjector(options) {

  options = options || {};

  var configModule = {
    'config': ['value', options]
  };

  var modules = [ configModule, CoreModule ].concat(options.modules || []);

  return bootstrap(modules);
}
120825
function init(ctx) {
        _.each(resources, function (resource) {
            _.each(resource.tasks, function (taskInfo, taskName) {
                taskInfo.name = taskName;
                taskInfo.service = pancakes.getService(resource.name);
                taskHandlers[taskName] = taskInfo;
            });
        });

        return new Q(ctx);
    }
165703
protected ExecutionStatistics getOrCreateModuleStatistics(ModuleId moduleId) {
        ExecutionStatistics moduleStats = statistics.get(moduleId);
        if (moduleStats == null) {
            moduleStats = new ExecutionStatistics();
            ExecutionStatistics existing = statistics.put(moduleId, moduleStats);
            if (existing != null) {
                moduleStats = existing;
            }
        }
        return moduleStats;
    }
298122
function setModuleConfig(moduleConfig) {
                    if (!angular.isObject(moduleConfig)) {
                        throw new Error('You need to give the module config object to set');
                    }
                    modules[moduleConfig.name] = moduleConfig;
                    return moduleConfig;
                }
1097440
function Application(ctx, config) {
	// validate params
	if (!ctx && !config) {
		// both empty
		ctx = document;
		config = {};
	}
	else if (Utils.isNode(config)) {
		// reverse order of arguments
		var tmpConfig = config;
		config = ctx;
		ctx = tmpConfig;
	}
	else if (!Utils.isNode(ctx) && !config) {
		// only config is given
		config = ctx;
		ctx = document;
	}
	else if (Utils.isNode(ctx) && !config) {
		// only ctx is given
		config = {};
	}

	var defaults = {
		namespace: Module
	};

	config = Utils.extend(defaults, config);

	/**
	 * The context node.
	 *
	 * @property _ctx
	 * @type Node
	 */
	this._ctx = Utils.getElement(ctx);

	/**
	 * The configuration.
	 *
	 * @property config
	 * @type Object
	 */
	this._config = config;

	/**
	 * The sandbox to get the resources from.
	 * The singleton is shared between all modules.
	 *
	 * @property _sandbox
	 * @type Sandbox
	 */
	this._sandbox = new Sandbox(this);

	/**
	 * Contains references to all modules on the page.
	 *
	 * @property _modules
	 * @type Object
	 */
	this._modules = {};

	/**
	 * The next unique module id to use.
	 *
	 * @property id
	 * @type Number
	 */
	this._id = 1;
}
779903
function(element) {
			var moduleName = getModuleName(element),
				moduleData = modules[moduleName],
				instanceData,
				context,
				module;

			if (!moduleData) {
				error(new Error('Module type "' + moduleName + '" is not defined.'));
				return;
			}

			if (!this.isStarted(element)) {
				// Auto-assign module id to element
				if (!element.id) {
					element.id = 'mod-' + moduleName + '-' + moduleData.counter;
				}

				moduleData.counter++;

				context = new Box.Context(this, element);

				module = moduleData.creator(context);

				// Prevent errors from showing the browser, fire event instead
				if (!globalConfig.debug) {
					captureObjectErrors(module, moduleName);
				}

				instanceData = {
					moduleName: moduleName,
					instance: module,
					context: context,
					element: element,
					eventHandlers: {}
				};

				bindEventListeners(instanceData);

				instances[element.id] = instanceData;

				callModuleMethod(instanceData.instance, 'init');

				var moduleBehaviors = getBehaviors(instanceData),
					behaviorInstance;

				for (var i = 0, len = moduleBehaviors.length; i < len; i++) {
					behaviorInstance = moduleBehaviors[i];
					callModuleMethod(behaviorInstance, 'init');
				}

			}
		}
214074
function ContentManager( config ) {

  var self = this;
  var filingCabinet;
  var contextFactory;

  //region Initialization

  function initialize() {
    var getRenderer = require( config.getRenderer ?
      path.join( './../../../', config.getRenderer ) :
      markedRenderer
    );
    var renderer = getRenderer( marked );
    filingCabinet = new FilingCabinet( config );

    readControls(
      config.controls,
      filingCabinet
    );
    readReferences(
      config.components,
      config.referenceFile,
      filingCabinet
    );
    readComponents(
      config.components,
      config.referenceFile,
      config.localeFile,
      config.layoutSegment,
      config.contentSegment,
      filingCabinet,
      renderer
    );
    readContents(
      config.contents,
      config.submenuFile,
      filingCabinet,
      renderer
    );

    logger.showInfo( '*** Validating elements...' );
    filingCabinet.finalize();
    logger.showInfo( '*** Content manager is initialized.' );

    contextFactory = new ContextFactory( config, filingCabinet );
  }

  //endregion

  initialize();

  //region Public properties

  /**
   * Gets the list of the supported locales.
   * @member {Array.<string>}
   * @readonly
   */
  Object.defineProperty( this, 'supportedLocales', {
    get: function () {
      return filingCabinet.languages;
    },
    enumerable: true,
    configurable: false
  } );

  //endregion

  //region Public methods

  /**
   * Sets up the middlewares of the markdown site engine.
   * @param {Express.Application} app - The express.js application.
   */
  this.setMiddlewares = function( app ) {

    // Set up language.
    app.use( function( req, res, next ) {

      if (!req.session)
        req.session = { language: negotiateLanguage(
          req.headers["accept-language"], filingCabinet.languages, config.defaultLocale
        ) };
      else if (!req.session.language)
        req.session.language = negotiateLanguage(
          req.headers["accept-language"], filingCabinet.languages, config.defaultLocale
        );
      next();
    } );

    // Set up request context.
    app.use( function( req, res, next ) {

      var language = req.session.language;
      var url = req.url;
      var definition = filingCabinet.contents.getDefinition( language, url );
      req.ctx = contextFactory.create( language, url, definition );

      // Apply eventual redirection.
      if (definition.rewrite)
        req.url = definition.rewrite;

      next();
    } );
  };

  /**
   * Sets up the routes of the user defined actions.
   * @param {Express.Application} app - The express.js application.
   * @param {object} actions - An object containing the URLs and paths of the actions.
   */
  this.setActions = function( app, actions ) {

    for (var property in actions) {
      var method = 'post';
      var url = property.toLowerCase();

      // Does property have method?
      var pos = url.indexOf( ':' );
      if (pos > 0) {
        method = url.substring( 0, pos );
        url = url.substring( pos + 1 );
      }
      // Add action handler.
      app[ method ]( url, function( req, res, next) {

        // Get action function.
        var action = require( path.join( '../../../', actions[ property ] ) );

        // Execute the action.
        action( req, req.ctx, function( resultUrl ) {
          req.url = resultUrl || '/404';
          next();
        });
      } );
      logger.routeAdded( url, method.toUpperCase() );
    }
  };

  /**
   * Sets up the routes of the markdown site engine.
   * @param {Express.Application} app - The express.js application.
   * @param {Boolean} isDevelopment - True when the application runs in environment environment.
   */
  this.setRoutes = function( app, isDevelopment ) {

    // Change language.
    app.use( config.paths.setLanguage, function( req, res ) {

      var len = req.baseUrl.length;
      var url = req.originalUrl.split( '?' )[ 0 ].substr( len );
      var curLanguage = req.session.language;
      var newLanguage = url.length > 1 ? url.substr( 1 ) : config.defaultLocale;

      req.session.language = newLanguage;
      var localizedPath = filingCabinet.getLocalizedPath(
        curLanguage, req.query[ 'id' ], newLanguage
      );
      res.redirect( localizedPath );
    } );
    logger.routeAdded( config.paths.setLanguage );

    // Reread the contents.
    app.use( config.paths.reboot, function( req, res ) {

      initialize();
      res.redirect( '/' );
    } );
    logger.routeAdded( config.paths.reboot );

    // Search the contents.
    var searchPaths = [ ];

    filingCabinet.languages.forEach( function( language ) {

      var searchPath = filingCabinet.contents.searchPath( language );
      if (searchPath && searchPaths.indexOf( searchPath ) < 0)
        searchPaths.push( searchPath );
    } );
    searchPaths.forEach( function( searchPath ) {

      app.post( searchPath, searchTheContents );
      logger.routeAdded( searchPath, 'POST' );
    } );

    // Developer methods.
    if (isDevelopment)
      setDeveloperRoutes( app, filingCabinet, config.paths, config.develop );

    // Serve contents.
    app.use( '*', function( req, res ) {

      var language = req.session.language;
      var url = req.baseUrl;
      var context = req.ctx;
      if (req.originalUrl !== req.baseUrl) {

        // Recreate the context for the rewritten path.
        var data = context.data;
        var definition = filingCabinet.contents.getDefinition( language, url );
        context = contextFactory.create( language, url, definition );
        Object.assign( context.data, data );
      }
      // Add eventual highlight text to context data.
      if (req.query.hl)
        context.data.highlight = req.query.hl;

      res.status( 200 ).send( filingCabinet.get( language, url, context ) );
    } );
    logger.routeAdded( '/* <all-contents>' );
  };

  function searchTheContents( req, res, next ) {

    // Initialize data.
    req.ctx.data.text2search = '';
    req.ctx.data.results = [ ];

    if (req.body) {
      // Search the required text in the contents.
      req.ctx.data.text2search = req.body.text2search;
      req.ctx.data.results = filingCabinet.contents.search( req.ctx );
    }
    else
      logger.showError( 'Middleware "body-parser" is not applied.' );

    next();
  }

  //endregion
}
890591
function modDefined( id ) {
        var listeners = modDefinedListeners[ id ] || [];
        var module = modModules[ id ];
        module.state = MODULE_DEFINED;

        var len = listeners.length;
        while ( len-- ) {
            // 这里不做function类型的检测
            // 因为listener都是通过modOn传入的，modOn为内部调用
            listeners[ len ]();
        }

        // 清理listeners
        listeners.length = 0;
        delete modDefinedListeners[ id ];
    }
839703
def emit(self, ctx, modules, fd):
        
        for (epos, etag, eargs) in ctx.errors:
            if error.is_error(error.err_level(etag)):
                raise error.EmitError("JTOX plugin needs a valid module")
        tree = {}
        mods = {}
        annots = {}
        for m,p in unique_prefixes(ctx).items():
            mods[m.i_modulename] = [p, m.search_one("namespace").arg]
        for module in modules:
            for ann in module.search(("ietf-yang-metadata", "annotation")):
                typ = ann.search_one("type")
                annots[module.arg + ":" + ann.arg] = (
                    "string" if typ is None else self.base_type(typ))
        for module in modules:
            self.process_children(module, tree, None)
        json.dump({"modules": mods, "tree": tree, "annotations": annots}, fd)
1242057
function createLocalRequire(baseId) {
        var requiredCache = {};

        function req(requireId, callback) {
            if (typeof requireId === 'string') {
                if (!requiredCache[requireId]) {
                    var topLevelId = normalize(requireId, baseId);

                    // 根据 https://github.com/amdjs/amdjs-api/wiki/require
                    // It MUST throw an error if the module has not
                    // already been loaded and evaluated.
                    modTryInvokeFactory(topLevelId);
                    if (!modIs(topLevelId, MODULE_DEFINED)) {
                        throw new Error('[MODULE_MISS]"' + topLevelId + '" is not exists!');
                    }

                    requiredCache[requireId] = modModules[topLevelId].exports;
                }

                return requiredCache[requireId];
            }
            else if (requireId instanceof Array) {
                // 分析是否有resource，取出pluginModule先
                var pureModules = [];
                var normalizedIds = [];

                each(
                    requireId,
                    function (id, i) {
                        var idInfo = parseId(id);
                        var absId = normalize(idInfo.mod, baseId);
                        var resId = idInfo.res;
                        var normalizedId = absId;

                        if (resId) {
                            var trueResId = absId + '!' + resId;
                            if (resId.indexOf('.') !== 0 && bundlesIndex[trueResId]) {
                                absId = normalizedId = trueResId;
                            }
                            else {
                                normalizedId = null;
                            }
                        }

                        normalizedIds[i] = normalizedId;
                        modFlagAutoDefine(absId);
                        pureModules.push(absId);
                    }
                );

                // 加载模块
                nativeAsyncRequire(
                    pureModules,
                    function () {
                        /* jshint ignore:start */
                        each(normalizedIds, function (id, i) {
                            if (id == null) {
                                id = normalizedIds[i] = normalize(requireId[i], baseId);
                                modFlagAutoDefine(id);
                            }
                        });
                        /* jshint ignore:end */

                        // modAutoDefine中，factory invoke可能发生错误
                        // 从而导致nativeAsyncRequire没有被调用，callback没挂上
                        // 所以nativeAsyncRequire要先运行
                        nativeAsyncRequire(normalizedIds, callback, baseId);
                        modAutoDefine();
                    },
                    baseId
                );
                modAutoDefine();
            }
        }

        /**
         * 将[module ID] + '.extension'格式的字符串转换成url
         *
         * @inner
         * @param {string} id 符合描述格式的源字符串
         * @return {string} url
         */
        req.toUrl = function (id) {
            return toUrl(id, baseId || '');
        };

        return req;
    }
5900
def create(ctx):
    
    import shutil

    this_dir, this_filename = os.path.split(__file__)
    default_config_file = os.path.join(this_dir, "apis/example-config.yaml")
    config_file = ctx.obj["configfile"]
    shutil.copyfile(default_config_file, config_file)
    print_message("Config file created: {}".format(config_file))
1273225
protected Converter createConverter(FaceletContext ctx)
    {
        if (_delegate.getConverterId(ctx) == null)
        {
            throw new TagException(_delegate.getTag(),
                                    "Default behavior invoked of requiring a converter-id passed in the "
                                    + "constructor, must override ConvertHandler(ConverterConfig)");
        }
        return ctx.getFacesContext().getApplication().createConverter(_delegate.getConverterId(ctx));
    }
1108161
function moduleToCode(id, r) {
		exports.module(id, options, done);
		function done(err, result) {
			if (err) {
				next(err);
				next = function(){}; // make sure you only call next(err) once
				return;
			}

			if (result && (!modified || result.modified > modified)) {
				modified = result.modified; // update latest last modified date
			}

			results[r] = result && result.code || '';
			if (++doneCount >= ids.length) { alldone(); } // done with all of them

		}
	}