Inject AutoAPI into the TOC Tree dynamically.
430066
def doctree_read(app, doctree):
    
    if app.env.docname == "index":
        all_docs = set()
        insert = True
        nodes = doctree.traverse(toctree)
        toc_entry = "%s/index" % app.config.autoapi_root
        add_entry = (
            nodes
            and app.config.autoapi_generate_api_docs
            and app.config.autoapi_add_toctree_entry
        )
        if not add_entry:
            return
        # Capture all existing toctree entries
        for node in nodes:
            for entry in node["entries"]:
                all_docs.add(entry[1])
        # Don't insert autoapi it's already present
        for doc in all_docs:
            if doc.find(app.config.autoapi_root) != -1:
                insert = False
        if insert and app.config.autoapi_add_toctree_entry:
            # Insert AutoAPI index
            nodes[-1]["entries"].append((None, u"%s/index" % app.config.autoapi_root))
            nodes[-1]["includefiles"].append(u"%s/index" % app.config.autoapi_root)
            message_prefix = bold("[AutoAPI] ")
            message = darkgreen(
                "Adding AutoAPI TOCTree [{0}] to index.rst".format(toc_entry)
            )
            LOGGER.info(message_prefix + message)
1293497
function injectJs(jsList, content) {
        var script = jsList.reduce(function (prev, now) {
            var uri = now.uri;
            return [prev, '<script type="text/javascript" src="', uri, '"></script>\r\n'].join('');
        }, '');
        if (content.indexOf(settings.scriptTag) !== -1) {
            content = content.replace(settings.scriptTag, script);
        }
        else {
            content = content.replace(/<\/head>/, script + '\n$&');
        }
        return content;
    }
1122373
private void updateAutoGeneratedQueriesPanel()
  {
    // make sure to make a copy since we are adding items to this set
    Set<String> corpora = new HashSet<>(ui.getQueryState().getSelectedCorpora().
      getValue());

    if (corpora.isEmpty())
    {
      corpora.addAll(ui.getQueryState().getAvailableCorpora().getItemIds());
    }
    autoGenQueries.setSelectedCorpusInBackground(corpora);
  }
1129067
function selfapi (/* parent, …overrides, child */) {
  // Parent API instance or root server app.
  var parent = null;

  // Child API overrides.
  var path = null;
  var title = null;
  var description = null;

  // Child API instance.
  var child = null;

  if ((this instanceof API) || isServerApp(this)) {
    // Called from parent, e.g. `var api = parent.api(…)`.
    parent = this;
  } else if ((arguments[0] instanceof API) || isServerApp(arguments[0])) {
    // First argument is parent, e.g. `var api = selfapi(parent…)`.
    parent = [].shift.call(arguments);
  }

  if (typeof arguments[0] === 'string' /* || instanceof RegExp */) {
    // Next argument is path, e.g. `api(…path…)`.
    path = [].shift.call(arguments);
    if (typeof arguments[0] === 'string') {
      // Next argument is title, e.g. `api(…path, title…)`.
      title = [].shift.call(arguments);
      if (typeof arguments[0] === 'string') {
        // Next argument is description, e.g. `api(…path, title, description…)`.
        description = [].shift.call(arguments);
      }
    }
  }

  if (arguments[arguments.length - 1] instanceof API) {
    // Last argument is child API instance, e.g. `selfapi(…api)`.
    child = [].pop.call(arguments);
  } else if (typeof arguments[arguments.length - 1] === 'object') {
    // Last argument is parameters object, e.g. `selfapi(…parameters)`.
    var parameters = [].pop.call(arguments);
    child = new API(parameters);
  } else {
    // No further useful argument.
    child = new API({});
  }

  // Apply any overrides.
  if (path) {
    child.path = path;
  }
  if (title) {
    child.title = title;
  }
  if (description) {
    child.description = description;
  }

  // Associate child and parent, triggering the `set parent` function if needed.
  if (parent) {
    child.parent = parent;
  }

  return child;
}
173263
def as_tree(context):
    """"""

    tree = _build_tree(context, 2, 1)
    if type(tree) == dict:
        tree = [tree] 
    
    return Response(content_type='application/json', body=json.dumps(tree))
363515
function loadAPI() {
  var apiPath = this.fullPath(this.paths.api);
  if (fs.existsSync(apiPath) && fs.statSync(apiPath).isDirectory()) {
    var files = protos.util.ls(apiPath, this.regex.jsFile);
    files.forEach(function(file) {
      var methods = protos.require(apiPath + "/" + file, true); // Don't use module cache (allow reloading)
      _.extend(this.api, methods);
    }, this);
  }
  this.emit('api_loaded', this.api);
}
1223114
function injectVideoApi(url, callback) {
    if (utils.isNil(url)) {
        console.error('Inject videos api error');
        return;
    }
    let found = document.querySelectorAll('script[src="' + url + '"]')
    if (utils.isNil(found) || found.length == 0) {
        let script = document.createElement('script');
        script.type = 'text/javascript';
        script.src = url;
        script.onload = () => {
            if (utils.isFunction(callback)) callback();
        };
        document.body.appendChild(script);
        return false;
    }
    if (utils.isFunction(callback)) callback();
}
63892
private <T> Provider<T> autoProvider(Key<T> key)
  {
    for (InjectAutoBind autoBind : _autoBind) {
      Provider<T> provider = autoBind.provider(this, key);

      if (provider != null) {
        return provider;
      }
    }

    return providerDefault(key);
  }
922381
protected void inject(Collection<? extends Expression> objs) {
        for (Object o : objs) {
            if (o == null) {
                continue;
            }

            injector.injectMembers(o);
        }
    }
1071278
def autopage(self):
        
        while self.items:
            yield from self.items
            self.items = self.fetch_next()
1103464
function injectMethods(Collection, collection) {
  Object.keys(Collection.prototype).forEach(function (method) {
    collection[method] = Collection.prototype[method];
  });
}
60170
private void addAnchor(DeprecatedAPIListBuilder builder, int type, Content htmlTree) {
        if (builder.hasDocumentation(type)) {
            htmlTree.addContent(getMarkerAnchor(ANCHORS[type]));
        }
    }
356906
function addLegacyAPI(service, handle) {
    var falseFn = function() {
      return false;
    };
    var rejectFn = function() {
      return $q.when($mdUtil.supplant(errorMsg, [handle || ""]));
    };

    return angular.extend({
      isLockedOpen: falseFn,
      isOpen: falseFn,
      toggle: rejectFn,
      open: rejectFn,
      close: rejectFn,
      onClose: angular.noop,
      then: function(callback) {
        return waitForInstance(handle).then(callback || angular.noop);
      }
    }, service);
  }
1131110
def expose(self, binder, interface, annotation=None):
        """"""
        private_module = self
        class Provider(object):
            def get(self):
                return private_module.private_injector.get_instance(
                        interface, annotation)

        self.original_binder.bind(interface, annotated_with=annotation,
                                  to_provider=Provider)
1241348
def _expand_autotag(atag, container):
    
    if atag.tag != "auto":
        return

    if "names" in atag.attrib:
        i = -1
        for name in re.split("[\s,]+", atag.attrib["names"]):
            if name[0] == '^':
                name = name[1::]
                insert = True
                i += 1
            else:
                insert = False
                
            for child in atag:
                dupe = child.copy()
                for attr, value in dupe.items():
                    dupe.attrib[attr] = value.replace("$", name)

                if insert:
                    container.insert(i, dupe)
                else:
                    container.append(dupe)            
    else:
        from fortpy.msg import warn
        warn("'names' is a required attribute of the <auto> tag.")
707212
function (id, obj, deps) {
            var normId = normalizeServiceName(id);
            injectedMap[normId] = obj;

            if (deps) {
                dependencyMap[normId] = normalizeServiceNames(deps);
            }
        }
364582
def prepare(cls):
        """"""
        if cls._ask_openapi():
            napp_path = Path()
            tpl_path = SKEL_PATH / 'napp-structure/username/napp'
            OpenAPI(napp_path, tpl_path).render_template()
            print('Please, update your openapi.yml file.')
            sys.exit()