Пример #1
0
def test_style_invalid():
    with pytest.raises(
            MkDocsClickException,
            match=
            "invalid is not a valid option style, which must be either `plain` or `table`."
    ):
        list(make_command_docs("hello", hello, style="invalid"))
Пример #2
0
def test_custom_multicommand(multi):
    """
    Custom `MultiCommand` objects are supported (i.e. not just `Group` multi-commands).
    """
    expected = dedent("""
        # multi

        Multi help

        **Usage:**

        ```
        multi [OPTIONS] COMMAND [ARGS]...
        ```

        **Options:**

        ```
          --help  Show this message and exit.
        ```

        ## hello

        Hello, world!

        **Usage:**

        ```
        multi hello [OPTIONS]
        ```

        **Options:**

        ```
          -d, --debug TEXT  Include debug output
          --help            Show this message and exit.
        ```
        """).lstrip()

    output = "\n".join(make_command_docs("multi", multi))
    assert output == expected
Пример #3
0
def test_custom_multicommand():
    """
    Custom `MultiCommand` objects are supported (i.e. not just `Group` multi-commands).
    """

    multi = MultiCLI("multi", help="Multi help")

    expected = dedent("""
        # multi

        Multi help

        Usage:

        ```
        multi [OPTIONS] COMMAND [ARGS]...
        ```

        ## hello

        Hello, world!

        Usage:

        ```
        multi hello [OPTIONS]
        ```

        Options:

        ```
          -d, --debug TEXT  Include debug output
        ```
        """).lstrip()

    output = "\n".join(make_command_docs("multi", multi))
    assert output == expected
Пример #4
0
def test_prog_name():
    output = "\n".join(make_command_docs("hello-world", hello)).strip()
    assert output == HELLO_EXPECTED.replace("# hello", "# hello-world")
Пример #5
0
def test_depth():
    output = "\n".join(make_command_docs("hello", hello, level=2)).strip()
    assert output == HELLO_EXPECTED.replace("# ", "### ")
Пример #6
0
def test_make_command_docs():
    output = "\n".join(make_command_docs("hello", hello)).strip()
    assert output == HELLO_EXPECTED
Пример #7
0
def test_custom_multicommand_name():
    """Custom multi commands must be given a name."""
    multi = MultiCLI()
    with pytest.raises(MkDocsClickException):
        list(make_command_docs("multi", multi))
Пример #8
0
def test_basic():
    output = "\n".join(make_command_docs("hello", hello))
    assert output == HELLO_EXPECTED
Пример #9
0
def test_style_table(command, expected):
    output = "\n".join(make_command_docs("hello", command, style="table"))
    assert output == expected