def main(): '''Generates a python api documentation website.''' if FileHandler('documentation').is_directory(): current_working_directory = FileHandler() index_file = FileHandler('documentation/source/index.rst') modules_to_document = '\ninit' FileHandler( location='%sinit.rst' % index_file.directory.path ).content = ( (79 * '=') + '\n{name}\n' + (79 * '=') + '\n\n.. automodule::' + ' {name}\n :members:' ).format(name=current_working_directory.name) for file in FileHandler(): if Module.is_package(file.path): modules_to_document += '\n %s' % file.name FileHandler(location='%s%s.rst' % ( index_file.directory.path, file.name )).content = ( (79 * '=') + '\n{name}.{package}\n' + (79 * '=') + '\n\n.. automodule:: {name}.{package}\n' ' :members:' ).format( name=current_working_directory.name, package=file.name) for module in __get_all_modules__(file.path): modules_to_document += '\n %s.%s' % (file.name, module) FileHandler(location='%s%s.%s.rst' % ( index_file.directory.path, file.name, module )).content = ( (79 * '=') + '\n{name}.{package}.{module}\n' + (79 * '=') + '\n\n.. automodule:: {name}.{package}.' '{module}\n :members:' ).format( name=current_working_directory.name, package=file.name, module=module) index_file.content = regularExpression.compile( '\n ([a-z][a-zA-Z]+\n)+$', regularExpression.DOTALL ).sub(modules_to_document, index_file.content) Platform.run('/usr/bin/env git add --all', error=False, log=True) FileHandler('documentation').change_working_directory() makefile = FileHandler('Makefile') # # python3.5 FileHandler('MakefilePython3').copy(makefile) FileHandler('MakefilePython2').copy(makefile) Platform.run( command='make html', native_shell=True, error=False, log=True) makefile.remove_file() FileHandler('build/html').path = '../apiDocumentation' FileHandler('build').remove_deep()