Skip to content

Commit 9d61a39

Browse files
authored
Disable list of other declarations in minimized mode (#778) 121218746
* Disable list of other declarations in minimized mode 121218746 Disable list of other declarations in minimized mode * clean up `hasOtherDeclarations` logic clean up `hasOtherDeclarations` logic
1 parent 940167c commit 9d61a39

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

bin/check-source

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1818

1919
function replace_acceptable_years() {
2020
# this needs to replace all acceptable forms with 'YEARS'
21-
sed -e 's/20[12][789012]-20[12][890123]/YEARS/' -e 's/20[12][890123]/YEARS/'
21+
sed -e 's/20[12][78901234]-20[12][8901234]/YEARS/' -e 's/20[12][8901234]/YEARS/'
2222
}
2323

2424
printf "=> Checking license headers… "

src/components/DocumentationTopic.vue

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
This source file is part of the Swift.org open source project
33

4-
Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
4+
Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
Licensed under Apache License v2.0 with Runtime Library Exception
66

77
See https://swift.org/LICENSE.txt for license information
@@ -539,9 +539,11 @@ export default {
539539
declarations({ primaryContentSections = [] }) {
540540
return primaryContentSections.filter(({ kind }) => kind === SectionKind.declarations);
541541
},
542-
hasOtherDeclarations({ declarations = [] }) {
543-
// there's always only 1 `declaration` at this level
544-
return declarations.length ? declarations[0].declarations.some(decl => Object.prototype.hasOwnProperty.call(decl, 'otherDeclarations')) : false;
542+
hasOtherDeclarations({ declarations = [], enableMinimized }) {
543+
// disable otherDeclarations in minimized mode
544+
return !enableMinimized && declarations.length
545+
// there's always only 1 `declaration` at this level
546+
&& declarations[0].declarations.some(decl => Object.prototype.hasOwnProperty.call(decl, 'otherDeclarations'));
545547
},
546548
declListToggleText({ declListExpanded }) {
547549
return declListExpanded ? this.$t('declarations.hide-other-declarations')

tests/unit/components/DocumentationTopic.spec.js

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* This source file is part of the Swift.org open source project
33
*
4-
* Copyright (c) 2021-2023 Apple Inc. and the Swift project authors
4+
* Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
55
* Licensed under Apache License v2.0 with Runtime Library Exception
66
*
77
* See https://swift.org/LICENSE.txt for license information
@@ -673,7 +673,7 @@ describe('DocumentationTopic', () => {
673673
});
674674
});
675675

676-
it('render an declaration list menu if has other declarations', () => {
676+
it('render a declaration list menu if has other declarations', () => {
677677
let declListMenu = wrapper.find('.declaration-list-menu');
678678
expect(declListMenu.exists()).toBe(false);
679679

@@ -687,6 +687,22 @@ describe('DocumentationTopic', () => {
687687
expect(declListMenu.exists()).toBe(true);
688688
});
689689

690+
it('does not render a declaration list menu in minimized mode', () => {
691+
wrapper.setProps({
692+
primaryContentSections: [
693+
...propsData.primaryContentSections,
694+
hasOtherDeclSection,
695+
],
696+
});
697+
let declListMenu = wrapper.find('.declaration-list-menu');
698+
expect(declListMenu.exists()).toBe(true);
699+
700+
wrapper.setProps({ enableMinimized: true });
701+
702+
declListMenu = wrapper.find('.declaration-list-menu');
703+
expect(declListMenu.exists()).toBe(false);
704+
});
705+
690706
it('renders correct declaration list toggle, text, and icon', () => {
691707
wrapper.setProps({
692708
primaryContentSections: [

0 commit comments

Comments
 (0)