| 461 | |
| 462 | // Used to summarize index-entries that point to the same help file |
| 463 | function 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 | } |