#!/usr/bin/python
# -*- Mode: Python -*-
# Copyright (C) 2015 Mathieu Duponchelle
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
#

import os

from hotdoc.core.doc_tool import doc_tool, ConfigError
from hotdoc.extensions import *

if __name__=="__main__":
    extension_dirs = os.getenv ("HOTDOC_EXTENSION_PATH")
    if extension_dirs:
        for dir_ in extension_dirs.split(':'):
            for f in os.listdir (dir_):
                if f.endswith (".py"):
                    __import__ ("%s.%s" % (dir_, f[:-3]))

    try:
        doc_tool.parse_and_format()
    except ConfigError as e:
        print e
