]> sigrok.org Git - libsigrok.git/commitdiff
python: Give all enum values __doc__ strings.
authorMartin Ling <redacted>
Sun, 25 Oct 2015 14:04:49 +0000 (14:04 +0000)
committerDaniel Elstner <redacted>
Mon, 26 Oct 2015 06:17:01 +0000 (07:17 +0100)
.gitignore
Makefile.am
bindings/python/sigrok/core/classes.i
bindings/swig/doc.py

index 00abc7e4b2f59495534dc7dda9ec946b55e3db08..95b1d5d65f8c902ed9c39251645e5aee6bd015af 100644 (file)
@@ -50,7 +50,8 @@ stamp-h?
 /bindings/python/sigrok/__pycache__/
 /bindings/python/sigrok/core/classes.py
 /bindings/python/sigrok/core/classes_wrap.cpp
-/bindings/python/sigrok/core/doc.i
+/bindings/python/sigrok/core/doc_start.i
+/bindings/python/sigrok/core/doc_end.i
 /bindings/python/sigrok/core/lowlevel.py
 /bindings/python/sigrok/core/lowlevel_wrap.c
 /bindings/python/timestamp
index c47639f71873d0b0c9f9c7695019b424408e8e7e..58115772fbdb5f31458d45268a8dfd6d37835903 100644 (file)
@@ -584,21 +584,27 @@ $(CPPXMLDOC): bindings/cxx/include/libsigrokcxx/libsigrokcxx.hpp \
 if BINDINGS_PYTHON
 
 PDIR = bindings/python
-PDOC = bindings/python/sigrok/core/doc.i
+PDOC_START = bindings/python/sigrok/core/doc_start.i
+PDOC_END = bindings/python/sigrok/core/doc_end.i
 
 setup_vars = VERSION='$(PACKAGE_VERSION)' CC='$(CXX)' CFLAGS='$(AM_CXXFLAGS) $(CXXFLAGS)' LDADD='$(PYSIGROK_LIBS)'
 setup_quiet = --quiet
 setup_py = $(PYTHON) $(srcdir)/$(PDIR)/setup.py $(setup_vars) $(setup_quiet)
 
-$(PDOC): $(srcdir)/bindings/swig/doc.py $(CPPXMLDOC)
+$(PDOC_START): $(srcdir)/bindings/swig/doc.py $(CPPXMLDOC)
        $(AM_V_at)test -d $(PDIR)/sigrok/core || $(MKDIR_P) $(PDIR)/sigrok/core
-       $(AM_V_GEN)$(PYTHON) $(srcdir)/bindings/swig/doc.py python $(CPPXMLDOC) > $@
+       $(AM_V_GEN)$(PYTHON) $(srcdir)/bindings/swig/doc.py python $(CPPXMLDOC) start > $@
+
+$(PDOC_END): $(srcdir)/bindings/swig/doc.py $(CPPXMLDOC)
+       $(AM_V_at)test -d $(PDIR)/sigrok/core || $(MKDIR_P) $(PDIR)/sigrok/core
+       $(AM_V_GEN)$(PYTHON) $(srcdir)/bindings/swig/doc.py python $(CPPXMLDOC) end > $@
 
 python-build: $(PDIR)/timestamp
 
 $(PDIR)/timestamp: $(PDIR)/sigrok/core/classes.i \
-               bindings/swig/classes.i bindings/swig/enums.i $(PDOC) \
-               $(library_include_HEADERS) $(nodist_library_include_HEADERS) \
+               bindings/swig/classes.i bindings/swig/enums.i $(PDOC_START) \
+               $(PDOC_END) $(library_include_HEADERS) \
+               $(nodist_library_include_HEADERS) \
                $(bindings_cxx_libsigrokcxx_la_include_HEADERS) \
                $(nodist_bindings_cxx_libsigrokcxx_la_include_HEADERS) \
                @ORDER@ bindings/cxx/libsigrokcxx.la
index 9dd34ac61caaac6a95c31db812a83b8250e25b2a..46336549609cfc3a46cd665fbb97b6b8c1168db3 100644 (file)
@@ -384,7 +384,7 @@ std::map<std::string, Glib::VariantBase> dict_to_map_options(PyObject *dict,
 %ignore sigrok::InputFormat::create_input;
 %ignore sigrok::OutputFormat::create_output;
 
-%include "doc.i"
+%include "doc_start.i"
 
 %define %attributevector(Class, Type, Name, Get)
 %rename(_ ## Get) sigrok::Class::Get;
@@ -527,3 +527,5 @@ std::map<std::string, Glib::VariantBase> dict_to_map_options(PyObject *dict,
     data = property(_data)
 }
 }
+
+%include "doc_end.i"
index ffde9331f6b045e0f253151f13669b5f114c2ab7..b9e20ade83c70be13a8bab8c686f5816e9a83da9 100644 (file)
@@ -21,7 +21,9 @@ from __future__ import print_function
 from xml.etree import ElementTree
 import sys, os
 
-language, input_file = sys.argv[1:]
+language, input_file = sys.argv[1:3]
+if len(sys.argv) == 4:
+    mode = sys.argv[3]
 input_dir = os.path.dirname(input_file)
 
 index = ElementTree.parse(input_file)
@@ -88,7 +90,14 @@ for compound in index.findall('compound'):
                 trimmed_name, member_name))
         print('%}')
     elif language == 'python' and constants:
-        print('%%extend %s {\n%%pythoncode %%{' % class_name)
-        for member_name, brief in constants:
-            print('    ## @brief %s\n    %s = None' % (brief, member_name))
-        print('%}\n}')
+        if mode == 'start':
+            print('%%extend %s {\n%%pythoncode %%{' % class_name)
+            for member_name, brief in constants:
+                print('    ## @brief %s\n    %s = None' % (brief, member_name))
+            print('%}\n}')
+        elif mode == 'end':
+            print('%pythoncode %{')
+            for member_name, brief in constants:
+                print('%s.%s.__doc__ = """%s"""' % (
+                    trimmed_name, member_name, brief))
+            print('%}')