Patch content with extracted parts metadata

@param {string} content Module content
@param {Object} parts Extracted parts metadata
6586
function patchContent (content, parts) {
  return Object.keys(parts).reduce((content, type) => {
    let paths = parts[type].filter(({ valid }) => valid).map(({ path }) => path)
    return patchType(content, type, paths)
  }, content)
}
621547
function _cleanModulesOnElement(enabledElement) {
  const modules = store.modules;

  Object.keys(modules).forEach(function(key) {
    if (typeof modules[key].removeEnabledElementCallback === 'function') {
      modules[key].removeEnabledElementCallback(enabledElement);
    }
  });
}
585585
function runModule(module, str, replacements) {
    var pattern = module.pattern,
        replace = module.replace,
        match;

    // Reset the pattern so we can re-use it
    pattern.lastIndex = 0;

    while ((match = pattern.exec(str)) !== null) {
        replacements[match.index] = {
            oldStr: match[0],
            newStr: typeof replace === "function"? replace(match) : replace
        };
        if (pattern.global === false) {
            // if the search isn't global we need to break manually
            // because pattern.exec() will always return something
            break;
        }
    }
}
978247
public static Patch patch(String uri, String content) {
        return patch(uri, content.getBytes(), CONNECTION_TIMEOUT, READ_TIMEOUT);
    }
1263861
function patch(node) {
    var data = node.data || {};

    data.stem = stemmer(nlcstToString(node));

    node.data = data;
}
342572
function extractOriginsOfChunkWithExtractedModules(chunk, reason = 'async commons') {
  return chunk.origins.map((origins, origin) => Object.assign({}, origin, {
    reasons: (origin.reasons || []).concat(reason)
  }))
}
816606
public void addBottom(Content body) {
        Content bottom = new RawHtml(replaceDocRootDir(configuration.bottom));
        Content small = HtmlTree.SMALL(bottom);
        Content p = HtmlTree.P(HtmlStyle.legalCopy, small);
        body.addContent(p);
    }
259343
function extractModulesAndReturnAffectedChunks(reallyUsedModules, usedChunks) {
  const affectedChunksSet = new Set()
  reallyUsedModules.forEach(
    module => usedChunks.forEach(
      // removeChunk returns true if the chunk was contained and succesfully removed
      // false if the module did not have a connection to the chunk in question
      chunk => module.removeChunk(chunk) && affectedChunksSet.add(chunk)
    )
  )
  return affectedChunksSet
}
1203787
@Override
    protected void addIndex(Content body) {
        for (String groupname : groupList) {
            SortedSet<ModuleElement> list = groupModuleMap.get(groupname);
            if (list != null && !list.isEmpty()) {
                addIndexContents(list,
                        groupname, configuration.getText("doclet.Member_Table_Summary",
                                groupname, configuration.getText("doclet.modules")), body);
            }
        }
    }
727033
function buildContentByPackage(content) {
  let chunksByPackage = buildChunksByPackage(content)
  let contentByPackage = {}

  for (let packageName in chunksByPackage) {
    contentByPackage[packageName] = chunksByPackage[packageName].join('\n\n')
  }

  return contentByPackage
}
760848
protected void addIndex(Content body) {
        addIndexContents(configuration.modules, "doclet.Module_Summary",
                configuration.getText("doclet.Member_Table_Summary",
                configuration.getText("doclet.Module_Summary"),
                configuration.getText("doclet.modules")), body);
    }
343738
function saveContentToEntitlementsFile(content) {
  var plistContent = plist.build(content);
  var filePath = pathToEntitlementsFile();

  // ensure that file exists
  mkpath.sync(path.dirname(filePath));

  // save it's content
  fs.writeFileSync(filePath, plistContent, 'utf8');
}
328129
function extractMetadata (content, callback) {
  var end;
  var result;
  var metadata = '';
  var body = content;

  // Metadata is defined by either starting and ending line,
  if (content.slice(0, 3) === '---') {
    result = content.match(/^-{3,}\s([\s\S]*?)-{3,}(\s[\s\S]*|\s?)$/);
    if (result && result.length === 3) {
      metadata = result[1];
      body = result[2];
    }
  }
  // or Markdown metadata section at beginning of file.
  else if (content.slice(0, 12) === '```metadata\n') {
    end = content.indexOf('\n```\n');
    if (end !== -1) {
      metadata = content.substring(12, end);
      body = content.substring(end + 5);
    }
  }

  parseMetadata(metadata, function (error, parsed) {
    if (error) return callback(error);
    callback(null, {
      metadata: parsed,
      body: body
    });
  });
}
695565
public void addPart(AttachmentPart part) {
        if (attachments == null) {
            attachments = new BodyPart.Attachments();
        }

        this.attachments.add(part);
    }
563450
function editPartTitle(summary, index, newTitle) {
    var parts = summary.getParts();

    var part = parts.get(index);
    if (!part) {
        return summary;
    }

    part = part.set('title', newTitle);
    parts = parts.set(index, part);

    return summary.set('parts', parts);
}
987981
public function updateMetadata($contentId, MetadataUpdateStruct $content)
    {
        $this->contentGateway->updateContent($contentId, $content);
        $this->updatePathIdentificationString($contentId, $content);

        return $this->loadContentInfo($contentId);
    }
1332931
public void setContent(final WComponent content) {
		getOrCreateComponentModel().content = content;

		// There should only be one content.
		holder.removeAll();
		holder.add(content);
	}