doc BUGFIX trees information organization

Remove duplicated groups of schema information and improve overall
organization and coverage for schema and data groups in doxygen.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 217257b..875edc9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -333,6 +333,7 @@
     add_custom_target(doc
             COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
             WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+    string(REPLACE ";" " " DOXY_HEADERS "${headers}")
     configure_file(Doxyfile.in Doxyfile)
 endif()
 
diff --git a/Doxyfile.in b/Doxyfile.in
index 869013f..9abd406 100644
--- a/Doxyfile.in
+++ b/Doxyfile.in
@@ -561,7 +561,7 @@
 # name. If set to NO, the members will appear in declaration order.
 # The default value is: YES.
 
-SORT_MEMBER_DOCS       = NO
+SORT_MEMBER_DOCS       = YES
 
 # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief
 # descriptions of file, namespace and class members alphabetically by member
@@ -569,7 +569,7 @@
 # this will also influence the order of the classes in the class list.
 # The default value is: NO.
 
-SORT_BRIEF_DOCS        = NO
+SORT_BRIEF_DOCS        = YES
 
 # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the
 # (brief and detailed) documentation of class members so that constructors and
@@ -581,14 +581,14 @@
 # detailed member documentation.
 # The default value is: NO.
 
-SORT_MEMBERS_CTORS_1ST = NO
+SORT_MEMBERS_CTORS_1ST = YES
 
 # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy
 # of group names into alphabetical order. If set to NO the group names will
 # appear in their defined order.
 # The default value is: NO.
 
-SORT_GROUP_NAMES       = NO
+SORT_GROUP_NAMES       = YES
 
 # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by
 # fully-qualified names, including namespaces. If set to NO, the class list will
@@ -781,16 +781,7 @@
 # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
 # Note: If this tag is empty the current directory is searched.
 
-INPUT                  = ./src/libyang.h \
-			 ./src/context.h \
-			 ./src/tree.h \
-                         ./src/tree_schema.h \
-                         ./src/plugins_types.h \
-                         ./src/plugins_exts.h \
-                         ./src/tree_data.h \
-                         ./src/log.h \
-                         ./src/set.h \
-                         ./src/dict.h
+INPUT                  = @DOXY_HEADERS@
 
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
diff --git a/src/printer_schema.h b/src/printer_schema.h
index 58fff4c..1162cc2 100644
--- a/src/printer_schema.h
+++ b/src/printer_schema.h
@@ -21,11 +21,13 @@
 #include "printer.h"
 #include "tree_schema.h"
 
+/**
+ * @addtogroup schematree
+ * @{
+ */
 
 /**
  * @defgroup schemaprinterflags Schema output options
- * @ingroup schema
- *
  * @{
  */
 #define LYS_OUTPUT_NO_SUBSTMT        0x10 /**< Print only top-level/referede node information,
@@ -35,9 +37,7 @@
 //#define LYS_OUTOPT_TREE_USES       0x04 /**< Print only uses instead the resolved grouping nodes (only for tree format) */
 //#define LYS_OUTOPT_TREE_NO_LEAFREF 0x08 /**< Do not print the target of leafrefs (only for tree format) */
 
-/**
- * @} schemaprinterflags
- */
+/** @} schemaprinterflags */
 
 /**
  * @brief Schema module printer.
@@ -65,4 +65,6 @@
  */
 ssize_t lys_print_node(struct lyp_out *out, const struct lysc_node *node, LYS_OUTFORMAT format, int line_length, int options);
 
+/** @} schematree */
+
 #endif /* LY_PRINTER_SCHEMA_H_ */
diff --git a/src/tree.h b/src/tree.h
index d1313b7..e63cfc1 100644
--- a/src/tree.h
+++ b/src/tree.h
@@ -24,6 +24,14 @@
 #endif
 
 /**
+ * @defgroup trees Trees
+ *
+ * Generic macros, functions, etc. to work with both [schema](@ref schematree) and [data](@ref datatree) trees.
+ *
+ * @{
+ */
+
+/**
  * @brief Type (i.e. size) of the [sized array](@ref sizedarrays)'s size counter.
  *
  * To print the value via a print format, use LY_PRI_ARRAY_SIZE_TYPE specifier.
@@ -70,13 +78,6 @@
          ++INDEX)
 
 /**
- * @defgroup schematree Schema Tree
- * @{
- *
- * Data structures and functions to manipulate and access schema tree.
- */
-
-/**
  * @brief Get a number of records in the ARRAY.
  *
  * Does not check if array exists!
@@ -165,7 +166,7 @@
  */
 extern const char* ly_data_type2str[LY_DATA_TYPE_COUNT];
 
-/** @} */
+/** @} trees */
 
 #ifdef __cplusplus
 }
diff --git a/src/tree_data.h b/src/tree_data.h
index b3a2ab4..5d7d480 100644
--- a/src/tree_data.h
+++ b/src/tree_data.h
@@ -31,6 +31,7 @@
 
 /**
  * @defgroup datatree Data Tree
+ * @ingroup trees
  * @{
  *
  * Data structures and functions to manipulate and access instance data tree.
diff --git a/src/tree_schema.h b/src/tree_schema.h
index 3fe9466..b3139dc 100644
--- a/src/tree_schema.h
+++ b/src/tree_schema.h
@@ -32,6 +32,14 @@
 #endif
 
 /**
+ * @defgroup schematree Schema Tree
+ * @ingroup trees
+ * @{
+ *
+ * Data structures and functions to manipulate and access schema tree.
+ */
+
+/**
  * @brief Macro to iterate via all elements in a schema tree which can be instantiated in data tree
  * (skips cases, input, output). This is the opening part to the #LYSC_TREE_DFS_END - they always have to be used together.
  *
@@ -577,7 +585,7 @@
 #define LYS_DEV_ADD 2                /**< deviate type add */
 #define LYS_DEV_DELETE 3             /**< deviate type delete */
 #define LYS_DEV_REPLACE 4            /**< deviate type replace */
-/** @} */
+/** @} deviatetypes */
 
 /**
  * @brief Generic deviate structure to get type and cast to lysp_deviate_* structure
@@ -740,7 +748,6 @@
 
 /**
  * @defgroup snodeflags Schema nodes flags
- * @ingroup schematree
  * @{
  */
 #define LYS_CONFIG_W     0x01        /**< config true; also set for input children nodes */
@@ -805,7 +812,7 @@
 #define LYS_ISENUM       0x200       /**< flag to simply distinguish type in struct lysc_type_bitenum_item */
 
 #define LYS_FLAGS_COMPILED_MASK 0xff /**< mask for flags that maps to the compiled structures */
-/** @} */
+/** @} snodeflags */
 
 /**
  * @brief Generic YANG data node
@@ -1206,9 +1213,7 @@
 #define LYS_IFF_AND  0x01 /**< operand "and" */
 #define LYS_IFF_OR   0x02 /**< operand "or" */
 #define LYS_IFF_F    0x03 /**< feature */
-/**
- * @}
- */
+/** @} ifftokens */
 
 /**
  * @brief Compiled YANG revision statement
@@ -1906,8 +1911,6 @@
 
 /**
  * @defgroup sgetnextflags lys_getnext() flags
- * @ingroup schematree
- *
  * @{
  */
 #define LYS_GETNEXT_WITHCHOICE   0x01 /**< lys_getnext() option to allow returning #LYS_CHOICE nodes instead of looking into them */
@@ -2002,7 +2005,7 @@
  */
 const char *lys_nodetype2str(uint16_t nodetype);
 
-/** @} */
+/** @} schematree */
 
 #ifdef __cplusplus
 }