Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fixed tests in activity-lifecycle/testing_test-wait.
[simgrid.git] / docs / find-missing.py
index 17de1216292d525bdaec5894933644b1dc8611a5..c491e382536ebc2ac7dbe42ff563ab86e15d872b 100755 (executable)
@@ -1,8 +1,7 @@
 #! /usr/bin/env python3
 # -*- coding: utf-8 -*-
 
 #! /usr/bin/env python3
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2019. The SimGrid Team.
-# All rights reserved.
+# Copyright (c) 2019-2021. 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.
 
 # 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.
@@ -12,6 +11,8 @@ Search for symbols documented in both the XML files produced by Doxygen and the
 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.
 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.
+
+If you are missing some dependencies, try:  pip3 install --requirement docs/requirements.txt
 """
 
 import fnmatch
 """
 
 import fnmatch
@@ -29,8 +30,6 @@ xml_files = [
     '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_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_1Exec.xml',
     'build/xml/classsimgrid_1_1s4u_1_1Host.xml',
     'build/xml/classsimgrid_1_1s4u_1_1Io.xml',
@@ -39,7 +38,22 @@ xml_files = [
     '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_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'
+    'build/xml/classsimgrid_1_1s4u_1_1VirtualMachine.xml',
+    'build/xml/classsimgrid_1_1xbt_1_1signal_3_01R_07P_8_8_8_08_4.xml',
+    'build/xml/namespacesimgrid_1_1s4u_1_1this__actor.xml',
+    'build/xml/actor_8h.xml',
+    'build/xml/barrier_8h.xml',
+    'build/xml/cond_8h.xml',
+    'build/xml/engine_8h.xml',
+    'build/xml/forward_8h.xml',
+    'build/xml/host_8h.xml',
+    'build/xml/link_8h.xml',
+    'build/xml/mailbox_8h.xml',
+    'build/xml/msg_8h.xml',
+    'build/xml/mutex_8h.xml',
+    'build/xml/semaphore_8h.xml',
+    'build/xml/vm_8h.xml',
+    'build/xml/zone_8h.xml'
 ]
 
 python_modules = [
 ]
 
 python_modules = [
@@ -96,8 +110,17 @@ for name in python_modules:
     try:
         module = __import__(name)
     except Exception:
     try:
         module = __import__(name)
     except Exception:
-        print("Cannot import {}. Did you set PYTHONPATH=../lib accordingly?".format(name))
-        sys.exit(1)
+        if os.path.exists("../lib") and "../lib" not in sys.path:
+            print("Adding ../lib to PYTHONPATH as {} cannot be imported".format(name))
+            sys.path.append("../lib")
+            try:
+                module = __import__(name)
+            except Exception:
+                print("Cannot import {}, even with PYTHONPATH=../lib".format(name))
+                sys.exit(1)
+        else:
+            print("Cannot import {}".format(name))
+            sys.exit(1)
     for sub in dir(module):
         if sub[0] == '_':
             continue
     for sub in dir(module):
         if sub[0] == '_':
             continue
@@ -123,24 +146,33 @@ doxy_funs = {} # {classname: {func_name: [args]} }
 doxy_vars = {} # {classname: [names]}
 
 # find the declarations in the XML files
 doxy_vars = {} # {classname: [names]}
 
 # find the declarations in the XML files
-for arg in xml_files[:3]:
+for arg in xml_files:
     if arg[-4:] != '.xml':
         print ("Argument '{}' does not end with '.xml'".format(arg))
         continue
     if arg[-4:] != '.xml':
         print ("Argument '{}' does not end with '.xml'".format(arg))
         continue
-    print("Parse file {}".format(arg))
+    #print("Parse file {}".format(arg))
     tree = ET.parse(arg)
     for elem in tree.findall(".//compounddef"):
     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))
+        if elem.attrib["kind"] == "class":
+            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))
+        elif elem.attrib["kind"] == "file":
+            compoundname = ""
+        elif elem.attrib["kind"] == "namespace":
+            compoundname = elem.find("compoundname").text
+        else:
+            print("Element {} is of kind {}".format(elem.attrib["id"], elem.attrib["kind"]))
+
         for member in elem.findall('.//memberdef'):
             if member.attrib["prot"] != "public":
                 continue
             kind = member.attrib["kind"]
             name = member.find("name").text
         for member in elem.findall('.//memberdef'):
             if member.attrib["prot"] != "public":
                 continue
             kind = member.attrib["kind"]
             name = member.find("name").text
+            #print("kind:{} compoundname:{} name:{}".format( kind,compoundname, name))
             if kind == "variable":
                 if compoundname not in doxy_vars:
                     doxy_vars[compoundname] = []
             if kind == "variable":
                 if compoundname not in doxy_vars:
                     doxy_vars[compoundname] = []
@@ -154,33 +186,40 @@ for arg in xml_files[:3]:
                 if name not in doxy_funs[compoundname]:
                     doxy_funs[compoundname][name] = []
                 doxy_funs[compoundname][name].append(args)
                 if name not in doxy_funs[compoundname]:
                     doxy_funs[compoundname][name] = []
                 doxy_funs[compoundname][name].append(args)
+            elif kind == "friend":
+                pass # Ignore friendship
             else:
                 print ("member {}::{} is of kind {}".format(compoundname, name, kind))
 
 # Forget about the declarations that are done in the RST
             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:
+with os.popen('grep doxygenfunction:: find-missing.ignore source/*rst|sed \'s/^.*doxygenfunction:: //\'') 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)
     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 '::' in line:
+            (klass, obj) = line.rsplit('::', 1)
+        else:
+            (klass, obj) = ("", line)
 
         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]:
 
         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))
+            print("Warning: Object '{}' documented but not found in '{}'".format(line, klass))
+#            for obj in doxy_funs[klass]:
+#                print("  found: {}::{}".format(klass, obj))
         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:
         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))
+            #print("Found {} in {}".format(line, klass))
             doxy_funs[klass][obj].remove(args)
             if len(doxy_funs[klass][obj]) == 0:
                 del doxy_funs[klass][obj]
             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:
+with os.popen('grep autodoxyvar:: find-missing.ignore source/*rst|sed \'s/^.*autodoxyvar:: //\'') as pse:
     for line in (l.strip() for l in pse):
         (klass, var) = line.rsplit('::', 1)
 
     for line in (l.strip() for l in pse):
         (klass, var) = line.rsplit('::', 1)
 
@@ -199,7 +238,7 @@ with os.popen('grep autodoxyvar:: source/*rst|sed \'s/^.*autodoxyvar:: //\'') as
 for obj in sorted(doxy_funs):
     for meth in sorted(doxy_funs[obj]):
         for args in sorted(doxy_funs[obj][meth]):
 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))
+            print(".. doxygenfunction:: {}::{}{}".format(obj, meth, args))
 
 for obj in doxy_vars:
     for meth in sorted(doxy_vars[obj]):
 
 for obj in doxy_vars:
     for meth in sorted(doxy_vars[obj]):