Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
f
[simgrid.git] / docs / find-missing.py
index 207c4b9..ac61890 100755 (executable)
@@ -1,7 +1,7 @@
 #! /usr/bin/env python3
 # -*- coding: utf-8 -*-
 
-# Copyright (c) 2019-2021. The SimGrid Team. All rights reserved.
+# Copyright (c) 2019-2023. 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.
@@ -15,7 +15,6 @@ This script is tailored to SimGrid own needs.
 If you are missing some dependencies, try:  pip3 install --requirement docs/requirements.txt
 """
 
-import fnmatch
 import os
 import re
 import sys
@@ -49,7 +48,6 @@ xml_files = [
     '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',
@@ -81,7 +79,7 @@ def handle_python_module(fullname, englobing, elm):
 
 
     if fullname in python_ignore:
-        print ("Ignore Python symbol '{}' as requested.".format(fullname))
+        print("Ignore Python symbol '{}' as requested.".format(fullname))
         return
 
     if inspect.isroutine(elm) and inspect.isclass(englobing):
@@ -93,9 +91,12 @@ def handle_python_module(fullname, englobing, elm):
     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
+    elif isinstance(elm, (int, str)): # We do have such a data, directly in the SimGrid top module
         found_decl("data", fullname)
 #        print('.. autodata:: {}'.format(fullname))
+    elif inspect.isclass(type(elm)): # Enum classes are of that kind
+        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('__'):
@@ -103,7 +104,7 @@ def handle_python_module(fullname, englobing, elm):
 #            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)))
+        print('UNHANDLED TYPE {} : {!r} Type: {} Englobing: {} str: {} Members: \n{}\n'.format(fullname, elm, type(elm), englobing, str(elm), inspect.getmembers(elm)))
 
 # Start the recursion on the provided Python modules
 for name in python_modules:
@@ -149,7 +150,7 @@ doxy_type = {} # {classname: [names]}
 # find the declarations in the XML files
 for arg in xml_files:
     if arg[-4:] != '.xml':
-        print ("Argument '{}' does not end with '.xml'".format(arg))
+        print("Argument '{}' does not end with '.xml'".format(arg))
         continue
     #print("Parse file {}".format(arg))
     tree = ET.parse(arg)
@@ -160,7 +161,7 @@ for arg in xml_files:
             if "compoundname" in elem:
                 raise Exception("Compound {} has no 'compoundname' child tag.".format(elem))
             compoundname = elem.find("compoundname").text
-            #print ("compoundname {}".format(compoundname))
+            #print("compoundname {}".format(compoundname))
         elif elem.attrib["kind"] == "file":
             compoundname = ""
         elif elem.attrib["kind"] == "namespace":
@@ -180,7 +181,7 @@ for arg in xml_files:
                 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')
+                args = re.sub(r'\)[^)]*$', ')', args) # ignore what's after the parameters (eg, '=0' or ' const')
 
                 if compoundname not in doxy_funs:
                     doxy_funs[compoundname] = {}
@@ -190,14 +191,14 @@ for arg in xml_files:
             elif kind == "typedef":
                 if compoundname not in doxy_type:
                     doxy_type[compoundname] = []
-                doxy_type[compoundname].append(name)                
+                doxy_type[compoundname].append(name)
             elif kind == "friend":
                 pass # Ignore friendship
             else:
-                print ("member {}::{} is of kind {}".format(compoundname, name, kind))
+                print("member {}::{} is of kind {}".format(compoundname, name, kind))
 
 # Forget about the declarations that are done in the RST
-with os.popen('grep doxygenfunction:: find-missing.ignore source/*rst|sed \'s/^.*doxygenfunction:: //\'') as pse:
+with os.popen('grep doxygenfunction:: find-missing.ignore source/*rst|sed \'s/^.*doxygenfunction:: //\'|sed \'s/ *const//\'') as pse:
     for line in (l.strip() for l in pse):
         (klass, obj, args) = (None, None, None)
         if "(" in line:
@@ -215,7 +216,7 @@ with os.popen('grep doxygenfunction:: find-missing.ignore source/*rst|sed \'s/^.
             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:
+        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))
@@ -256,7 +257,7 @@ with os.popen('grep doxygentypedef:: find-missing.ignore source/*rst|sed \'s/^.*
             if len(doxy_type[klass]) == 0:
                 del doxy_type[klass]
 
-# Dump the undocumented Doxygen declarations 
+# 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]):