changeset 370:8f7e9ebf7c96

merge
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 02 Apr 2020 08:40:20 +0200
parents 181b02cea7ab (diff) 6979ebaae833 (current diff)
children cb1d9a5bb043 847996394688
files
diffstat 1 files changed, 36 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Sphinx/source/plugins/python.rst	Wed Apr 01 22:45:01 2020 +0200
+++ b/Sphinx/source/plugins/python.rst	Thu Apr 02 08:40:20 2020 +0200
@@ -348,6 +348,42 @@
   orthanc.RegisterRestCallback('/pydicom/(.*)', DecodeInstance)  # (*)
 
 
+.. _python-introspection:
+
+Inspecting the available API
+............................
+
+.. highlight:: python
+
+Thanks to Python's introspection primitives, it is possible to inspect
+the API of the ``orthanc`` module in order to dump all the available
+features::
+
+  import inspect
+  import numbers
+  import orthanc
+
+  # Loop over the members of the "orthanc" module
+  for (name, obj) in inspect.getmembers(orthanc):
+      if inspect.isroutine(obj):
+          print('Function %s():\n  Documentation: %s\n' % (name, inspect.getdoc(obj)))
+
+      elif inspect.isclass(obj):
+          print('Class %s:\n  Documentation: %s' % (name, inspect.getdoc(obj)))
+
+          # Loop over the members of the class
+          for (subname, subobj) in inspect.getmembers(obj):
+              if isinstance(subobj, numbers.Number):
+                  print('  - Enumeration value %s: %s' % (subname, subobj))
+              elif (not subname.startswith('_') and
+                    inspect.ismethoddescriptor(subobj)):
+                  print('  - Method %s(): %s' % (subname, inspect.getdoc(subobj)))
+          print('')
+
+  
+               
+
+
 Performance and concurrency
 ---------------------------