From: Martin Quinson Date: Tue, 19 Nov 2019 00:13:06 +0000 (+0100) Subject: Merge branch 'xbt_random' into 'master' X-Git-Tag: v3.25~386 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/5089a0a98b27f5eeee62321dff4f025f1648f025?hp=92b61e41082d8e54e25b87d7d1b772f0447e4802 Merge branch 'xbt_random' into 'master' A module for RNG calls See merge request simgrid/simgrid!20 --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9b9b09bfb8..7c355ce85a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,17 +1,17 @@ image: simgrid/build-deps -stages: - - build - - test +#stages: +# - build +# - test pages: - stage: test +# stage: test script: - cmake -Denable_model-checking=OFF -Denable_documentation=ON -Denable_compile_optimizations=OFF -Denable_smpi=OFF -Dpython=ON . - make -j4 - pip3 install --requirement docs/requirements.txt - cd docs - - LC_ALL=C.UTF-8 ./Build.sh + - LC_ALL=C.UTF-8 SPHINXOPTS=-vv ./Build.sh - mv build/html ../public # - The CSS contains a reference to a font or something, not something we gonna fix on our side # - The javasphinx output does not exist in the git, so the "edit on FramaGit" link is broken. @@ -27,7 +27,7 @@ pages: - master ctest: - stage: build +# stage: build except: - stable script: @@ -36,7 +36,7 @@ ctest: pip: image: debian:testing - stage: build +# stage: build except: - stable script: @@ -45,7 +45,7 @@ pip: - cd dist && tar xfz simgrid*.tar.gz && cd simgrid-*/ && python3 setup.py build release: - stage: build +# stage: build only: - stable script: diff --git a/ChangeLog b/ChangeLog index d665a77279..5ead4c98ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,9 +2,27 @@ SimGrid (3.24.1) NOT RELEASED YET (v3.25 expected December 22. 2029, 04:19 UTC) +S4U: +- Actor: Merge signals on_migration_start/end into on_host_change +- Actor: Rename migrate() into set_host() + +XML: +- Parse errors now raise a simgrid::ParseError that you may want to catch. + +Kernel: +- In simgrid::kernel::resource::Model, the methods next_occuring_event*() have + been renamed to fix a spelling error. As usual, the previous definitions are + kept with a deprecation warning. However, to avoid runtime errors, it is now + forbidden to override these deprecated methods in a derived class. Please use + the new names immediately if you need to override them. + +XBT: +- Remove unused parameter 'free_ctn' for xbt_dict_set() and xbt_dict_set_ext(). + Fixed bugs (FG#.. -> framagit bugs; FG!.. -> framagit merge requests): - GH#31: [MC] please provide an option to make MPI_Send asynchronous - - GH#305: Unscheduled tasks are still excuted + - GH#305: Unscheduled tasks are still excuted + - GH#323: Crash when an actor turn off his physical host - FG!19: Removing RngStream ---------------------------------------------------------------------------- diff --git a/MANIFEST.in b/MANIFEST.in index d0d6fa9ba3..af8fabfca3 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -273,7 +273,6 @@ include examples/python/exec-dvfs/exec-dvfs.py include examples/python/exec-dvfs/exec-dvfs.tesh include examples/python/exec-remote/exec-remote.py include examples/python/exec-remote/exec-remote.tesh -include examples/s4u/README.rst include examples/s4u/actor-create/s4u-actor-create.cpp include examples/s4u/actor-create/s4u-actor-create.tesh include examples/s4u/actor-create/s4u-actor-create_d.xml @@ -690,8 +689,6 @@ include teshsuite/s4u/activity-lifecycle/activity-lifecycle.tesh include teshsuite/s4u/activity-lifecycle/testing_platform.xml include teshsuite/s4u/actor-autorestart/actor-autorestart.cpp include teshsuite/s4u/actor-autorestart/actor-autorestart.tesh -include teshsuite/s4u/actor-migration/actor-migration.cpp -include teshsuite/s4u/actor-migration/actor-migration.tesh include teshsuite/s4u/actor/actor.cpp include teshsuite/s4u/actor/actor.tesh include teshsuite/s4u/cloud-interrupt-migration/cloud-interrupt-migration.cpp @@ -831,6 +828,8 @@ include teshsuite/smpi/coll-scatter/coll-scatter.c include teshsuite/smpi/coll-scatter/coll-scatter.tesh include teshsuite/smpi/fort_args/fort_args.f90 include teshsuite/smpi/fort_args/fort_args.tesh +include teshsuite/smpi/gh-139/gh-139.c +include teshsuite/smpi/gh-139/gh-139.tesh include teshsuite/smpi/hostfile include teshsuite/smpi/hostfile_cluster include teshsuite/smpi/hostfile_coll @@ -1747,6 +1746,7 @@ include doc/doxygen/uhood.doc include doc/doxygen/uhood_arch.doc include doc/doxygen/uhood_switch.doc include docs/Build.sh +include docs/find-missing.py include docs/ignored_symbols include docs/manpages/smpicc.1 include docs/manpages/smpicxx.1 @@ -1767,7 +1767,10 @@ 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/autodoxy.py +include docs/source/_ext/showfile.css +include docs/source/_ext/showfile.js +include docs/source/_ext/showfile.py include docs/source/_templates/breadcrumbs.html include docs/source/app_msg.rst include docs/source/app_s4u.rst @@ -1779,8 +1782,6 @@ include docs/source/img/eclipseScreenShot.png include docs/source/img/extlink.png include docs/source/img/extlink.svg include docs/source/img/graphical-toc.svg -include docs/source/img/lang_cpp.png -include docs/source/img/lang_python.png include docs/source/img/smpi_simgrid_alltoall_pair_16.png include docs/source/img/smpi_simgrid_alltoall_ring_16.png include docs/source/img/zone_hierarchy.png @@ -1810,6 +1811,7 @@ include docs/source/tuto_smpi/gemm_mpi.cpp include docs/source/tuto_smpi/img/big-picture.svg include docs/source/tuto_smpi/img/lu.S.4.png include docs/source/tuto_smpi/roundtrip.c +include examples/README.rst include examples/deprecated/java/.classpath include examples/deprecated/java/.project include examples/deprecated/java/CMakeLists.txt diff --git a/contrib/benchmarking_code_block/inject.h b/contrib/benchmarking_code_block/inject.h index f5a9261ecd..50bab56c41 100644 --- a/contrib/benchmarking_code_block/inject.h +++ b/contrib/benchmarking_code_block/inject.h @@ -86,7 +86,7 @@ static inline void xbt_inject_init(char *inputfile) for (int i = 0; i < (data->n - 1); i++) data->percentage[i] = atof(strtok_r(NULL, "\t", &saveptr)); - xbt_dict_set(mydict, key, data, NULL); + xbt_dict_set(mydict, key, data); } fclose(fpInput); } @@ -139,7 +139,7 @@ static inline void inject_init_starpu(char *inputfile, xbt_dict_t *dict, RngStre data->percentage[i] = atof(strtok_r(NULL, "\t", &saveptr)); } - xbt_dict_set(mydict, key, data, NULL); + xbt_dict_set(mydict, key, data); } fclose(fpInput); } diff --git a/doc/doxygen/inside_extending.doc b/doc/doxygen/inside_extending.doc index b47395fb27..f0f02b6110 100644 --- a/doc/doxygen/inside_extending.doc +++ b/doc/doxygen/inside_extending.doc @@ -55,7 +55,7 @@ and add an entry in the corresponding array in surf_interface.cpp ~~~~ s_surf_model_description_t surf_cpu_model_description[] = { {"Cas01", - "Simplistic CPU model (time=size/power).", + "Simplistic CPU model (time=size/speed).", surf_cpu_model_init_Cas01}, {"Plop", "The new plop CPU model.", diff --git a/docs/Build.sh b/docs/Build.sh index d51e6edc09..8bb15b214d 100755 --- a/docs/Build.sh +++ b/docs/Build.sh @@ -38,30 +38,24 @@ set +x perl -pe 's/(xlink:href="(?:http|.*\.html))/target="_top" $1/' \ source/img/graphical-toc.svg > build/html/graphical-toc.svg -echo "List of missing references:" -for f in $( (grep '' build/xml/msg_8h.xml; \ - grep '' build/xml/namespacesimgrid_1_1s4u.xml; \ - grep ']*>//g' | sort ) +echo +echo "Undocumented examples:" +for ex in $( (cd .. ; \ + find examples/s4u/ -name '*.cpp'; \ + find examples/python -name '*.py'; \ + ) | sort ) do - - if grep $f source/*rst | grep -q '.. doxygen[^::]*:: '"$f"'$' || - grep $f source/*rst | grep -q '.. doxygen[^::]*:: simgrid::[^:]*::[^:]*::'"$f"'$' ; then : -# echo "$f documented" - else - if grep -q $f ignored_symbols ; then : -# echo "$f ignored" # not documented + if grep -q "example-tab:: $ex" ../examples/README.rst ; then : +# echo "found example-tab:: $ex" + elif grep -q "showfile:: $ex" ../examples/README.rst ; then : else - echo "$f" + echo $ex fi - fi done -if [ -e /opt/simgrid ] ; then chmod -x /opt/simgrid; fi - -set +e # Don't fail +set +e # Don't fail if [ -e /usr/bin/linkchecker ] ; then - linkchecker --no-status -o csv --ignore-url='.*\.css$' --ignore-url=public/java/org build/html \ + linkchecker --no-status -o csv --ignore-url='.*\.css$' --ignore-url=build/html/_modules --ignore-url=public/java/org build/html \ | grep -v '^#' \ | grep -v 'urlname;parentname;baseref;result;warningstring' echo "done." diff --git a/docs/find-missing.py b/docs/find-missing.py new file mode 100755 index 0000000000..4e1afee8bf --- /dev/null +++ b/docs/find-missing.py @@ -0,0 +1,203 @@ +#! /usr/bin/env python3 +# -*- coding: utf-8 -*- + +# Copyright (c) 2019. The SimGrid Team. +# All rights reserved. + +# This program is free software; you can redistribute it and/or modify it +# under the terms of the license (GNU LGPL) which comes with this package. + +""" +Search for symbols documented in both the XML files produced by Doxygen and the python modules, +but not documented with autodoxy in the RST files. + +This script is tailored to SimGrid own needs and should be made more generic for autodoxy. +""" + +import fnmatch +import os +import re +import sys +import xml.etree.ElementTree as ET +import inspect + +xml_files = [ + 'build/xml/classsimgrid_1_1s4u_1_1Activity.xml', + 'build/xml/classsimgrid_1_1s4u_1_1Actor.xml', + 'build/xml/classsimgrid_1_1s4u_1_1Barrier.xml', + 'build/xml/classsimgrid_1_1s4u_1_1Comm.xml', + 'build/xml/classsimgrid_1_1s4u_1_1ConditionVariable.xml', + 'build/xml/classsimgrid_1_1s4u_1_1Disk.xml', + 'build/xml/classsimgrid_1_1s4u_1_1Engine.xml', + 'build/xml/classsimgrid_1_1s4u_1_1ExecPar.xml', + 'build/xml/classsimgrid_1_1s4u_1_1ExecSeq.xml', + 'build/xml/classsimgrid_1_1s4u_1_1Exec.xml', + 'build/xml/classsimgrid_1_1s4u_1_1Host.xml', + 'build/xml/classsimgrid_1_1s4u_1_1Io.xml', + 'build/xml/classsimgrid_1_1s4u_1_1Link.xml', + 'build/xml/classsimgrid_1_1s4u_1_1Mailbox.xml', + 'build/xml/classsimgrid_1_1s4u_1_1Mutex.xml', + 'build/xml/classsimgrid_1_1s4u_1_1NetZone.xml', + 'build/xml/classsimgrid_1_1s4u_1_1Semaphore.xml', + 'build/xml/classsimgrid_1_1s4u_1_1VirtualMachine.xml' +] + +python_modules = [ + 'simgrid' +] +python_ignore = [ + 'simgrid.ActorKilled' +] + + +############ Search the python elements in the source, and report undocumented ones +############ + +# data structure in which we store the declaration we find +python_decl = {} + +def handle_python_module(fullname, englobing, elm): + """Recursive function exploring the python modules.""" + + def found_decl(kind, obj): + """Helper function that add an object in the python_decl data structure""" + if kind not in python_decl: python_decl[kind] = [] + python_decl[kind].append(obj) + + + if fullname in python_ignore: + print ("Ignore Python symbol '{}' as requested.".format(fullname)) + return + + if inspect.isroutine(elm) and inspect.isclass(englobing): + found_decl("method", fullname) +# print('.. automethod:: {}'.format(fullname)) + elif inspect.isroutine(elm) and (not inspect.isclass(englobing)): + found_decl("function", fullname) +# print('.. autofunction:: {}'.format(fullname)) + elif inspect.isdatadescriptor(elm): + found_decl("attribute", fullname) +# print('.. autoattribute:: {}'.format(fullname)) + elif isinstance(elm, str) or isinstance(elm, int): # We do have such a data, directly in the SimGrid top module + found_decl("data", fullname) +# print('.. autodata:: {}'.format(fullname)) + elif inspect.ismodule(elm) or inspect.isclass(elm): + for name, data in inspect.getmembers(elm): + if name.startswith('__'): + continue +# print("Recurse on {}.{}".format(fullname, name)) + handle_python_module("{}.{}".format(fullname, name), elm, data) + else: + print('UNHANDLED TYPE {} : {!r} Type: {}'.format(fullname, elm, type(elm))) + +# Start the recursion on the provided Python modules +for name in python_modules: + try: + module = __import__(name) + except Exception: + print("Cannot import {}. Did you set PYTHONPATH=../lib accordingly?".format(name)) + sys.exit(1) + for sub in dir(module): + if sub[0] == '_': + continue + handle_python_module("{}.{}".format(name, sub), module, getattr(module, sub)) + +# Forget about the python declarations that were actually done in the RST +for kind in python_decl: + with os.popen('grep \'[[:blank:]]*auto{}::\' source/*rst|sed \'s/^.*auto{}:: //\''.format(kind, kind)) as pse: + for fullname in (l.strip() for l in pse): + if fullname not in python_decl[kind]: + print("Warning: {} documented but declaration not found in python.".format(fullname)) + else: + python_decl[kind].remove(fullname) +# Dump the missing ones +for kind in python_decl: + for fullname in python_decl[kind]: + print(" .. auto{}:: {}".format(kind, fullname)) + +################ And now deal with Doxygen declarations +################ + +doxy_funs = {} # {classname: {func_name: [args]} } +doxy_vars = {} # {classname: [names]} + +# find the declarations in the XML files +for arg in xml_files[:3]: + if arg[-4:] != '.xml': + print ("Argument '{}' does not end with '.xml'".format(arg)) + continue + print("Parse file {}".format(arg)) + tree = ET.parse(arg) + for elem in tree.findall(".//compounddef"): + if elem.attrib["prot"] != "public": + continue + if "compoundname" in elem: + raise Exception("Compound {} has no 'compoundname' child tag.".format(elem)) + compoundname = elem.find("compoundname").text + #print ("compoundname {}".format(compoundname)) + for member in elem.findall('.//memberdef'): + if member.attrib["prot"] != "public": + continue + kind = member.attrib["kind"] + name = member.find("name").text + if kind == "variable": + if compoundname not in doxy_vars: doxy_vars[compoundname] = [] + doxy_vars[compoundname].append(name) + elif kind == "function": + args = member.find('argsstring').text + args = re.sub('\)[^)]*$', ')', args) # ignore what's after the parameters (eg, '=0' or ' const') + + if compoundname not in doxy_funs: doxy_funs[compoundname] = {} + if name not in doxy_funs[compoundname]: doxy_funs[compoundname][name] = [] + doxy_funs[compoundname][name].append(args) + else: + print ("member {}::{} is of kind {}".format(compoundname, name, kind)) + +# Forget about the declarations that are done in the RST +with os.popen('grep autodoxymethod:: source/*rst|sed \'s/^.*autodoxymethod:: //\'') as pse: + for line in (l.strip() for l in pse): + (klass, obj, args) = (None, None, None) + if "(" in line: + (line, args) = line.split('(', 1) + args = "({}".format(args) + (klass, obj) = line.rsplit('::', 1) + + if klass not in doxy_funs: + print("Warning: {} documented, but class {} not found in doxygen.".format(line, klass)) + continue + if obj not in doxy_funs[klass]: + print("Warning: Object {} documented but not found in {}".format(line, klass)) + elif len(doxy_funs[klass][obj])==1: + del doxy_funs[klass][obj] + elif args not in doxy_funs[klass][obj]: + print("Warning: Function {}{} not found in {}".format(obj, args, klass)) + else: +# print("Found {} in {}".format(line, klass)) + doxy_funs[klass][obj].remove(args) + if len(doxy_funs[klass][obj]) == 0: + del doxy_funs[klass][obj] +with os.popen('grep autodoxyvar:: source/*rst|sed \'s/^.*autodoxyvar:: //\'') as pse: + for line in (l.strip() for l in pse): + (klass, var) = line.rsplit('::', 1) + + if klass not in doxy_vars: + print("Warning: {} documented, but class {} not found in doxygen.".format(line, klass)) + continue + if var not in doxy_vars[klass]: + print("Warning: Object {} documented but not found in {}".format(line, klass)) + else: +# print("Found {} in {}".format(line, klass)) + doxy_vars[klass].remove(var) + if len(doxy_vars[klass]) == 0: + del doxy_vars[klass] + +# Dump the undocumented Doxygen declarations +for obj in sorted(doxy_funs): + for meth in sorted(doxy_funs[obj]): + for args in sorted(doxy_funs[obj][meth]): + print(".. autodoxymethod:: {}::{}{}".format(obj, meth, args)) + +for obj in doxy_vars: + for meth in sorted(doxy_vars[obj]): + print(".. autodoxyvar:: {}::{}".format(obj, meth)) + diff --git a/docs/ignored_symbols b/docs/ignored_symbols index f8f924418b..d039c80c44 100644 --- a/docs/ignored_symbols +++ b/docs/ignored_symbols @@ -15,4 +15,5 @@ MSG_init_nocheck intrusive_ptr_release intrusive_ptr_add_ref get_filtered_netzones_recursive -simgrid::s4u::Storage \ No newline at end of file +simgrid::s4u::Storage +simgrid::s4u::Activity_T diff --git a/docs/requirements.txt b/docs/requirements.txt index 0e101800fd..4302bfe80f 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,4 +1,5 @@ breathe sphinx>=1.8.0 sphinx_rtd_theme +sphinx_tabs javasphinx diff --git a/docs/source/Configuring_SimGrid.rst b/docs/source/Configuring_SimGrid.rst index c629d166ac..db03b0a01c 100644 --- a/docs/source/Configuring_SimGrid.rst +++ b/docs/source/Configuring_SimGrid.rst @@ -5,7 +5,7 @@ Configuring SimGrid .. raw:: html - + -""" - -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/docs/source/_ext/showfile.css b/docs/source/_ext/showfile.css new file mode 100644 index 0000000000..1e3b831334 --- /dev/null +++ b/docs/source/_ext/showfile.css @@ -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 index 0000000000..fd8ae6c4b8 --- /dev/null +++ b/docs/source/_ext/showfile.js @@ -0,0 +1,12 @@ + +$(function() { + /** + * Toggle logic + */ + $('.hidden-content').hide() + $('.toggle-header').click(function () { + $(this).toggleClass("open"); + $(this).next('.toggle-content').toggle('400'); + }) +}); + diff --git a/docs/source/_ext/showfile.py b/docs/source/_ext/showfile.py new file mode 100644 index 0000000000..06845d40ed --- /dev/null +++ b/docs/source/_ext/showfile.py @@ -0,0 +1,164 @@ +# -*- coding: utf-8 -*- + +# Useful doc: https://www.sphinx-doc.org/en/master/extdev/markupapi.html +# Example: https://www.sphinx-doc.org/en/master/development/tutorials/recipe.html + +import os +from docutils.parsers.rst import Directive, directives +from docutils import nodes +from docutils.statemachine import StringList +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. + """ + + has_content = False + optional_arguments = 1 + option_spec = { + 'language': directives.unchanged + } + + def run(self): + + filename = self.arguments[0] + language = "python" + if 'language' in self.options: + language = self.options['language'] + + logger = logging.getLogger(__name__) +# logger.info('showfile {} in {}'.format(filename, language)) + + new_content = [ + '.. toggle-header::', + ' :header: View {}'.format(filename), + '', + ' `Download {} `_'.format(os.path.basename(filename), filename), + '', + ' .. literalinclude:: ../../{}'.format(filename), + ' :language: {}'.format(language), + '' + ] + + for idx, line in enumerate(new_content): +# logger.info('{} {}'.format(idx,line)) + self.content.data.insert(idx, line) + self.content.items.insert(idx, (None, idx)) + + node = nodes.container() + self.state.nested_parse(self.content, self.content_offset, node) + return node.children + +class ExampleTabDirective(Directive): + """ + A group-tab for a given language, in the presentation of the examples. + """ + has_content = True + optional_arguments = 0 + mandatory_argument = 0 + + def run(self): + self.assert_has_content() + + filename = self.content[0].strip() + self.content.trim_start(1) + + (language, langcode) = (None, None) + if filename[-3:] == '.py': + language = 'Python' + langcode = 'py' + elif filename[-4:] == '.cpp': + language = 'C++' + langcode = 'cpp' + elif filename[-4:] == '.xml': + language = 'XML' + langcode = 'xml' + else: + raise Exception("Unknown language '{}'. Please choose '.cpp', '.py' or '.xml'".format(language)) + + for idx, line in enumerate(self.content.data): + self.content.data[idx] = ' ' + line + + for idx, line in enumerate([ + '.. group-tab:: {}'.format(language), + ' ']): + self.content.data.insert(idx, line) + self.content.items.insert(idx, (None, idx)) + + for line in [ + '', + ' .. showfile:: {}'.format(filename), + ' :language: {}'.format(langcode), + '']: + idx = len(self.content.data) + self.content.data.insert(idx, line) + self.content.items.insert(idx, (None, idx)) + +# logger = logging.getLogger(__name__) +# logger.info('------------------') +# for line in self.content.data: +# logger.info('{}'.format(line)) + + node = nodes.container() + self.state.nested_parse(self.content, self.content_offset, node) + return node.children + +class ToggleDirective(Directive): + has_content = True + option_spec = { + 'header': directives.unchanged, + 'show': directives.flag + } + optional_arguments = 1 + + def run(self): + node = nodes.container() + node['classes'].append('toggle-content') + if "show" not in self.options: + # This :show: thing is not working, and I fail to see why. + # Only the hidden-content class gets a call to hide() in the Javascript, + # and :show:n block# still get hidden when I load the page. + # No idea what's going on (Mt) + node['classes'].append('hidden-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): + app.add_directive('toggle-header', ToggleDirective) + app.add_directive('showfile', ShowFileDirective) + app.add_directive('example-tab', ExampleTabDirective) + + app.connect('builder-inited', add_assets) + app.connect('build-finished', copy_assets) + diff --git a/docs/source/app_msg.rst b/docs/source/app_msg.rst index 23f2fea9d9..dbf2749fec 100644 --- a/docs/source/app_msg.rst +++ b/docs/source/app_msg.rst @@ -44,7 +44,6 @@ The basic workflow is the following: .. doxygendefine:: MSG_init .. doxygenfunction:: MSG_launch_application .. doxygenfunction:: MSG_main -.. doxygenfunction:: MSG_set_function Process Management ================== @@ -88,7 +87,6 @@ This describes the process structure :cpp:type:`msg_process_t` and the functions .. doxygenfunction:: MSG_process_sleep .. doxygenfunction:: MSG_process_suspend .. doxygenfunction:: MSG_process_unref -.. doxygenfunction:: MSG_process_userdata_init .. doxygenfunction:: MSG_process_yield Host Management diff --git a/docs/source/app_s4u.rst b/docs/source/app_s4u.rst index 885a6a932d..01aada4b5e 100644 --- a/docs/source/app_s4u.rst +++ b/docs/source/app_s4u.rst @@ -5,7 +5,7 @@ The S4U Interface .. raw:: html - +