code: def pretaxonomy_hook(generator):
      
  
      category_objects = {}
      real_articles = []
  
      for article in generator.articles:
          dirname, fname = os.path.split(article.source_path)
          fname, _ = os.path.splitext(fname)
          if fname == 'index':
              category_objects[dirname] = \
                  make_category(article, os.path.basename(dirname))
          else:
              real_articles.append(article)
  
      category_assignment = \
          re.compile("^(" +
                     "|".join(re.escape(prefix)
                              for prefix in category_objects.keys()) +
                     ")/")
  
      for article in real_articles:
          m = category_assignment.match(article.source_path)
          if not m or m.group(1) not in category_objects:
              logger.error("No category assignment for %s (%s)",
                           article, article.source_path)
              continue
  
          article.category = category_objects[m.group(1)]
          patch_urlformat(article)
  
      generator.articles = real_articles
docs: This hook is invoked before the generator's .categories property is
         filled in. Each article has already been assigned a category
         object, but these objects are _not_ unique per category and so are
         not safe to tack metadata onto (as is).
  
         The category metadata we're looking for is represented as an
         Article object, one per directory, whose filename is 'index.ext'.