diff --git a/conf.py b/conf.py index de9321e3d..0c3c36286 100644 --- a/conf.py +++ b/conf.py @@ -121,9 +121,6 @@ extensions = [ # Redirection generator 'redirects', - # Code switcher (switcher and case directives) - 'switcher', - # Content tabs 'sphinx_tabs.tabs', diff --git a/extensions/odoo_theme/static/style.scss b/extensions/odoo_theme/static/style.scss index 04620701c..ad804131e 100644 --- a/extensions/odoo_theme/static/style.scss +++ b/extensions/odoo_theme/static/style.scss @@ -512,25 +512,6 @@ header.o_main_header { max-width: 100%; } - .content-switcher { - .nav-tabs .nav-link.active { - background-color: #f8f8f8; - border-color: #dee2e6 #dee2e6 #f8f8f8; - font-weight: $fw_semibold; - } - - .tab-content { - background: $doc_code-bg; - border: 1px $gray-300 solid; - border-top: 0; - - div[class^="highlight"] { - border: 0; - margin: 0; - } - } - } - @include media-breakpoint-up(xl) { width: 100%; padding-right: 0; diff --git a/extensions/switcher/__init__.py b/extensions/switcher/__init__.py deleted file mode 100644 index d71316786..000000000 --- a/extensions/switcher/__init__.py +++ /dev/null @@ -1,65 +0,0 @@ -import os.path - -from docutils import nodes -from docutils.parsers.rst import Directive - -from pygments.lexers import get_lexer_by_name - - -def setup(app): - app.add_directive('switcher', SwitcherDirective) - app.add_directive('case', CaseDirective) - - app.connect('env-updated', add_statics) - - return { - 'parallel_read_safe': True, - 'parallel_write_safe': True - } - -def add_statics(app, env): - app.add_js_file('js/switcher.js') - env.config.html_static_path.append(statics()) - - -statics = lambda *p: os.path.join( - os.path.abspath(os.path.dirname(__file__)), - 'static', *p) - - -class SwitcherDirective(Directive): - has_content = True - - def run(self): - self.assert_has_content() - - body = nodes.compound('\n'.join(self.content), classes=['tab-content']) - self.state.nested_parse(self.content, self.content_offset, body) - - titles = [] - for child in body.children: - if isinstance(child, nodes.literal_block): - titles.append(get_lexer_by_name(child['language']).name) - else: - assert child['names'], ( - "A switcher case must be either a code block or a compound with a name" - ) - titles.append(' '.join(child['names'])) - tabs = nodes.bullet_list('', *[ - nodes.list_item('', nodes.Text(title), classes=['nav-link']) - for title in titles - ], classes=['nav nav-tabs'] ) - node = nodes.compound('', tabs, body, classes=['content-switcher']) - return [node] - - -class CaseDirective(Directive): - required_arguments = 1 - final_argument_whitespace = True - has_content = True - - def run(self): - self.assert_has_content() - node = nodes.compound('\n'.join(self.content), names=[self.arguments[0]]) - self.state.nested_parse(self.content, self.content_offset, node) - return [node] diff --git a/extensions/switcher/static/js/switcher.js b/extensions/switcher/static/js/switcher.js deleted file mode 100644 index 41797af51..000000000 --- a/extensions/switcher/static/js/switcher.js +++ /dev/null @@ -1,36 +0,0 @@ -(function ($) { - - // TODO EDI custom css for content-switcher logic - // can be placed as css inside the extension ideally - document.addEventListener('DOMContentLoaded', function () { - document.querySelectorAll('.content-switcher').forEach(switcher => { - const links = switcher.querySelectorAll('ul li'); - const linksArray = Array.from(links); - const tabs = switcher.querySelectorAll('.tab-content > div'); - - tabs.forEach(tab => { - tab.classList.add('tab-pane'); - }); - - function select(index) { - links.forEach(link => { - link.classList.remove('active'); - }); - tabs.forEach(tab => { - tab.classList.remove('active'); - }); - links[index].classList.add('active'); - tabs[index].classList.add('active'); - } - - select(0); - links.forEach(link => { - link.addEventListener('click', ev => { - // const clickedLink = ev.target.closest('ul li'); - select(linksArray.indexOf(link)); - }); - }); - }); - }); - -})();