Giter Club home page Giter Club logo

Comments (2)

delatrie avatar delatrie commented on June 2, 2024 2

It's actually pretty consistent, just not in the intuitive way. Allure renders a description as markdown. Here are several examples:

Paragraph

In your first example the docstring is just a line of text. It's rendered as a paragraph:

Python:

def test_1():
    """First description"""

Docstring value:

First description

Rendered description:

image

Block code

The second example has a docstring consisting of three lines. The first and the last lines are essentially empty and are ignored. The second line is prepended by four spaces, hence is rendered as a block code:

Python:

def test_2():
    """
    Second description
    """

Docstring value:

    Second description
    

Rendered description:

image

Complex description

Now, as you see how it works, it's easy to put something even more complicated into the docstring.

Python:

def test_3():
    """The next line will appear as a block code:

    This is rendered as a block code.

This is a table:

| Name | ID  |
| ---- | --- |
| John | 1   |
| Jane | 2   |

    """

Docstring value:

The next line will appear as a block code:

    This is rendered as a block code.

This is a table:

| Name | ID  |
| ---- | --- |
| John | 1   |
| Jane | 2   |

    

Rendered description:

image

So it's pretty consistent. It's just that raw markdown isn't that convenient to be put in python docstrings. As you see, it makes docstrings quite ugly.

I think we may try to dedent docstrings before putting them to the test's description, so that the third example could be written like this:

def test_3():
    """
    The next line will appear as a block code:
    
    This is rendered as a block code.
    
    This is a table:
    
    | Name | ID  |
    | ---- | --- |
    | John | 1   |
    | Jane | 2   |

    """

That will help making the whole thing more predictable and user-friendly.

from allure-python.

joaonc avatar joaonc commented on June 2, 2024

I think we may try to dedent docstrings before putting them to the test's description

@delatrie Please do! I've been working w/ Allure for several months now and it was nagging at me that we couldn't have formatted text from the docstring, never imagining I needed to dedent! Don't remember seeing this info in any documentation.

Dedenting in code is quite counter-intuitive and doesn't really follow Python aesthetics. Also, some linters like black auto-indent (ie, insert indentation), which makes use of these linters harder or impossible (black doesn't have an option to not indent docstrings).

Dendenting in Allure, like you suggested, would be the way to go.

from allure-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.