Driver.hpp

#pragma once

#include "Entity.hpp"

#include <filesystem>
#include <list>
#include <string>
#include <unordered_map>
#include <unordered_set>

class YAMLNode;

/**
 * Driver for running commands
 *
 * @ingroup developer
 */
class Driver {
public:
  /**
   * Constructor.
   */
  Driver();

  /**
   * Read in the configuration file.
   */
  void config();

  /**
   * Create a new configuration file.
   */
  void init();

  /**
   * Build documentation.
   */
  void build();

  /**
   * Watch and build documentation on changes.
   */
  void watch();

  /**
   * Output line coverage information.
   */
  void cover();

  /**
   * Clean documentation.
   */
  void clean();

  /**
   * Markdown style.
   */
  std::string style;

  /**
   * Title.
   */
  std::string title;

  /**
   * Description.
   */
  std::string description;

  /**
   * Coverage file.
   */
  std::filesystem::path coverage;

  /**
   * Output directory.
   */
  std::filesystem::path output;

private:
  /**
   * Parse files.
   */
  void parse();

  /**
   * Count line coverage.
   */
  void count();

  /**
   * Recursively read groups from the configuration file.
   */
  static void groups(YAMLNode& parentNode, Entity& parentEntity);

  /**
   * Root entity.
   */
  Entity root;

  /**
   * Configuration file path.
   */
  std::filesystem::path config_file;

  /**
   * Files patterns.
   */
  std::list<std::string> files_patterns;

  /**
   * Macro definitions.
   */
  std::unordered_map<std::string,std::string> defines;

  /**
   * Files.
   */
  std::unordered_set<std::filesystem::path> filenames;
};