DennisLi
DennisLi

Reputation: 4154

Python Sphinx WARNING: Definition list ends without a blank line; unexpected unindent

My doc is like this:

    def segments(self, start_time=1, end_time=9223372036854775806, offset=0, size=20):
        """Get segments of the model

        :parameter
            offset: - optional int
            size: - optional int
            start_time: - optional string,Segments 
            end_time: - optional string,Segments 
        :return: Segments Object
        """

When I make html, it turns out:

 WARNING: Definition list ends without a blank line; unexpected unindent.

I have no idea where I should add a blank line?

I searched SO, but can not find any similar case as mine.

Upvotes: 17

Views: 28433

Answers (2)

Peter Trcka
Peter Trcka

Reputation: 1521

I had the same error message but the issue was slightly different. I had a multiline parameter description.

    """Get segments of the model
    
    :parameter offset: optional int and this was very long 
    description of the parameter. Which runs over
    multiple lines.
    :return: Segments Object
    """

To solve the issue I had to add indentation for each row in the description. The final code looks like this:

    """Get segments of the model
    
    :parameter offset: optional int and this was a very long 
        description of the parameter. Which runs over
        multiple lines.
    :return: Segments Object
    """

Another confusing aspect was that error did not reference the real problem but rather the file's first function.

Upvotes: 6

CodePrinz
CodePrinz

Reputation: 497

The Question was already answered by jonrsharpe in a comment, but i want to complete it here.

You are using the default Sphinx Style "reStructuredText"

You have to add ":parameter" on every line:

    """Get segments of the model
    
    :parameter offset: optional int
    :parameter size: optional int
    :parameter start_time: optional string,Segments 
    :parameter end_time: optional string,Segments 
    :return: Segments Object
    """

If you had created a dedicated definition list, then you would need an empty line after the last definition. In this case, you can do it, but don't always have to.

Upvotes: 8

Related Questions