Skip to content

Commit 15d7887

Browse files
authored
Omit Mentioned In section on module pages (#811)
rdar://125512559
1 parent b980a6b commit 15d7887

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

src/components/DocumentationTopic.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@
171171

172172
<script>
173173
import Language from 'docc-render/constants/Language';
174+
import SymbolKind from 'docc-render/constants/SymbolKind';
174175
import metadata from 'theme/mixins/metadata';
175176
import { buildUrl } from 'docc-render/utils/url-helper';
176177
import { normalizeRelativePath } from 'docc-render/utils/assets';
@@ -494,7 +495,7 @@ export default {
494495
) {
495496
return false;
496497
}
497-
return symbolKind ? (symbolKind === 'module') : true;
498+
return symbolKind ? (symbolKind === SymbolKind.module) : true;
498499
},
499500
shortHero: ({
500501
roleHeading,
@@ -572,8 +573,13 @@ export default {
572573
topicState.contentWidth > ON_THIS_PAGE_CONTAINER_BREAKPOINT
573574
),
574575
disableMetadata: ({ enableMinimized }) => enableMinimized,
575-
primaryContentSectionsSanitized({ primaryContentSections = [] }) {
576-
return primaryContentSections.filter(({ kind }) => kind !== SectionKind.declarations);
576+
primaryContentSectionsSanitized({ primaryContentSections = [], symbolKind }) {
577+
return primaryContentSections.filter(({ kind }) => {
578+
if (kind === SectionKind.mentions) {
579+
return symbolKind !== SymbolKind.module;
580+
}
581+
return kind !== SectionKind.declarations;
582+
});
577583
},
578584
declarations({ primaryContentSections = [] }) {
579585
return primaryContentSections.filter(({ kind }) => kind === SectionKind.declarations);

src/constants/SymbolKind.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ export default {
1717
protocol: 'protocol',
1818
struct: 'struct',
1919
uid: 'uid',
20+
module: 'module',
2021
};

tests/unit/components/DocumentationTopic.spec.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import DocumentationTopic from 'docc-render/components/DocumentationTopic.vue';
1313
import Language from 'docc-render/constants/Language';
1414
import InlinePlusCircleIcon from 'docc-render/components/Icons/InlinePlusCircleIcon.vue';
1515
import { TopicTypes } from '@/constants/TopicTypes';
16+
import SymbolKind from '@/constants/SymbolKind';
1617
import DocumentationHero from '@/components/DocumentationTopic/Hero/DocumentationHero.vue';
1718
import { TopicSectionsStyle } from '@/constants/TopicSectionsStyle';
1819
import OnThisPageNav from '@/components/OnThisPageNav.vue';
@@ -368,6 +369,37 @@ describe('DocumentationTopic', () => {
368369
expect(hierarchy.exists()).toBe(false);
369370
});
370371

372+
it('only creates a "Mentioned In" section for non-module pages', () => {
373+
const mentionSection = {
374+
kind: PrimaryContent.constants.SectionKind.mentions,
375+
mentions: [
376+
'topic://foo',
377+
'topic://bar',
378+
],
379+
};
380+
381+
wrapper.setProps({
382+
references: hierarchyItemsReferences,
383+
role: TopicTypes.symbol,
384+
symbolKind: SymbolKind.protocol,
385+
primaryContentSections: [
386+
mentionSection,
387+
foo,
388+
],
389+
});
390+
391+
expect(wrapper.find(PrimaryContent).props()).toHaveProperty('sections', [
392+
mentionSection,
393+
foo,
394+
]);
395+
396+
wrapper.setProps({
397+
symbolKind: SymbolKind.module,
398+
});
399+
400+
expect(wrapper.find(PrimaryContent).props()).toHaveProperty('sections', [foo]);
401+
});
402+
371403
it('renders `Hierarchy` without its immediate parent if its within overload group', () => {
372404
wrapper.setProps({
373405
references: hierarchyItemsReferences,

0 commit comments

Comments
 (0)