[Django] #30255: docutils reports an error when the first line in a docstring is not empty

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #30255: docutils reports an error when the first line in a docstring is not empty

Django
#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 [hidden email].
To post to this group, send email to [hidden email].
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 | Threaded
Open this post in threaded view
|

Re: [Django] #30255: docutils reports an error rendering view docstring when the first line is not empty (was: docutils reports an error when the first line in a docstring is not empty)

Django
#30255: docutils reports an error rendering view docstring when the first line is
not empty
-----------------------------------+------------------------------------
     Reporter:  Manlio Perillo     |                    Owner:  nobody
         Type:  Bug                |                   Status:  new
    Component:  contrib.admindocs  |                  Version:  2.1
     Severity:  Normal             |               Resolution:
     Keywords:                     |             Triage Stage:  Accepted
    Has patch:  0                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+------------------------------------
Changes (by Tim Graham):

 * type:  Uncategorized => Bug
 * stage:  Unreviewed => Accepted


Comment:

 Confirmed the patch fixes the issue, although it crashes for some tests
 with `ValueError: min() arg is an empty sequence`.

--
Ticket URL: <https://code.djangoproject.com/ticket/30255#comment:1>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.fade4f25364d02975927ba588ce48f41%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30255: docutils reports an error rendering view docstring when the first line is not empty

Django
In reply to this post by Django
#30255: docutils reports an error rendering view docstring when the first line is
not empty
-----------------------------------+------------------------------------
     Reporter:  Manlio Perillo     |                    Owner:  nobody
         Type:  Bug                |                   Status:  new
    Component:  contrib.admindocs  |                  Version:  2.1
     Severity:  Normal             |               Resolution:
     Keywords:                     |             Triage Stage:  Accepted
    Has patch:  0                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+------------------------------------

Comment (by Simon Charette):

 We should probably just switch to `inspect.cleandoc` as
 [https://docs.python.org/3/library/inspect.html#inspect.cleandoc it
 implements] the algorithm [https://www.python.org/dev/peps/pep-0257
 /#handling-docstring-indentation defined in PEP257].

--
Ticket URL: <https://code.djangoproject.com/ticket/30255#comment:2>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.1646268f76b6888292d07f6a32242c20%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30255: docutils reports an error rendering view docstring when the first line is not empty

Django
In reply to this post by Django
#30255: docutils reports an error rendering view docstring when the first line is
not empty
-----------------------------------+------------------------------------
     Reporter:  Manlio Perillo     |                    Owner:  nobody
         Type:  Bug                |                   Status:  new
    Component:  contrib.admindocs  |                  Version:  2.1
     Severity:  Normal             |               Resolution:
     Keywords:                     |             Triage Stage:  Accepted
    Has patch:  0                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+------------------------------------

Comment (by Manlio Perillo):

 Replying to [comment:1 Tim Graham]:
 > Confirmed the patch fixes the issue, although it crashes for some tests
 with `ValueError: min() arg is an empty sequence`.

 Yes, I also found it yesterday.  The simple solution is:

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

 The `default` argument was added in Python 3.4, so it is safe to use in
 Django.

--
Ticket URL: <https://code.djangoproject.com/ticket/30255#comment:3>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.c19a63453fc61608c6af285b236b2e69%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30255: docutils reports an error rendering view docstring when the first line is not empty

Django
In reply to this post by Django
#30255: docutils reports an error rendering view docstring when the first line is
not empty
-----------------------------------+------------------------------------
     Reporter:  Manlio Perillo     |                    Owner:  nobody
         Type:  Bug                |                   Status:  new
    Component:  contrib.admindocs  |                  Version:  2.1
     Severity:  Normal             |               Resolution:
     Keywords:                     |             Triage Stage:  Accepted
    Has patch:  0                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+------------------------------------

Comment (by tapaswenipathak):

 Hello folks: Can I PR?

--
Ticket URL: <https://code.djangoproject.com/ticket/30255#comment:4>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.89d017b0878fab96183aa3774f3e3795%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30255: docutils reports an error rendering view docstring when the first line is not empty

Django
In reply to this post by Django
#30255: docutils reports an error rendering view docstring when the first line is
not empty
-------------------------------------+-------------------------------------
     Reporter:  Manlio Perillo       |                    Owner:  Hasan
                                     |  Ramezani
         Type:  Bug                  |                   Status:  assigned
    Component:  contrib.admindocs    |                  Version:  2.1
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

 * owner:  nobody => Hasan Ramezani
 * status:  new => assigned


Comment:

 I can not reproduce on:
 * Python=3.7
 * django=master
 * docutils=0.15.2

 @Manlio Perillo, Could you please help me? I am wrong?

--
Ticket URL: <https://code.djangoproject.com/ticket/30255#comment:5>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.9918cb22973c01c4f77d64c72c190d72%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30255: docutils reports an error rendering view docstring when the first line is not empty

Django
In reply to this post by Django
#30255: docutils reports an error rendering view docstring when the first line is
not empty
-------------------------------------+-------------------------------------
     Reporter:  Manlio Perillo       |                    Owner:  Hasan
                                     |  Ramezani
         Type:  Bug                  |                   Status:  assigned
    Component:  contrib.admindocs    |                  Version:  2.1
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Markus Zapke-GrĂ¼ndemann):

 * cc: Markus Zapke-GrĂ¼ndemann (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/30255#comment:6>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.93f277cf049f760bf8889f43fe99779b%40djangoproject.com.