write method based on RequireJS official text plugin by James Burke https://github.com/jrburke/requirejs/blob/master/text.js
964226
function(pluginName, moduleName, write){
            if(moduleName in buildMap){
                var content = buildMap[moduleName];
                write('define("'+ pluginName +'!'+ moduleName +'", function(){ return '+ content +';});\n');
            }
        }
222338
async function write(packageName, pkg) {
  const packagePath = path.join(cwd, packageName, 'package.json');

  await fs.writeFile(packagePath, `${JSON.stringify(pkg, null, 2)}\n`);
}
348732
function (out) {
            var textContent = this._cfg.text;
            // String cast
            if (textContent !== null) {
                textContent = '' + textContent;
            } else {
                textContent = '';
            }
            this.textContent = textContent;
            out.write('<span class="createdEllipisElement">' + ariaUtilsString.escapeHTML(this.textContent)
                    + "</span>");
        }
1176261
function insertTextScript(text) {
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.text = text;
    insertHeaderNode(script);
    return script;
}
611395
function write(s) {
		var err
		var args = Array.prototype.slice.call(arguments)
		var cb = typeof args[args.length - 1] === 'function' ? args.pop() : null
		var cbCounter = 1
		if (writeToStdoutEnabled) {
			cbCounter++
			process.stdout.write(s, stdWr)
		}
		if (writeStream) {
			cbCounter++
			writeStream.write(s, wRes)
		}
		end()

		function stdWr(e) {
			if (e) {
				if (!err) err = e
				writeToStdoutEnabled = false
				write('stdout error: ' + e.message)
				self.emit('error', e)
			}
			end()
		}

		function wRes(e) {
			if (e) {
				if (!err) err = e
				writeStream = false
				write('stream error: ' + e.message)
				self.emit('error', e)
			}
			end()
		}

		function end() {
			if (!--cbCounter)
				if (cb)
					if (err) cb(err)
					else cb()
		}
	}
869659
protected void writeJavaScript(Header header) throws IOException {
        addTabs(2);
        writeStart(HtmlTags.SCRIPT);
        write(HtmlTags.LANGUAGE, HtmlTags.JAVASCRIPT);
        if (markup.size() > 0) {
          /* JavaScript reference example:
           *
           * <script language="JavaScript" src="/myPath/MyFunctions.js"/>
           */ 
          writeMarkupAttributes(markup);
          os.write(GT);
          writeEnd(HtmlTags.SCRIPT);
        }
        else {
          /* JavaScript coding convention:
           *
           * <script language="JavaScript" type="text/javascript">
           * <!--
           * // ... JavaScript methods ...
           * //-->
           * </script>
           */ 
          write(HtmlTags.TYPE, Markup.HTML_VALUE_JAVASCRIPT);
          os.write(GT);
          addTabs(2);
          write(new String(BEGINCOMMENT) + "\n");
          write(header.getContent());
          addTabs(2);
          write("//" + new String(ENDCOMMENT));
          addTabs(2);
          writeEnd(HtmlTags.SCRIPT);
        }
    }
897800
function write(dir, code) {
  return new Promise(function (resolve, reject) {
    fse.ensureFile(dir, (err) => {
      if (err) return reject(err)
      fs.writeFile(dir, code, 'utf-8', (err) => {
        if (err) {
          return reject(err)
        }
        console.info(chalk.red(dir) + ' ' + chalk.green(getSize(code)))
        resolve()
      })
    })
  })
}
1018883
function functionWriter(&$doclet) {

        parent::MDWriter($doclet);

        $this->_id = "definition";

        $rootDoc = & $this->_doclet->rootDoc();

        $packages = & $rootDoc->packages();
        ksort($packages);

        foreach ($packages as $packageName => $package) {
            $this->_depth = $package->depth() + 1;

            ob_start();

            echo "- - -\n\n";

            echo "#Functions#\n\n";

            echo "- - -\n\n";

            $functions = & $package->functions();

            if ($functions) {
                ksort($functions);
                echo "<table id=\"summary_function\" class=\"title\">", "\n";
                echo "<tr><th colspan=\"2\" class=\"title\">Function Summary</th></tr>", "\n";
                foreach ($functions as $function) {
                    $textTag = & $function->tags("@text");
                    echo "<tr>\n";
                    echo "<td>", $this->_methodSignature($function), "</td>\n";
                    echo "<td class=\"description\">";
                    echo "<p class=\"name\"><a href=\"#", $this->_asURL($function),"\">", $function->name(), "</a>", $this->_flatSignature($function), "</p>";
                    if ($textTag) {
                        echo "<p class=\"description\">", strip_tags($this->_processInlineTags($textTag, TRUE), "<a><b>**<u><em>"), "</p>";
                    }
                    echo "</td>\n";
                    echo "</tr>\n";
                }
                echo "</table>\n\n";

                echo "<h2 id=\"detail_function\">Function Detail</h2>", "\n";
                foreach ($functions as $function) {
                    $textTag = & $function->tags("@text");
                    $this->_sourceLocation($function);
                    echo "<h3 id=\"", $function->name(), "()\">", $function->name(), "</h3>\n";
                    echo $this->_methodSignature($function);
                    echo " {$function->name()} {$this->_flatSignature($function)}\n\n";
                    echo "<div class=\"details\">\n";
                    if ($textTag) {
                        echo $this->_processInlineTags($textTag), "\n";
                    }
                    $this->_processTags($function->tags());
                    echo "</div>\n\n";
                    echo "- - -\n\n";
                }
            }

            $this->_output = ob_get_contents();
            ob_end_clean();

            $this->_write($this->_normalize($package->_name) . "_package-functions.md");
        }
    }
33790
def _write_method(schema):
    
    def method(
        self,
        filename=None,
        schema=schema,
        id_col='uid',
        sequence_col='sequence',
        extra_data=None,
        alphabet=None,
        **kwargs):
        # Use generic write class to write data.
        return _write(
            self._data,
            filename=filename,
            schema=schema,
            id_col=id_col,
            sequence_col=sequence_col,
            extra_data=extra_data,
            alphabet=alphabet,
            **kwargs
        )
    # Update docs
    method.__doc__ = _write_doc_template(schema)
    return method
1304807
function(str, lex) {
  if (lex) {
    w.plugin({
      words: lex
    });
  }
  let doc = buildText(str, w);
  doc.tagger();
  return doc;
}
826223
def _write_html_pages(root, tlobjects, methods, layer, input_res):
    
    # Save 'Type: [Constructors]' for use in both:
    # * Seeing the return type or constructors belonging to the same type.
    # * Generating the types documentation, showing available constructors.
    paths = {k: root / v for k, v in (
        ('css', 'css'),
        ('arrow', 'img/arrow.svg'),
        ('search.js', 'js/search.js'),
        ('404', '404.html'),
        ('index_all', 'index.html'),
        ('bot_index', 'botindex.html'),
        ('index_types', 'types/index.html'),
        ('index_methods', 'methods/index.html'),
        ('index_constructors', 'constructors/index.html')
    )}
    paths['default_css'] = 'light'  # docs.<name>.css, local path
    type_to_constructors = defaultdict(list)
    type_to_functions = defaultdict(list)
    for tlobject in tlobjects:
        d = type_to_functions if tlobject.is_function else type_to_constructors
        d[tlobject.result].append(tlobject)

    for t, cs in type_to_constructors.items():
        type_to_constructors[t] = list(sorted(cs, key=lambda c: c.name))

    methods = {m.name: m for m in methods}

    # Since the output directory is needed everywhere partially apply it now
    create_path_for = functools.partial(_get_path_for, root)
    path_for_type = lambda t: root / _get_path_for_type(t)
    bot_docs_paths = []

    for tlobject in tlobjects:
        filename = create_path_for(tlobject)
        with DocsWriter(root, filename, path_for_type) as docs:
            docs.write_head(title=tlobject.class_name,
                            css_path=paths['css'],
                            default_css=paths['default_css'])

            # Create the menu (path to the current TLObject)
            docs.set_menu_separator(paths['arrow'])
            _build_menu(docs)

            # Create the page title
            docs.write_title(tlobject.class_name)

            if tlobject.is_function:
                if tlobject.usability == Usability.USER:
                    start = '<strong>Only users</strong> can'
                elif tlobject.usability == Usability.BOT:
                    bot_docs_paths.append(filename)
                    start = '<strong>Only bots</strong> can'
                elif tlobject.usability == Usability.BOTH:
                    bot_docs_paths.append(filename)
                    start = '<strong>Both users and bots</strong> can'
                else:
                    bot_docs_paths.append(filename)
                    start = \
                        'Both users and bots <strong>may</strong> be able to'

                docs.write_text('{} use this method. <a href="#examples">'
                                'See code examples.</a>'.format(start))

            # Write the code definition for this TLObject
            docs.write_code(tlobject)
            docs.write_copy_button('Copy import to the clipboard',
                                   get_import_code(tlobject))

            # Write the return type (or constructors belonging to the same type)
            docs.write_title('Returns' if tlobject.is_function
                             else 'Belongs to', level=3)

            generic_arg = next((arg.name for arg in tlobject.args
                                if arg.generic_definition), None)

            if tlobject.result == generic_arg:
                # We assume it's a function returning a generic type
                generic_arg = next((arg.name for arg in tlobject.args
                                    if arg.is_generic))
                docs.write_text('This function returns the result of whatever '
                                'the result from invoking the request passed '
                                'through <i>{}</i> is.'.format(generic_arg))
            else:
                if re.search('^vector<', tlobject.result, re.IGNORECASE):
                    docs.write_text('A list of the following type is returned.')
                    _, inner = tlobject.result.split('<')
                    inner = inner.strip('>')
                else:
                    inner = tlobject.result

                docs.begin_table(column_count=1)
                docs.add_row(inner, link=path_for_type(inner))
                docs.end_table()

                cs = type_to_constructors.get(inner, [])
                if not cs:
                    docs.write_text('This type has no instances available.')
                elif len(cs) == 1:
                    docs.write_text('This type can only be an instance of:')
                else:
                    docs.write_text('This type can be an instance of either:')

                docs.begin_table(column_count=2)
                for constructor in cs:
                    link = create_path_for(constructor)
                    docs.add_row(constructor.class_name, link=link)
                docs.end_table()

            # Return (or similar types) written. Now parameters/members
            docs.write_title(
                'Parameters' if tlobject.is_function else 'Members', level=3
            )

            # Sort the arguments in the same way they're sorted
            # on the generated code (flags go last)
            args = [
                a for a in tlobject.sorted_args()
                if not a.flag_indicator and not a.generic_definition
            ]

            if args:
                # Writing parameters
                docs.begin_table(column_count=3)

                for arg in args:
                    # Name row
                    docs.add_row(arg.name,
                                 bold=True)

                    # Type row
                    friendly_type = 'flag' if arg.type == 'true' else arg.type
                    if arg.is_generic:
                        docs.add_row('!' + friendly_type, align='center')
                    else:
                        docs.add_row(
                            friendly_type, align='center',
                            link=path_for_type(arg.type)
                         )

                    # Add a description for this argument
                    docs.add_row(_get_description(arg))

                docs.end_table()
            else:
                if tlobject.is_function:
                    docs.write_text('This request takes no input parameters.')
                else:
                    docs.write_text('This type has no members.')

            if tlobject.is_function:
                docs.write_title('Known RPC errors')
                method_info = methods.get(tlobject.fullname)
                errors = method_info and method_info.errors
                if not errors:
                    docs.write_text("This request can't cause any RPC error "
                                    "as far as we know.")
                else:
                    docs.write_text(
                        'This request can cause {} known error{}:'.format(
                            len(errors), '' if len(errors) == 1 else 's'
                    ))
                    docs.begin_table(column_count=2)
                    for error in errors:
                        docs.add_row('<code>{}</code>'.format(error.name))
                        docs.add_row('{}.'.format(error.description))
                    docs.end_table()
                    docs.write_text('You can import these from '
                                    '<code>telethon.errors</code>.')

                docs.write_title('Example', id='examples')
                docs.write('''<pre>\
<strong>from</strong> telethon.sync <strong>import</strong> TelegramClient
<strong>from</strong> telethon <strong>import</strong> functions, types

<strong>with</strong> TelegramClient(name, api_id, api_hash) <strong>as</strong> client:
    result = client(''')
                tlobject.as_example(docs, indent=1)
                docs.write(')\n')
                if tlobject.result.startswith('Vector'):
                    docs.write('''\
    <strong>for</strong> x <strong>in</strong> result:
        print(x''')
                else:
                    docs.write('    print(result')
                    if tlobject.result != 'Bool' \
                            and not tlobject.result.startswith('Vector'):
                        docs.write('.stringify()')

                docs.write(')</pre>')

            depth = '../' * (2 if tlobject.namespace else 1)
            docs.add_script(src='prependPath = "{}";'.format(depth))
            docs.add_script(path=paths['search.js'])
            docs.end_body()

    # Find all the available types (which are not the same as the constructors)
    # Each type has a list of constructors associated to it, hence is a map
    for t, cs in type_to_constructors.items():
        filename = path_for_type(t)
        out_dir = filename.parent
        if out_dir:
            out_dir.mkdir(parents=True, exist_ok=True)

        # Since we don't have access to the full TLObject, split the type
        if '.' in t:
            namespace, name = t.split('.')
        else:
            namespace, name = None, t

        with DocsWriter(root, filename, path_for_type) as docs:
            docs.write_head(title=snake_to_camel_case(name),
                            css_path=paths['css'],
                            default_css=paths['default_css'])

            docs.set_menu_separator(paths['arrow'])
            _build_menu(docs)

            # Main file title
            docs.write_title(snake_to_camel_case(name))

            # List available constructors for this type
            docs.write_title('Available constructors', level=3)
            if not cs:
                docs.write_text('This type has no constructors available.')
            elif len(cs) == 1:
                docs.write_text('This type has one constructor available.')
            else:
                docs.write_text('This type has %d constructors available.' %
                                len(cs))

            docs.begin_table(2)
            for constructor in cs:
                # Constructor full name
                link = create_path_for(constructor)
                docs.add_row(constructor.class_name, link=link)
            docs.end_table()

            # List all the methods which return this type
            docs.write_title('Methods returning this type', level=3)
            functions = type_to_functions.get(t, [])
            if not functions:
                docs.write_text('No method returns this type.')
            elif len(functions) == 1:
                docs.write_text('Only the following method returns this type.')
            else:
                docs.write_text(
                    'The following %d methods return this type as a result.' %
                    len(functions)
                )

            docs.begin_table(2)
            for func in functions:
                link = create_path_for(func)
                docs.add_row(func.class_name, link=link)
            docs.end_table()

            # List all the methods which take this type as input
            docs.write_title('Methods accepting this type as input', level=3)
            other_methods = sorted(
                (u for u in tlobjects
                 if any(a.type == t for a in u.args) and u.is_function),
                key=lambda u: u.name
            )
            if not other_methods:
                docs.write_text(
                    'No methods accept this type as an input parameter.')
            elif len(other_methods) == 1:
                docs.write_text(
                    'Only this method has a parameter with this type.')
            else:
                docs.write_text(
                    'The following %d methods accept this type as an input '
                    'parameter.' % len(other_methods))

            docs.begin_table(2)
            for ot in other_methods:
                link = create_path_for(ot)
                docs.add_row(ot.class_name, link=link)
            docs.end_table()

            # List every other type which has this type as a member
            docs.write_title('Other types containing this type', level=3)
            other_types = sorted(
                (u for u in tlobjects
                 if any(a.type == t for a in u.args) and not u.is_function),
                key=lambda u: u.name
            )

            if not other_types:
                docs.write_text(
                    'No other types have a member of this type.')
            elif len(other_types) == 1:
                docs.write_text(
                    'You can find this type as a member of this other type.')
            else:
                docs.write_text(
                    'You can find this type as a member of any of '
                    'the following %d types.' % len(other_types))

            docs.begin_table(2)
            for ot in other_types:
                link = create_path_for(ot)
                docs.add_row(ot.class_name, link=link)
            docs.end_table()
            docs.end_body()

    # After everything's been written, generate an index.html per folder.
    # This will be done automatically and not taking into account any extra
    # information that we have available, simply a file listing all the others
    # accessible by clicking on their title
    for folder in ['types', 'methods', 'constructors']:
        _generate_index(root, root / folder, paths)

    _generate_index(root, root / 'methods', paths, True,
                    bot_docs_paths)

    # Write the final core index, the main index for the rest of files
    types = set()
    methods = []
    cs = []
    for tlobject in tlobjects:
        if tlobject.is_function:
            methods.append(tlobject)
        else:
            cs.append(tlobject)

        if not tlobject.result.lower() in CORE_TYPES:
            if re.search('^vector<', tlobject.result, re.IGNORECASE):
                types.add(tlobject.result.split('<')[1].strip('>'))
            else:
                types.add(tlobject.result)

    types = sorted(types)
    methods = sorted(methods, key=lambda m: m.name)
    cs = sorted(cs, key=lambda c: c.name)

    shutil.copy(str(input_res / '404.html'), str(paths['404']))
    _copy_replace(input_res / 'core.html', paths['index_all'], {
        '{type_count}': len(types),
        '{method_count}': len(methods),
        '{constructor_count}': len(tlobjects) - len(methods),
        '{layer}': layer,
    })

    def fmt(xs):
        zs = {}  # create a dict to hold those which have duplicated keys
        for x in xs:
            zs[x.class_name] = x.class_name in zs
        return ', '.join(
            '"{}.{}"'.format(x.namespace, x.class_name)
            if zs[x.class_name] and x.namespace
            else '"{}"'.format(x.class_name) for x in xs
        )

    request_names = fmt(methods)
    constructor_names = fmt(cs)

    def fmt(xs, formatter):
        return ', '.join('"{}"'.format(
            formatter(x)).replace(os.path.sep, '/') for x in xs)

    type_names = fmt(types, formatter=lambda x: x)

    # Local URLs shouldn't rely on the output's root, so set empty root
    get_path_for = functools.partial(_get_path_for, Path())

    request_urls = fmt(methods, get_path_for)
    type_urls = fmt(types, _get_path_for_type)
    constructor_urls = fmt(cs, get_path_for)

    paths['search.js'].parent.mkdir(parents=True, exist_ok=True)
    _copy_replace(input_res / 'js/search.js', paths['search.js'], {
        '{request_names}': request_names,
        '{type_names}': type_names,
        '{constructor_names}': constructor_names,
        '{request_urls}': request_urls,
        '{type_urls}': type_urls,
        '{constructor_urls}': constructor_urls
    })
564579
function plugin(options){
  options = options || {};
  var keys = options.keys || [];

  return function(files, metalsmith, done){
    setImmediate(done);
    var md = new MarkdownIt(options);
    Object.keys(files).forEach(function(file){
      if (!markdown(file)) return;
      var data = files[file];
      var dir = dirname(file);
      var html = basename(file, extname(file)) + '.html';
      if ('.' != dir) html = dir + '/' + html;

      var str = md.render(data.contents.toString());
      data.contents = new Buffer(str);
      keys.forEach(function(key) {
        data[key] = md.render(data[key]);
      });

      delete files[file];
      files[html] = data;
    });
  };
}
222605
function docmeify(htmldir, cb) {
  var outstreams =  [] 
    , pruneTransform = transformify(pruneHtml.bind(null, [ 'h1', 'h2', 'h3', 'header' ]));

  function getOutStream() {
    var s = new MutinyWritable();
    outstreams.push(s);
    return s;
  }

  function onend() {
    var apidocs = outstreams.map(function (x) { return x.apidoc }).join('');
    cb(null, apidocs);
  }
  
  log.verbose('docme', 'githubifying the jsdoc generated pages');

  mutiny(
      { getOutStream: getOutStream, transform: [ jsdocGithubify, pruneTransform ] }
    , { root: htmldir, fileFilter: '*.html' }
  )
  .on('error', cb)
  .on('data', function (d) { log.verbose('docme', 'Processed:\n', d); })
  .on('end', onend)
}
540490
function createInput(opt_text) {
    var input = document.createElement('input');
    input.type = 'text';
    input.placeholder = opt_text || '';
    holder.appendChild(input);
    return input;
  }
281198
def buildFromJsbString(self, jsb, nocompressjs=False):
        
        tempconffile = 'temp-app.jsb3'
        cmd = ['sencha', 'build', '-p', tempconffile, '-d', self.outdir]
        if nocompressjs:
            cmd.append('--nocompress')
        open(tempconffile, 'w').write(jsb)
        log.info('Running: %s', ' '.join(cmd))
        try:
            call(cmd)
        finally:
            remove(tempconffile)
874504
function create(text) {
  // Hand waving here -- not showing how this interacts with XHR or persistent
  // server-side storage.
  // Using the current timestamp + random number in place of a real id.
  var id = (+new Date() + Math.floor(Math.random() * 999999)).toString(36);
  _todos[id] = {
    id: id,
    complete: false,
    text: text
  };
}
822962
function (statusCode, text) {
                    var resp = this._response;
                    resp.writeHead(statusCode, {"Content-Type": "text/plain"});
                    resp.write([
                        "port    : " + this._options.port,
                        "method  : " + this._request.method,
                        "url     : " + this._request.url,
                        "root    : " + this._options.root,
                        "path    : " + this._filePath,
                        "headers : "
                        + JSON.stringify(this._request.headers, null, "\t\t"),
                        text
                    ].join("\n"));
                    resp.end();
                }