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()
Esempio n. 2
0
import inspect
import os
import sys

'''Make boostnode packages and modules importable via relative paths.'''
path = os.path.abspath(sys.path[0] + 2 * (os.sep + '..'))
if path not in sys.path:
    sys.path.append(path)
if not sys.path[0]:
    sys.path[0] = os.getcwd()

from boostnode import __get_all_modules__

# endregion

__all__ = __get_all_modules__()
'''Determine all modules in this folder via introspection.'''

# region footer

'''
    Preset some variables given by introspection letting the linter know what \
    globale variables are available.
'''
__logger__ = __exception__ = __module_name__ = __file_path__ = \
    __test_mode__ = __test_buffer__ = __test_folder__ = __test_globals__ = None
if __name__ == '__main__':
    from boostnode.extension.system import CommandLine
    '''
        Extends this module with some magic environment variables to provide \
        better introspection support. A generic command line interface for \