# Path: uqbar/strings.py
# def normalize(string: str) -> str:
#     """
#     Normalizes whitespace.
# 
#     Strips leading and trailing blank lines, dedents, and removes trailing
#     whitespace from the result.
#     """
#     string = string.replace("\t", "    ")
#     lines = string.split("\n")
#     while lines and (not lines[0] or lines[0].isspace()):
#         lines.pop(0)
#     while lines and (not lines[-1] or lines[-1].isspace()):
#         lines.pop()
#     for i, line in enumerate(lines):
#         lines[i] = line.rstrip()
#     string = "\n".join(lines)
#     string = textwrap.dedent(string)
#     return string


import pathlib
import shutil
import sys
import pytest
import uqbar.apis
from uqbar.strings import normalize
    builder = uqbar.apis.APIBuilder(
        [test_path / "fake_package"],
        test_path / "docs",
        member_documenter_classes=[
            uqbar.apis.FunctionDocumenter,
            uqbar.apis.SummarizingClassDocumenter,
        ],
        module_documenter_class=uqbar.apis.SummarizingModuleDocumenter,
        root_documenter_class=uqbar.apis.SummarizingRootDocumenter,
    )
    builder()
    paths = sorted((test_path / "docs").rglob("*"))
    paths = [str(path.relative_to(test_path)) for path in paths]
    assert paths == [
        "docs/fake_package",
        "docs/fake_package/empty_module.rst",
        "docs/fake_package/empty_package",
        "docs/fake_package/empty_package/empty.rst",
        "docs/fake_package/empty_package/index.rst",
        "docs/fake_package/enums.rst",
        "docs/fake_package/index.rst",
        "docs/fake_package/module.rst",
        "docs/fake_package/multi",
        "docs/fake_package/multi/index.rst",
        "docs/fake_package/multi/one.rst",
        "docs/fake_package/multi/two.rst",
        "docs/index.rst",
    ]
    base_path = test_path / "docs" / "fake_package"
    with (base_path / ".." / "index.rst").open() as file_pointer:

# Path: uqbar/strings.py
# def normalize(string: str) -> str:
#     """
#     Normalizes whitespace.
# 
#     Strips leading and trailing blank lines, dedents, and removes trailing
#     whitespace from the result.
#     """
#     string = string.replace("\t", "    ")
#     lines = string.split("\n")
#     while lines and (not lines[0] or lines[0].isspace()):
#         lines.pop(0)
#     while lines and (not lines[-1] or lines[-1].isspace()):
#         lines.pop()
#     for i, line in enumerate(lines):
#         lines[i] = line.rstrip()
#     string = "\n".join(lines)
#     string = textwrap.dedent(string)
#     return string


# Path: tests/test_apis_SummarizingRootDocumenter.py
import pathlib
import shutil
import sys
import pytest
import uqbar.apis
from uqbar.strings import normalize

    builder = uqbar.apis.APIBuilder(
        [test_path / "fake_package"],
        test_path / "docs",
        member_documenter_classes=[
            uqbar.apis.FunctionDocumenter,
            uqbar.apis.SummarizingClassDocumenter,
        ],
        module_documenter_class=uqbar.apis.SummarizingModuleDocumenter,
        root_documenter_class=uqbar.apis.SummarizingRootDocumenter,
    )
    builder()
    paths = sorted((test_path / "docs").rglob("*"))
    paths = [str(path.relative_to(test_path)) for path in paths]
    assert paths == [
        "docs/fake_package",
        "docs/fake_package/empty_module.rst",
        "docs/fake_package/empty_package",
        "docs/fake_package/empty_package/empty.rst",
        "docs/fake_package/empty_package/index.rst",
        "docs/fake_package/enums.rst",
        "docs/fake_package/index.rst",
        "docs/fake_package/module.rst",
        "docs/fake_package/multi",
        "docs/fake_package/multi/index.rst",
        "docs/fake_package/multi/one.rst",
        "docs/fake_package/multi/two.rst",
        "docs/index.rst",
    ]
    base_path = test_path / "docs" / "fake_package"
    with (base_path / ".." / "index.rst").open() as file_pointer:

        assert normalize(file_pointer.read()) == normalize(