How to use the portray.api.as_html function in portray

To help you get started, we’ve selected a few portray examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github timothycrosley / portray / tests / test_api.py View on Github external
with chdir(temporary_dir):
        with open(os.path.join(temporary_dir, "my_module.py"), "w") as pathless_module:
            pathless_module.write("def my_method():\n    pass\n")

        # Rendering with no module identification should fail
        with pytest.raises(Exception):
            api.as_html()

        # With module specification, even without path should succeed
        api.as_html(modules=["my_module"])

        # Unless path auto inclusion is turned off
        with open(os.path.join(temporary_dir, "pyproject.toml"), "w") as pyproject:
            pyproject.write("[tool.portray]\nappend_directory_to_python_path = false")
        with pytest.raises(Exception):
            api.as_html()
github timothycrosley / portray / tests / test_api.py View on Github external
# Directory with no project
        with pytest.raises(exceptions.NoProjectFound):
            api.as_html()

        # Rendering should succeed as soon as a project is within the directory
        temp_project_dir = os.path.join(temporary_dir, "portray")
        shutil.copytree(project_dir, temp_project_dir)
        with chdir(temp_project_dir):
            api.as_html()

            # Rendering a second time should fail
            with pytest.raises(exceptions.DocumentationAlreadyExists):
                api.as_html()

            # Unless we enable overwritting destination
            api.as_html(overwrite=True)

            # Or, we output to a different location
            with tempfile.TemporaryDirectory() as new_temp_directory:
                api.as_html(output_dir=os.path.join(new_temp_directory, "site"))
github timothycrosley / portray / tests / test_api.py View on Github external
def test_as_html_custom_nav(temporary_dir, project_dir, chdir):
    with chdir(temporary_dir):
        temp_project_dir = os.path.join(temporary_dir, "portray")
        shutil.copytree(project_dir, temp_project_dir)
        with chdir(temp_project_dir):
            with open(os.path.join(temp_project_dir, "pyproject.toml"), "w+") as pyproject:
                pyproject.write(CUSTOM_NAV)

            api.as_html()
github timothycrosley / portray / tests / test_api.py View on Github external
# Rendering should succeed as soon as a project is within the directory
        temp_project_dir = os.path.join(temporary_dir, "portray")
        shutil.copytree(project_dir, temp_project_dir)
        with chdir(temp_project_dir):
            api.as_html()

            # Rendering a second time should fail
            with pytest.raises(exceptions.DocumentationAlreadyExists):
                api.as_html()

            # Unless we enable overwritting destination
            api.as_html(overwrite=True)

            # Or, we output to a different location
            with tempfile.TemporaryDirectory() as new_temp_directory:
                api.as_html(output_dir=os.path.join(new_temp_directory, "site"))
github timothycrosley / portray / tests / test_api.py View on Github external
def test_module_no_path(temporary_dir, chdir):
    """Test handling of python modules specified in root project directory but not in path"""
    with chdir(temporary_dir):
        with open(os.path.join(temporary_dir, "my_module.py"), "w") as pathless_module:
            pathless_module.write("def my_method():\n    pass\n")

        # Rendering with no module identification should fail
        with pytest.raises(Exception):
            api.as_html()

        # With module specification, even without path should succeed
        api.as_html(modules=["my_module"])

        # Unless path auto inclusion is turned off
        with open(os.path.join(temporary_dir, "pyproject.toml"), "w") as pyproject:
            pyproject.write("[tool.portray]\nappend_directory_to_python_path = false")
        with pytest.raises(Exception):
            api.as_html()