https://github.com/sinatra/sinatra-book/blob/master/book/Organizing_your_application.markdown
15545
def generate_app
      copy_templates
      app = File.read File.expand_path("../templates/app.erb", __FILE__)
      erb = ERB.new app, 0, '-'

      File.open "#{@destination}/#{@app_name}.rb", "w" do |f|
        f.write erb.result(binding)
      end

      route = File.read File.expand_path("../templates/app/routes/home.erb", __FILE__)
      erb = ERB.new route, 0, '-'

      File.open "#{@destination}/app/routes/home.rb", "w" do |f|
        f.write erb.result(binding)
      end

      FileUtils.rm "#{@destination}/app/routes/home.erb"
    end
352887
function (type, group) {
    return _.map(assetFiles(type, group), function (file) {
        return toHtml(type, path.join(config.root, fss.relative(file)));
    }).join('\n');
}
279159
def fields(markdown)
      fields = []
      if markdown.file
        fields.push(title: 'file',
                    value: markdown.file,
                    short: true)
      end
      if markdown.line
        fields.push(title: 'line',
                    value: markdown.line,
                    short: true)
      end
      fields
    end
71863
def main(app):
    
    c = app.config
    src = c.jinjaapi_srcdir

    if not src:
        return

    suffix = "rst"

    out = c.jinjaapi_outputdir or app.env.srcdir

    if c.jinjaapi_addsummarytemplate:
        tpath = pkg_resources.resource_filename(__package__, AUTOSUMMARYTEMPLATE_DIR)
        c.templates_path.append(tpath)

    tpath = pkg_resources.resource_filename(__package__, TEMPLATE_DIR)
    c.templates_path.append(tpath)

    prepare_dir(app, out, not c.jinjaapi_nodelete)
    generate(app, src, out,
             exclude=c.jinjaapi_exclude_paths,
             force=c.jinjaapi_force,
             followlinks=c.jinjaapi_followlinks,
             dryrun=c.jinjaapi_dryrun,
             private=c.jinjaapi_includeprivate,
             suffix=suffix,
             template_dirs=c.templates_path)
510609
def compile(src)
      src = src.read() if src.respond_to?(:read)
      markdown = Redcarpet::Markdown.new(renderer, markdown_options)
      rendered = markdown.render(src)
      return rendered
    end
1220432
def link_markdown_cells(cells, modules):
    ""
    for i, cell in enumerate(cells):
        if cell['cell_type'] == 'markdown':
            cell['source'] = link_docstring(modules, cell['source'])
1054424
function(files, mode) {
				var place    = list ? cwd.find('tbody') : cwd,
					l        = files.length, 
					atmb     = {},
					findNode = function(file) {
						var pointer = cwd.find('[id]:first'), file2;

						while (pointer.length) {
							file2 = fm.file(fm.cwdId2Hash(pointer.attr('id')));
							if (!pointer.hasClass('elfinder-cwd-parent') && file2 && fm.compare(file, file2) < 0) {
								return pointer;
							}
							pointer = pointer.next('[id]');
						}
					},
					findIndex = function(file) {
						var l = buffer.length, i;
						
						for (i =0; i < l; i++) {
							if (fm.compare(file, buffer[i]) < 0) {
								return i;
							}
						}
						return l || -1;
					},
					// created document fragment for jQuery >= 1.12, 2.2, 3.0
					// see Studio-42/elFinder#1544 @ github
					docFlag = $.htmlPrefilter? true : false,
					tempDom = docFlag? $(document.createDocumentFragment()) : $('<div/>'),
					file, hash, node, nodes, ndx;

				if (l > showFiles) {
					// re-render for performance tune
					content();
					selectedFiles = fm.arrayFlip($.map(files, function(f) { return f.hash; }), true);
					trigger();
				} else {
					// add the item immediately
					l && wz.removeClass('elfinder-cwd-wrapper-empty');
					
					while (l--) {
						file = files[l];
						hash = file.hash;
						
						if ($('#'+fm.cwdHash2Id(hash)).length) {
							continue;
						}
						
						if ((node = findNode(file)) && ! node.length) {
							node = null;
						}
						if (! node && (ndx = findIndex(file)) >= 0) {
							buffer.splice(ndx, 0, file);
						} else {
							tempDom.empty().append(itemhtml(file));
							(file.mime === 'directory') && !mobile && makeDroppable(tempDom);
							nodes = docFlag? tempDom : tempDom.children();
							if (node) {
								node.before(nodes);
							} else {
								place.append(nodes);
							}
						}
						
						if ($('#'+fm.cwdHash2Id(hash)).length) {
							if (file.tmb) {
								atmb[hash] = file.tmb;
							}
						}
					}
	
					if (list) {
						setColwidth();
						fixTableHeader({fitWidth: ! colWidth});
					}
					bottomMarkerShow(place);
					if (Object.keys(atmb).length) {
						Object.assign(bufferExt.attachTmbs, atmb);
					}
				}
			}
1338716
def intermediary_to_markdown(tables, relationships, output):
    
    er_markup = _intermediary_to_markdown(tables, relationships)
    with open(output, "w") as file_out:
        file_out.write(er_markup)
196792
def _run_markdownlint(matched_filenames, show_lint_files):
    """"""
    from prospector.message import Message, Location

    for filename in matched_filenames:
        _debug_linter_status("mdl", filename, show_lint_files)

    try:
        proc = subprocess.Popen(["mdl"] + matched_filenames,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE)
        lines = proc.communicate()[0].decode().splitlines()
    except OSError as error:
        if error.errno == errno.ENOENT:
            return []

    lines = [
        re.match(r"([\w\-.\/\\ ]+)\:([0-9]+)\: (\w+) (.+)", l).groups(1)
        for l in lines
    ]
    return_dict = dict()
    for filename, lineno, code, msg in lines:
        key = _Key(filename, int(lineno), code)
        loc = Location(filename, None, None, int(lineno), 0)
        return_dict[key] = Message("markdownlint", code, loc, msg)

    return return_dict
80524
def rst2markdown_github(path_to_rst, path_to_md, pandoc="pandoc"):
    
    _proc = subprocess.Popen([pandoc, "-f", "rst",
                              "-t", "markdown_github",
                              #"-o", path_to_md,
                              path_to_rst],
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
    print("Converting README.rst to markdown_github, "
          "using 'pandoc' ...")
    _stdout, _stderr = _proc.communicate()
    with _open(path_to_md, "w", encoding="utf-8") as _md:
        _skip_newline = False
        for line in _stdout.decode('utf-8').split(os.linesep):
            line = re.sub("``` sourceCode", "``` python", line)
            if line.startswith("[!["):
                _md.write(line)
                _md.write("\n")
                if not line.startswith(("[![LICENSE")):
                    _skip_newline = True
            elif _skip_newline and line == "":
                _skip_newline = False
                continue
            else:
                _md.write(line)
                _md.write("\n")

    if _stderr:
        print("pandoc.exe STDERR: ", _stderr)
    if os.path.isfile(path_to_md) and os.stat(path_to_md).st_size > 0:
        print("README.rst converted and saved as: {}".format(path_to_md))
114459
function provideAppMethods(model, methodsProto) {
  /*jshint immed:false */
  var key, method,
      cname = inflect.camelize(model.context),
      scname = inflect.singularize(cname),
      Application = app.constructor;
      
  var pluralize = /^(get|find|delete|destroy)$/
      
  for (key in methodsProto) {
    var suffix = (key.slice(-3) === 'All') ? cname : scname;
    method = key + suffix;
    (function(model, key, method) {
      app.model[method] = function() {
        model[key].apply(model, arguments);
      }
      if (pluralize.test(key)) {
        app.model[key + inflect.pluralize(suffix)] = app.model[method];
      }
    }).call(this, model, key, method);
  }
}
1264369
def associations
      {
        css:    ['css'],
        scss:   ['scss', 'sass'],
        js:     ['js'],
        ruby:   ['rb', 'Gemfile', 'lock', 'yml', 'Rakefile', 'ru', 'rdoc', 'rake', 'Capfile', 'jbuilder'],
        rails:  ['slim', 'haml', 'jbuilder', 'erb'],
        images: ['png', 'jpg', 'jpeg', 'gif'],
        static: ['pdf', 'txt', 'doc', 'docx', 'csv', 'xls', 'xlsx'],
        markup: ['html', 'xml', 'xhtml'],
        markdown: ['md', 'markdown', 'mdown'],
        php:    ['php', 'ini']
      }
    end
389027
function markdown(text, inline) {
    var r;

    if (text !== undefined)
      r = md_conrefs.replaceConref(text);

    else
      r = "";

    r = namp(r).html;

    // inline markdown means to strip enclosing tag, which in this case is <p>
    if (inline === true) {
        r = r.slice(3, -5);
    }

    // FIXME
    // desugar [[foo#bar]] tokens into local links
    // N.B. in order to not apply conversion in <code> blocks,
    // we first store replace code blocks with nonces
    var codes = {};
    r = r.replace(/(<code>[\s\S]*?<\/code>)/g, function (all, def) {
      var nonce = Math.random().toString().substring(2);
      codes[nonce] = def;
      return '@-=@=-@' + nonce + '@-=@=-@';
    });

    // convert [[link]] to links
    r = r.replace(/\[\[([\s\S]+?)\]\]/g, function (all, def) {
      def = def.split(/\s+/);
      id = def.shift();
      // invalid references don't produce links
      /*if (!list[id]) {// it's in a different file--list only refers to current page
          obj = fullList[id];

          if (obj === undefined) { // it might be global
              obj = {};
              obj.id = id;
          }
      }*/
      //else {
          obj = list[id];
      //}

      var obj = _.extend({name: def.join(' ') || id, globalId: id}, list[id]);
      obj.name = def.join(' ') || id;

      // lame, but I'm tired of writing stuff like [[child_process.fork `child_process.fork()`]]
      // If I didn't do this, it'd come out as an unstyled link
      if (def.length == 0) {
        if (obj.type === undefined && additionalObjsJSON[obj.name] === undefined && obj.name !== "Mixed") {
          console.error("Error".red + ": you tried to create a short link to an object that doesn't exist!");
          console.error(obj);
        } 

        if (additionalObjsJSON[obj.name] !== undefined)
          obj.name = "<code>" + obj.name + "</code>";
        else if (obj.type && obj.type !== "class" && obj.type.indexOf("property") < 0)
          obj.name = "<code>" + obj.name + "()</code>";
        else
          obj.name = "<code>" + obj.name + "</code>";
      }

      return link(obj, ['link-short'], true);
    });

    // restore code blocks, given previously stored nonces
    r = r.replace(/@-=@=-@(\d+)@-=@=-@/g, function (all, nonce) {
      return codes[nonce];
    });

    return r;
  }
511968
public StringBuffer markdown(SchemaMetadata meta, boolean include_input_fields, boolean include_output_fields) {
    MarkdownBuilder builder = new MarkdownBuilder();

    builder.comment("Preview with http://jbt.github.io/markdown-editor");
    builder.heading1("schema ", this.getClass().getSimpleName());
    builder.hline();
    // builder.paragraph(metadata.summary);

    // TODO: refactor with Route.markdown():

    // fields
    boolean first; // don't print the table at all if there are no rows

    try {
      if (include_input_fields) {
        first = true;
        builder.heading2("input fields");

        for (SchemaMetadata.FieldMetadata field_meta : meta.fields) {
          if (field_meta.direction == API.Direction.INPUT || field_meta.direction == API.Direction.INOUT) {
            if (first) {
              builder.tableHeader("name", "required?", "level", "type", "schema?", "schema", "default", "description", "values", "is member of frames", "is mutually exclusive with");
              first = false;
            }
            builder.tableRow(
                field_meta.name,
                String.valueOf(field_meta.required),
                field_meta.level.name(),
                field_meta.type,
                String.valueOf(field_meta.is_schema),
                field_meta.is_schema ? field_meta.schema_name : "", (null == field_meta.value ? "(null)" : field_meta.value.toString()), // Something better for toString()?
                field_meta.help,
                (field_meta.values == null || field_meta.values.length == 0 ? "" : Arrays.toString(field_meta.values)),
                (field_meta.is_member_of_frames == null ? "[]" : Arrays.toString(field_meta.is_member_of_frames)),
                (field_meta.is_mutually_exclusive_with == null ? "[]" : Arrays.toString(field_meta.is_mutually_exclusive_with))
            );
          }
        }
        if (first)
          builder.paragraph("(none)");
      }

      if (include_output_fields) {
        first = true;
        builder.heading2("output fields");
        for (SchemaMetadata.FieldMetadata field_meta : meta.fields) {
          if (field_meta.direction == API.Direction.OUTPUT || field_meta.direction == API.Direction.INOUT) {
            if (first) {
              builder.tableHeader("name", "type", "schema?", "schema", "default", "description", "values", "is member of frames", "is mutually exclusive with");
              first = false;
            }
            builder.tableRow(
                field_meta.name,
                field_meta.type,
                String.valueOf(field_meta.is_schema),
                field_meta.is_schema ? field_meta.schema_name : "",
                (null == field_meta.value ? "(null)" : field_meta.value.toString()), // something better than toString()?
                field_meta.help,
                (field_meta.values == null || field_meta.values.length == 0 ? "" : Arrays.toString(field_meta.values)),
                (field_meta.is_member_of_frames == null ? "[]" : Arrays.toString(field_meta.is_member_of_frames)),
                (field_meta.is_mutually_exclusive_with == null ? "[]" : Arrays.toString(field_meta.is_mutually_exclusive_with)));
          }
        }
        if (first)
          builder.paragraph("(none)");
      }

      // TODO: render examples and other stuff, if it's passed in
    }
    catch (Exception e) {
      IcedHashMapGeneric.IcedHashMapStringObject values = new IcedHashMapGeneric.IcedHashMapStringObject();
      values.put("schema", this);
      // TODO: This isn't quite the right exception type:
      throw new H2OIllegalArgumentException("Caught exception using reflection on schema: " + this,
          "Caught exception using reflection on schema: " + this + ": " + e,
          values);
    }
    return builder.stringBuffer();
  }
1009020
def compile_markdown_file(source_file):
  ''''''
  template = pkg_resources.resource_string('md2remark.resources.templates', 'slideshow.mustache')

  renderer = pystache.Renderer(search_dirs='./templates')

  f = open(source_file, 'r')
  slideshow_md = f.read()
  f.close()
  slideshow_name = os.path.split(source_file)[1].split('.')[0]

  rendered_text = renderer.render(template, {'title': slideshow_name, 'slideshow': slideshow_md})  

  if not os.path.exists('md2remark_build'):
    os.makedirs('md2remark_build')
  
  f = open(os.path.join('md2remark_build', slideshow_name + '.html'), 'w')
  f.write(rendered_text)
  f.close()
339
function mdlPublish(pubScope) {
  let cacheTtl = null;
  let src = null;
  let dest = null;

  if (pubScope === 'staging') {
    // Set staging specific vars here.
    cacheTtl = 0;
    src = 'dist/*';
    dest = bucketStaging;
  } else if (pubScope === 'prod') {
    // Set prod specific vars here.
    cacheTtl = 60;
    src = 'dist/*';
    dest = bucketProd;
  } else if (pubScope === 'promote') {
    // Set promote (essentially prod) specific vars here.
    cacheTtl = 60;
    src = `${bucketStaging}/*`;
    dest = bucketProd;
  }

  let infoMsg = `Publishing ${pubScope}/${pkg.version} to GCS (${dest})`;
  if (src) {
    infoMsg += ` from ${src}`;
  }
  console.log(infoMsg);

  // Build gsutil commands:
  // The gsutil -h option is used to set metadata headers.
  // The gsutil -m option requests parallel copies.
  // The gsutil -R option is used for recursive file copy.
  const cacheControl = `-h "Cache-Control:public,max-age=${cacheTtl}"`;
  const gsutilCacheCmd = `gsutil -m setmeta ${cacheControl} ${dest}/**`;
  const gsutilCpCmd = `gsutil -m cp -r -z html,css,js,svg ${src} ${dest}`;

  gulp.src('').pipe($.shell([gsutilCpCmd, gsutilCacheCmd]));
}
368771
def markdown(text)
      @renderer ||= Redcarpet::Markdown.new(ExternalLinks, no_intra_emphasis: true)
      smartify(@renderer.render(text))
    end