MCPcopy Create free account
hub / github.com/REditorSupport/vscode-R / summarizeTopics

Function summarizeTopics

src/helpViewer/packages.ts:463–486  ·  view source on GitHub ↗
(topics: Topic[])

Source from the content-addressed store, hash-verified

461
462// Used to summarize index-entries that point to the same help file
463function summarizeTopics(topics: Topic[]): Topic[] {
464 const topicMap = new Map<string, Topic>();
465 for(const topic of topics){
466 if(topicMap.has(topic.helpPath)){
467 const newTopic = <Topic>topicMap.get(topic.helpPath); // checked above that key is present
468 if(newTopic.aliases){
469 newTopic.aliases.push(topic.name);
470 }
471 // newTopic.topicType ||= topic.topicType;
472 newTopic.type = (newTopic.type === TopicType.NORMAL ? topic.type : newTopic.type);
473 } else{
474 const newTopic: Topic = {
475 ...topic,
476 };
477 if(newTopic.type === TopicType.NORMAL && newTopic.description){
478 newTopic.aliases = [newTopic.name];
479 [newTopic.name, newTopic.description] = [newTopic.description, newTopic.name];
480 }
481 topicMap.set(newTopic.helpPath, newTopic);
482 }
483 }
484 const newTopics = [...topicMap.values()];
485 return newTopics;
486}

Callers 1

getTopicsMethod · 0.85

Calls 2

hasMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected