From c9e01488a3d25d90a3cc7a9cafc22312cc155f2f Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Tue, 5 Nov 2019 06:59:59 +0100 Subject: [PATCH] docs: remove an unused extension of sphinx --- MANIFEST.in | 1 - docs/source/_ext/hidden_code_block.py | 128 -------------------------- tools/cmake/DefinePackages.cmake | 1 - 3 files changed, 130 deletions(-) delete mode 100644 docs/source/_ext/hidden_code_block.py diff --git a/MANIFEST.in b/MANIFEST.in index 66aaf78663..320d58964e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1768,7 +1768,6 @@ include docs/source/Start_Your_Own_Project.rst include docs/source/Tutorial_Algorithms.rst include docs/source/Tutorial_MPI_Applications.rst include docs/source/XML_Reference.rst -include docs/source/_ext/hidden_code_block.py include docs/source/_ext/showfile.py include docs/source/_templates/breadcrumbs.html include docs/source/app_msg.rst diff --git a/docs/source/_ext/hidden_code_block.py b/docs/source/_ext/hidden_code_block.py deleted file mode 100644 index a009d43226..0000000000 --- a/docs/source/_ext/hidden_code_block.py +++ /dev/null @@ -1,128 +0,0 @@ -"""Simple, inelegant Sphinx extension which adds a directive for a -highlighted code-block that may be toggled hidden and shown in HTML. -This is possibly useful for teaching courses. - -The directive, like the standard code-block directive, takes -a language argument and an optional linenos parameter. The -hidden-code-block adds starthidden and label as optional -parameters. - -Examples: - -.. hidden-code-block:: python - :starthidden: False - - a = 10 - b = a + 5 - -.. hidden-code-block:: python - :label: --- SHOW/HIDE --- - - x = 10 - y = x + 5 - -Thanks to http://www.javascriptkit.com/javatutors/dom3.shtml for -inspiration on the javascript. - -Thanks to Milad 'animal' Fatenejad for suggesting this extension -in the first place. - -Written by Anthony 'el Scopz' Scopatz, January 2012. -https://github.com/scopatz/hiddencode - -Released under the WTFPL (http://sam.zoy.org/wtfpl/). -""" - -from docutils import nodes -from docutils.parsers.rst import directives -from sphinx.directives.code import CodeBlock - -HCB_COUNTER = 0 - -js_showhide = """\ - -""" - -def nice_bool(arg): - tvalues = ('true', 't', 'yes', 'y') - fvalues = ('false', 'f', 'no', 'n') - arg = directives.choice(arg, tvalues + fvalues) - return arg in tvalues - - -class hidden_code_block(nodes.General, nodes.FixedTextElement): - pass - - -class HiddenCodeBlock(CodeBlock): - """Hidden code block is Hidden""" - - option_spec = dict(starthidden=nice_bool, - label=str, - **CodeBlock.option_spec) - - def run(self): - # Body of the method is more or less copied from CodeBlock - code = u'\n'.join(self.content) - hcb = hidden_code_block(code, code) - hcb['language'] = self.arguments[0] - hcb['linenos'] = 'linenos' in self.options - hcb['starthidden'] = self.options.get('starthidden', True) - hcb['label'] = self.options.get('label', '+ show/hide code') - hcb.line = self.lineno - return [hcb] - - -def visit_hcb_html(self, node): - """Visit hidden code block""" - global HCB_COUNTER - HCB_COUNTER += 1 - - # We want to use the original highlighter so that we don't - # have to reimplement it. However it raises a SkipNode - # error at the end of the function call. Thus we intercept - # it and raise it again later. - try: - self.visit_literal_block(node) - except nodes.SkipNode: - pass - - # The last element of the body should be the literal code - # block that was just made. - code_block = self.body[-1] - - fill_header = {'divname': 'hiddencodeblock{0}'.format(HCB_COUNTER), - 'startdisplay': 'none' if node['starthidden'] else 'block', - 'label': node.get('label'), - } - - divheader = ("""""" - """{label}
""" - '''
''' - ).format(**fill_header) - - code_block = js_showhide + divheader + code_block + "
" - - # reassign and exit - self.body[-1] = code_block - raise nodes.SkipNode - - -def depart_hcb_html(self, node): - """Depart hidden code block""" - # Stub because of SkipNode in visit - - -def setup(app): - app.add_directive('hidden-code-block', HiddenCodeBlock) - app.add_node(hidden_code_block, html=(visit_hcb_html, depart_hcb_html)) diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 7014a432f8..9ee5c6943d 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -875,7 +875,6 @@ set(DOC_SOURCES docs/requirements.txt docs/source/conf.py docs/source/Doxyfile - docs/source/_ext/hidden_code_block.py docs/source/_ext/showfile.py docs/source/_templates/breadcrumbs.html -- 2.20.1