Search code examples
pythonpython-sphinx

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.


Solution

  • 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.