docs: def build_node_data_bag():
      """Builds one 'node' data bag item per file found in the 'nodes' directory
  
      Automatic attributes for a node item:
          'id': It adds data bag 'id', same as filename but with underscores
          'name': same as the filename
          'fqdn': same as the filename (LittleChef filenames should be fqdns)
          'hostname': Uses the first part of the filename as the hostname
              (until it finds a period) minus the .json extension
          'domain': filename minus the first part of the filename (hostname)
              minus the .json extension
      In addition, it will contain the merged attributes from:
          All default cookbook attributes corresponding to the node
          All attributes found in nodes/<item>.json file
          Default and override attributes from all roles
  
      """
      nodes = lib.get_nodes()
      node_data_bag_path = os.path.join('data_bags', 'node')
      # In case there are leftovers
      remove_local_node_data_bag()
      os.makedirs(node_data_bag_path)
      all_recipes = lib.get_recipes()
      all_roles = lib.get_roles()
      for node in nodes:
          # Dots are not allowed (only alphanumeric), substitute by underscores
          node['id'] = node['name'].replace('.', '_')
  
          # Build extended role list
          node['role'] = lib.get_roles_in_node(node)
          node['roles'] = node['role'][:]
          for role in node['role']:
              node['roles'].extend(lib.get_roles_in_role(role))
          node['roles'] = list(set(node['roles']))
  
          # Build extended recipe list
          node['recipes'] = lib.get_recipes_in_node(node)
          # Add recipes found inside each roles in the extended role list
          for role in node['roles']:
              node['recipes'].extend(lib.get_recipes_in_role(role))
          node['recipes'] = list(set(node['recipes']))
  
          # Add node attributes
          _add_merged_attributes(node, all_recipes, all_roles)
          _add_automatic_attributes(node)
  
          # Save node data bag item
          with open(os.path.join(
                    'data_bags', 'node', node['id'] + '.json'), 'w') as f:
              f.write(json.dumps(node))