#30255: docutils reports an error when the first line in a docstring is not 
empty
---------------------------------------------+------------------------
               Reporter:  Manlio Perillo     |          Owner:  nobody
                   Type:  Uncategorized      |         Status:  new
              Component:  contrib.admindocs  |        Version:  2.1
               Severity:  Normal             |       Keywords:
           Triage Stage:  Unreviewed         |      Has patch:  0
    Needs documentation:  0                  |    Needs tests:  0
Patch needs improvement:  0                  |  Easy pickings:  0
                  UI/UX:  0                  |
---------------------------------------------+------------------------
 Currently admindoc works correctly only with  docstrings where the first
 line is empty, and all Django docstrings are formatted in this way.
 However usually the docstring text starts at the first line, e.g.:

 {{{
 def test():
     """test tests something.
     """
 }}}

 and this cause an error:

 {{{
 Error in "default-role" directive:
 no content permitted.

 .. default-role:: cmsreference
 }}}

 The culprit is this code in `trim_docstring`:

 {{{
 indent = min(len(line) - len(line.lstrip()) for line in lines if
 line.lstrip())
 }}}

 The problem is that the indentation of the first line is 0.

 The solution is to skip the first line:

 {{{
 indent = min(len(line) - len(line.lstrip()) for line in lines[1:] if
 line.lstrip())
 }}}

 Thanks.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30255>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.e410368b301b290b41195b5b68d784e3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to