lib/Preview.js
function generateEmbed(config, file) {
  const targetPath = path.join(config.destDir, path.relative(config.src, file));
  const document = parseDocument(file);
  const sampleSections = document.sections.filter(
    s => s.inBody && !s.isEmptyCodeSection()
  );
  sampleSections.forEach((section, index) => {
    highlight(section.codeSnippet()).then(code => {
      const tag = section.doc ? slug(section.doc.toLowerCase()) : index;
      const context = {
        sample: {
          file: path.basename(targetPath),
          preview: addFlag(targetPath, tag, 'preview'),
          embed: addFlag(targetPath, tag, 'embed'),
          template: addFlag(targetPath, tag, 'template'),
          body: section.code,
          code: code,
        },
        config: config,
        document: document,
      };
      generate(context.sample.preview, templates.preview, context, /* minify */ true);
      generate(context.sample.embed, templates.embed, context, /* minify */ true);
      generateTemplate(context);
    });
  });
}
function generateEmbed(config, file) {
  const targetPath = path.join(config.destDir, path.relative(config.src, file));
  const document = parseDocument(file);
  const sampleSections = document.sections.filter(
    s => s.inBody && !s.isEmptyCodeSection()
  );
  sampleSections.forEach((section, index) => {
    highlight(section.codeSnippet()).then(code => {
      const tag = section.doc ? slug(section.doc.toLowerCase()) : index;
      const context = {
        sample: {
          file: path.basename(targetPath),
          preview: addFlag(targetPath, tag, 'preview'),
          embed: addFlag(targetPath, tag, 'embed'),
          template: addFlag(targetPath, tag, 'template'),
          body: section.code,
          code: code,
        },
        config: config,
        document: document,
      };
      generate(context.sample.preview, templates.preview, context, /* minify */ true);
      generate(context.sample.embed, templates.embed, context, /* minify */ true);
      generateTemplate(context);
    });
  });
}
function generateEmbed ( config , file ) { const targetPath = path . join ( config . destDir , path . relative ( config . src , file ) ) ; const document = parseDocument ( file ) ; const sampleSections = document . sections . filter ( s => s . inBody && ! s . isEmptyCodeSection ( ) ) ; sampleSections . forEach ( ( section , index ) => { highlight ( section . codeSnippet ( ) ) . then ( code => { const tag = section . doc ? slug ( section . doc . toLowerCase ( ) ) : index ; const context = { sample : { file : path . basename ( targetPath ) , preview : addFlag ( targetPath , tag , 'preview' ) , embed : addFlag ( targetPath , tag , 'embed' ) , template : addFlag ( targetPath , tag , 'template' ) , body : section . code , code : code , } , config : config , document : document , } ; generate ( context . sample . preview , templates . preview , context , /* minify */ true ) ; generate ( context . sample . embed , templates . embed , context , /* minify */ true ) ; generateTemplate ( context ) ; } ) ; } ) ; }
Generates embeds for a given file.
Generates embeds for a given file .