示例#1
0
def test_get_section(name, mode):
    def func():
        pass

    section = get_section(Node(func), name, mode)
    section.name == name
    assert not section
示例#2
0
def test_link_from_toc():
    from examples.google_style import ExampleClass

    node = Node(ExampleClass)
    assert len(node.docstring.sections) == 4
    P.transform(node)
    assert len(node.docstring.sections) == 5
    assert "Methods" in node.docstring
    section = node.docstring['Methods']
    html = section.items[0].html
    assert '<a href="#examples.google_style.ExampleClass.message">' in html
示例#3
0
def test_transform_module(module):
    node = Node(module)
    P.transform(node, ["link"])
    q = module.__name__
    section = node.docstring["Functions"]
    assert "add" in section
    item = section["add"]
    item.markdown.startswith("Returns")
    item.html.startswith(f'<a href="#{q}.add">add</a>')
    assert "gen" in section
    section = node.docstring["Classes"]
    assert "ExampleClass" in section
    assert "ExampleDataClass" in section
示例#4
0
def test_transform_class(node):
    P.transform(node)
    section = node.docstring["Methods"]
    q = A.__qualname__
    for name in "fgab":
        assert name in section
        item = section[name]
        item.markdown = name * 3
        item.html.startswith(f'<a href="#{q}.{name}">{name}</a>')
    section = node.docstring["Classes"]
    assert "B" in section
    item = section["B"].markdown == "BBB"
    node = Node(A.B)
    P.transform_class(node)
示例#5
0
def node():
    node = Node(A)
    return node
示例#6
0
def test_is_complete():
    assert is_complete(Node(Base))
    assert not is_complete(Node(Inline))