Преглед на файлове

include auto-generated datatypes to documentation

Julius Pfrommer преди 8 години
родител
ревизия
570510ae13
променени са 3 файла, в които са добавени 27 реда и са изтрити 40 реда
  1. 6 1
      doc/CMakeLists.txt
  2. 1 0
      doc/index.rst
  3. 20 39
      tools/generate_datatypes.py

+ 6 - 1
doc/CMakeLists.txt

@@ -12,14 +12,19 @@ function(generate_rst in out)
 endfunction()
 
 generate_rst(${PROJECT_SOURCE_DIR}/include/ua_types.h ${PROJECT_BINARY_DIR}/doc_src/types.rst)
+generate_rst(${PROJECT_BINARY_DIR}/src_generated/ua_types_generated.h ${PROJECT_BINARY_DIR}/doc_src/types_generated.rst)
 
 add_custom_target(doc_latex ${SPHINX_EXECUTABLE}
   -b latex -c "${PROJECT_BINARY_DIR}/doc_src" "${PROJECT_BINARY_DIR}/doc_src" "${PROJECT_BINARY_DIR}/doc_latex"
   DEPENDS ${PROJECT_BINARY_DIR}/doc_src/types.rst
+  DEPENDS ${PROJECT_BINARY_DIR}/doc_src/types_generated.rst
   COMMENT "Building LaTeX sources for documentation with Sphinx")
+add_dependencies(doc_latex open62541)
+
 add_custom_target(doc ${SPHINX_EXECUTABLE}
   -b html -c "${PROJECT_BINARY_DIR}/doc_src" "${PROJECT_BINARY_DIR}/doc_src" "${PROJECT_BINARY_DIR}/doc"
   COMMAND ${CMAKE_COMMAND} -E copy "${PROJECT_BINARY_DIR}/doc_src/open62541_html.png" "${PROJECT_BINARY_DIR}/doc/_static/"
   DEPENDS ${PROJECT_BINARY_DIR}/doc_src/types.rst
+  DEPENDS ${PROJECT_BINARY_DIR}/doc_src/types_generated.rst
   COMMENT "Building HTML documentation with Sphinx")
-
+add_dependencies(doc open62541)

+ 1 - 0
doc/index.rst

@@ -24,6 +24,7 @@ standard.
    building
    tutorials
    types
+   types_generated
 
    
 Indices and tables

+ 20 - 39
tools/generate_datatypes.py

@@ -478,14 +478,8 @@ def printe(string):
 def printc(string):
     print(string, end='\n', file=fc)
 
-printh('''/**
-* @file ''' + outname + '''_generated.h
-*
-* @brief Autogenerated data types
-*
-* Generated from ''' + inname + ''' with script ''' + sys.argv[0] + '''
-* on host ''' + platform.uname()[1] + ''' by user ''' + getpass.getuser() + ''' at ''' + time.strftime("%Y-%m-%d %I:%M:%S") + '''
-*/
+printh('''/* Generated from ''' + inname + ''' with script ''' + sys.argv[0] + '''
+ * on host ''' + platform.uname()[1] + ''' by user ''' + getpass.getuser() + ''' at ''' + time.strftime("%Y-%m-%d %I:%M:%S") + ''' */
 
 #ifndef ''' + outname.upper() + '''_GENERATED_H_
 #define ''' + outname.upper() + '''_GENERATED_H_
@@ -501,17 +495,12 @@ extern "C" {
  + ('\n#include "ua_types_generated.h"\n' if args.namespace_id != 0 else '') + '''
 
 /**
-* @ingroup types
-*
-* @defgroup ''' + outname + '''_generated Autogenerated ''' + outname + ''' Types
-*
-* @brief Data structures that are autogenerated from an XML-Schema.
-*
-* @{
-*/
+ * Additional Data Type Definitions
+ * ================================
+ */
 ''')
-printh("#define " + outname.upper() + "_COUNT %s\n" % (str(len(types))))
-printh("extern UA_EXPORT const UA_DataType " + outname.upper() + "[];\n")
+printh("#define " + outname.upper() + "_COUNT %s" % (str(len(types))))
+printh("extern UA_EXPORT const UA_DataType " + outname.upper() + "[" + outname.upper() + "_COUNT];")
 
 i = 0
 if sys.version_info[0] < 3:
@@ -520,41 +509,33 @@ else:
     values = types.values()
 
 for t in values:
-    printh("")
+    printh("\n/**\n * " +  t.name)
+    printh(" * " + "-" * len(t.name))
+    if t.description == "":
+        printh(" */")
+    else:
+        printh(" * " + t.description + " */")
     if type(t) != BuiltinType:
-        if t.description != "":
-            printh("/** @brief " + t.description + " */")
-        printh(t.typedef_c())
+        printh(t.typedef_c() + "\n")
     printh("#define " + outname.upper() + "_" + t.name[3:].upper() + " " + str(i))
     printh(t.functions_c(outname.upper()))
     i += 1
 
 printh('''
-/// @} /* end of group */\n
 #ifdef __cplusplus
 } // extern "C"
 #endif\n
 #endif /* %s_GENERATED_H_ */''' % outname.upper())
 
-printe('''/**
-* @file ''' + outname + '''_generated_encoding_binary.h
-*
-* @brief Binary encoding for autogenerated data types
-*
-* Generated from ''' + inname + ''' with script ''' + sys.argv[0] + '''
-* on host ''' + platform.uname()[1] + ''' by user ''' + getpass.getuser() + ''' at ''' + time.strftime("%Y-%m-%d %I:%M:%S") + '''
-*/\n
+printe('''/* Generated from ''' + inname + ''' with script ''' + sys.argv[0] + '''
+ * on host ''' + platform.uname()[1] + ''' by user ''' + getpass.getuser() + ''' at ''' + time.strftime("%Y-%m-%d %I:%M:%S") + ''' */
+ 
 #include "ua_types_encoding_binary.h"
 #include "''' + outname + '''_generated.h"''')
 
-printc('''/**
-* @file ''' + outname + '''_generated.c
-*
-* @brief Autogenerated data types
-*
-* Generated from ''' + inname + ''' with script ''' + sys.argv[0] + '''
-* on host ''' + platform.uname()[1] + ''' by user ''' + getpass.getuser() + ''' at ''' + time.strftime("%Y-%m-%d %I:%M:%S") + '''
-*/\n
+printc('''/* Generated from ''' + inname + ''' with script ''' + sys.argv[0] + '''
+ * on host ''' + platform.uname()[1] + ''' by user ''' + getpass.getuser() + ''' at ''' + time.strftime("%Y-%m-%d %I:%M:%S") + ''' */
+ 
 #include "stddef.h"
 #include "ua_types.h"
 #include "''' + outname + '''_generated.h"\n