LilSpazJoekp / docstrfmt

A formatter for reStructuredText
MIT License
23 stars 15 forks source link

ValueError: Invalid starting width 88 #68

Closed nemesifier closed 4 months ago

nemesifier commented 4 months ago

Trying to run the latest version on this README: https://github.com/openwisp/openwisp-utils/blob/master/README.rst

I see this error:

docstrfmt --check -v README.rst 
ValueError: Invalid starting width 88
Failed to format '/home/nemesis/Code/openwisp/openwisp-utils/README.rst'
1 file were checked.
Done, but 1 error occurred ❌💥❌

I don't understand exactly what's going on. It seems there's one line which triggers this. Sometimes errors pop up but there's no indication of what line is causing them.

Funny thing is that removing the --check option allows the file to be reformatted successfully.

LilSpazJoekp commented 4 months ago

It does not like the nested table. This is a case I hadn't considered.

LilSpazJoekp commented 4 months ago

Try increasing the width or manually edit the nested table to better fit. I'll leave this open because it should be fixed but this is the first case I've seen a nested table and it should theoretically work but it'll need some special handleing. Unlike merged rows, I don't want to not support this use case.

LilSpazJoekp commented 4 months ago

Yeah, I think nested tables won't be easy to support. Docstrfmt has an auto sizing algorithm that doesn't work with nested tables either. I recommend switching many of your tables to a field list like this:

:attribute_1 str: Description for attribute 1.

:attribute_2 str: Description for attribute 2

:attribute_3 str: Description for attribute 3

This will also allow for your attribute tables to be more fluid and formatted in a format that is easier to maintain and edit.

nemesifier commented 4 months ago

@LilSpazJoekp at the moment I would be happy with getting a more informative error message. Can we make it spit out at which line is failing?

LilSpazJoekp commented 4 months ago

Yes it is failing here: https://github.com/openwisp/openwisp-utils/blob/master/README.rst?plain=1#L450

LilSpazJoekp commented 4 months ago

Oh I misread your comment. Let me see if I that is avaliable at the point of failure.

LilSpazJoekp commented 4 months ago

Disregard literally everything I just said. I was able to fix it to support nested tables. Will release a fix for it soon.