コード例 #1
0
def test_get_sidebar_default():
    """
    """
    load_config(exclude=["sidebar"])
    load_and_validate()

    response = config_manager.get("sidebar")
    assert response is False
コード例 #2
0
def test_get_python_default():
    """
    """
    load_config(exclude=["python"])
    load_and_validate()

    response = config_manager.get("python")
    assert response is None
コード例 #3
0
def test_get_title_prefix_default():
    """
    """
    load_config(exclude=["title_prefix"])
    load_and_validate()

    response = config_manager.get("title_prefix")
    assert response == ""
コード例 #4
0
def test_get_sidebar():
    """
    """
    expected = True

    load_config(sidebar=expected)
    load_and_validate()

    response = config_manager.get("sidebar")
    assert response == expected
コード例 #5
0
def test_get_titles():
    """
    """
    expected = [{"source": "mysourcefile.py", "title": "wowsuchdocs"}]

    load_config(titles=expected)
    load_and_validate()

    response = config_manager.get("titles")
    assert response == expected
コード例 #6
0
def test_get_title_prefix():
    """
    """
    expected = "myprefix"

    load_config(title_prefix=expected)
    load_and_validate()

    response = config_manager.get("title_prefix")
    assert response == expected
コード例 #7
0
def test_get_python():
    """
    """
    expected = {
        "include_init_files": True,
        "include_main_file": True,
        "module": "mymod",
    }

    load_config(python=expected)
    load_and_validate()

    response = config_manager.get("python")
    assert response == expected
コード例 #8
0
def main():
    ga = GithubAction(
        "stephend017",
        "pencil-pusher",
        os.environ,
        os.environ["INPUT_GITHUB_TOKEN"],
        {"repository"},
    )

    Documenter.install()

    gh = GithubAPI(ga.inputs["github_token"])

    owner_name = ga.builtins["repository"].split("/")[0]
    repository_name = ga.builtins["repository"].split("/")[1]

    rm = RepoManager(owner_name, repository_name, gh)
    rm.setup()
    rm.install()

    # load configs for the given file
    config_manager.load_config_file(
        f'{rm._repo_path}/{ga.inputs["config_file"]}')
    config_manager.validate()

    langs = config_manager.get_langs()
    extensions = []
    for _, ext_list in langs.items():
        for ext in ext_list:
            extensions.append(ext)

    # transform titles config into usable dict
    titles = {}
    for element in config_manager.get("titles"):
        has_defined_ext = False
        for ext in extensions:
            if element["source"].endswith(f".{ext}"):
                has_defined_ext = True
                titles[element["source"][:-(len(ext) + 1)]] = element["title"]
        if not has_defined_ext:
            titles[element["source"]] = element["title"]

    # only support default for now (repo_name = package_name)
    rm.document(
        sources=config_manager.get("sources"),
        module="" if not config_manager.has("python") else
        config_manager.get("python")["module"],
        title_prefix=config_manager.get("title_prefix"),
        title_suffix=config_manager.get("title_suffix"),
        titles=titles,
        extensions=extensions,
        sidebar=config_manager.get("sidebar"),
    )

    rm.publish()
    rm.cleanup()
コード例 #9
0
def test_get_values():
    """
    tests that config values are loaded properly
    """
    expected = [
        "path1/*",
        "path1/anotherpath/*",
        "path1/anotherpath2/",
        "path1/anotherpath2/file1.py",
    ]

    load_config(sources=expected)
    load_and_validate()

    response = config_manager.get("sources")
    assert len(expected) == len(response)
    for path in expected:
        assert path in response