Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
doc: get rid of sphinxcontrib.contentui
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sat, 9 Nov 2019 21:08:01 +0000 (22:08 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 10 Nov 2019 18:09:06 +0000 (19:09 +0100)
I want to modify that code too, so let's integrate it.

docs/requirements.txt
docs/source/_ext/showfile.css [new file with mode: 0644]
docs/source/_ext/showfile.js [new file with mode: 0644]
docs/source/_ext/showfile.py
docs/source/conf.py
src/plugins/host_energy.cpp
src/plugins/host_load.cpp

index ecb036b..4302bfe 100644 (file)
@@ -2,5 +2,4 @@ breathe
 sphinx>=1.8.0
 sphinx_rtd_theme
 sphinx_tabs
 sphinx>=1.8.0
 sphinx_rtd_theme
 sphinx_tabs
-sphinxcontrib.contentui
 javasphinx
 javasphinx
diff --git a/docs/source/_ext/showfile.css b/docs/source/_ext/showfile.css
new file mode 100644 (file)
index 0000000..eb44eab
--- /dev/null
@@ -0,0 +1,28 @@
+
+/**
+ *
+ */
+.toggle-tab {
+    margin-bottom: 40px;
+}
+
+.toggle-header {
+    display: block;
+    clear: both;
+    cursor: pointer;
+}
+.toggle-header p {display: inline; }
+.toggle-header strong {color: #2980b9 }
+
+.toggle-header:after {
+    content: " ▼";
+}
+
+.toggle-header.open:after {
+    content: " ▲";
+}
+
+.toggle-content {
+    display: none;
+    margin-bottom: 20px;
+}
diff --git a/docs/source/_ext/showfile.js b/docs/source/_ext/showfile.js
new file mode 100644 (file)
index 0000000..7dae2b1
--- /dev/null
@@ -0,0 +1,12 @@
+
+$(function() {
+    /**
+     * Toggle logic
+     */
+    $('.toggle-content').hide()
+    $('.toggle-header').click(function () {
+        $(this).toggleClass("open");
+        $(this).next('.toggle-content').toggle('400');
+    })
+});
+
index 39790a0..5d79a32 100644 (file)
@@ -10,6 +10,9 @@ from docutils.statemachine import StringList
 from sphinx.util.osutil import copyfile
 from sphinx.util import logging
 
 from sphinx.util.osutil import copyfile
 from sphinx.util import logging
 
+CSS_FILE = 'showfile.css'
+JS_FILE = 'showfile.js'
+
 class ShowFileDirective(Directive):
     """
     Show a file or propose it to download.
 class ShowFileDirective(Directive):
     """
     Show a file or propose it to download.
@@ -105,7 +108,48 @@ class ExampleTabDirective(Directive):
         self.state.nested_parse(self.content, self.content_offset, node)
         return node.children
 
         self.state.nested_parse(self.content, self.content_offset, node)
         return node.children
 
+class ToggleDirective(Directive):
+    has_content = True
+    option_spec = {'header': directives.unchanged}
+    optional_arguments = 1
+
+    def run(self):
+        node = nodes.container()
+        node['classes'].append('toggle-content')
+
+        par = nodes.container()
+        par['classes'].append('toggle-header')
+        if self.arguments and self.arguments[0]:
+            par['classes'].append(self.arguments[0])
+
+        self.state.nested_parse(StringList([self.options["header"]]), self.content_offset, par)
+        self.state.nested_parse(self.content, self.content_offset, node)
+
+        return [par, node]
+
+def add_assets(app):
+    app.add_stylesheet(CSS_FILE)
+    app.add_javascript(JS_FILE)
+
+
+def copy_assets(app, exception):
+    if app.builder.name not in ['html', 'readthedocs'] or exception:
+        return
+    logger = logging.getLogger(__name__)
+    logger.info('Copying showfile stylesheet/javascript... ', nonl=True)
+    dest = os.path.join(app.builder.outdir, '_static', CSS_FILE)
+    source = os.path.join(os.path.abspath(os.path.dirname(__file__)), CSS_FILE)
+    copyfile(source, dest)
+    dest = os.path.join(app.builder.outdir, '_static', JS_FILE)
+    source = os.path.join(os.path.abspath(os.path.dirname(__file__)), JS_FILE)
+    copyfile(source, dest)
+    logger.info('done')
+
 def setup(app):
 def setup(app):
+    app.add_directive('toggle-header', ToggleDirective)
     app.add_directive('showfile', ShowFileDirective)
     app.add_directive('example-tab', ExampleTabDirective)
 
     app.add_directive('showfile', ShowFileDirective)
     app.add_directive('example-tab', ExampleTabDirective)
 
+    app.connect('builder-inited', add_assets)
+    app.connect('build-finished', copy_assets)
+
index fe63c21..1839d11 100644 (file)
@@ -54,7 +54,6 @@ extensions = [
     'sphinx.ext.intersphinx',
     'sphinx.ext.autosummary',
     'sphinx_tabs.tabs',
     'sphinx.ext.intersphinx',
     'sphinx.ext.autosummary',
     'sphinx_tabs.tabs',
-    'sphinxcontrib.contentui',
     'javasphinx',
     'showfile',
     'autodoxy',
     'javasphinx',
     'showfile',
     'autodoxy',
index 5cbb75c..45d75ed 100644 (file)
@@ -18,7 +18,7 @@ SIMGRID_REGISTER_PLUGIN(host_energy, "Cpu energy consumption.", &sg_host_energy_
 
 /** @defgroup plugin_host_energy
 
 
 /** @defgroup plugin_host_energy
 
-  @rst
+  @beginrst
 This is the energy plugin, enabling to account not only for computation time, but also for the dissipated energy in the
 simulated platform.
 To activate this plugin, first call :cpp:func:`sg_host_energy_plugin_init()` before your :cpp:func:`MSG_init()`, and then use
 This is the energy plugin, enabling to account not only for computation time, but also for the dissipated energy in the
 simulated platform.
 To activate this plugin, first call :cpp:func:`sg_host_energy_plugin_init()` before your :cpp:func:`MSG_init()`, and then use
index 73debe7..3885580 100644 (file)
@@ -14,7 +14,7 @@ SIMGRID_REGISTER_PLUGIN(host_load, "Cpu load", &sg_host_load_plugin_init)
 
 /** @defgroup plugin_host_load
 
 
 /** @defgroup plugin_host_load
 
-  @rst
+  @beginrst
 
 Simple plugin that monitors the current load for each host.
 
 
 Simple plugin that monitors the current load for each host.