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

Question:

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.

Asked By: DennisLi

||

Answers:

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.

Answered By: CodePrinz

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.

Answered By: Peter Trcka
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.