Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Constify pointer and reference local variables in src/bindings/.
[simgrid.git] / docs / find-missing.py
index 4e1afee..9b0b906 100755 (executable)
@@ -1,8 +1,7 @@
 #! /usr/bin/env python3
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2019. The SimGrid Team.
-# All rights reserved.
+# 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.
@@ -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.
+
+If you are missing some dependencies, try:  pip3 install --requirement docs/requirements.txt
 """
 
 import fnmatch
@@ -39,7 +40,10 @@ 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_1VirtualMachine.xml'
+    'build/xml/classsimgrid_1_1s4u_1_1VirtualMachine.xml',
+    'build/xml/actor_8h.xml',
+    'build/xml/engine_8h.xml',
+    'build/xml/vm_8h.xml'
 ]
 
 python_modules = [
@@ -61,7 +65,8 @@ def handle_python_module(fullname, englobing, elm):
 
     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] = []
+        if kind not in python_decl:
+            python_decl[kind] = []
         python_decl[kind].append(obj)
 
 
@@ -122,34 +127,46 @@ doxy_funs = {} # {classname: {func_name: [args]} }
 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
-    print("Parse file {}".format(arg))
+    #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))
+        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 = ""
+        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
+            #print("kind:{} compoundname:{} name:{}".format( kind,compoundname, name))
             if kind == "variable":
-                if compoundname not in doxy_vars: doxy_vars[compoundname] = []
+                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] = []
+                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)
+            elif kind == "friend":
+                pass # Ignore friendship
             else:
                 print ("member {}::{} is of kind {}".format(compoundname, name, kind))
 
@@ -160,19 +177,24 @@ with os.popen('grep autodoxymethod:: source/*rst|sed \'s/^.*autodoxymethod:: //\
         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]:
-            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:
-#            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]
@@ -200,4 +222,3 @@ for obj in sorted(doxy_funs):
 for obj in doxy_vars:
     for meth in sorted(doxy_vars[obj]):
         print(".. autodoxyvar:: {}::{}".format(obj, meth))
-