brechtm / rinohtype

The Python document processor
http://www.mos6581.org/rinohtype
GNU Affero General Public License v3.0
498 stars 59 forks source link

Table cause endless loop 'item too long to fit on line (page N)' #413

Closed pdu3hc closed 1 year ago

pdu3hc commented 1 year ago

Is there an existing issue for this?

Sphinx or rinoh output

'item too long to fit on line (page N)'

Source files

In Support_Rinoh\source\modules\WdgM\generated\modification_parameters.txt, If I do not delete table name :ar:error_table_error_table_error_table, I am unable to generate pdf file because the endless loop 'item too long to fit on line (page N)'.

Any workaround for this beside delete the table ? Support_Rinoh.zip

run command 'python -msphinx -M etas_pdf source build'

Versions

rinoh 0.5.4 (2022-06-17)
sphinx-build 1.7.6
python 3.8.2
Windows-10-10.0.19041-SP0
brechtm commented 1 year ago

I'm running into another issue when trying to build:

$ sphinx-build -M rinoh source build
Running Sphinx v6.2.1
building [mo]: targets for 0 po files that are out of date
writing output...
building [rinoh]: all documents
updating environment: [new config] 13 added, 0 changed, 0 removed
reading sources... [100%] modules/WdgM/supported_features
/Users/brechtm/Code/rt_debug/413_Support_Rinoh/source/glossary.rst:12: WARNING: duplicate term description of Samp, other instance in glossary
/Users/brechtm/Code/rt_debug/413_Support_Rinoh/source/glossary.rst:18: WARNING: duplicate term description of Sam, other instance in glossary
/Users/brechtm/Code/rt_debug/413_Support_Rinoh/source/glossary.rst:21: WARNING: duplicate term description of Sam, other instance in glossary
/Users/brechtm/Code/rt_debug/413_Support_Rinoh/source/glossary.rst:24: WARNING: duplicate term description of Sam, other instance in glossary
/Users/brechtm/Code/rt_debug/413_Support_Rinoh/source/glossary.rst:30: WARNING: duplicate term description of Sam, other instance in glossary
/Users/brechtm/Code/rt_debug/413_Support_Rinoh/source/glossary.rst:33: WARNING: duplicate term description of Sa, other instance in glossary
/Users/brechtm/Code/rt_debug/413_Support_Rinoh/source/glossary.rst:36: WARNING: duplicate term description of Samp, other instance in glossary
/Users/brechtm/Code/rt_debug/413_Support_Rinoh/source/glossary.rst:39: WARNING: duplicate term description of Sam, other instance in glossary
/Users/brechtm/Code/rt_debug/413_Support_Rinoh/source/glossary.rst:42: WARNING: duplicate term description of Sam, other instance in glossary
/Users/brechtm/Code/rt_debug/413_Support_Rinoh/source/glossary.rst:45: WARNING: duplicate term description of Sampl, other instance in glossary
/Users/brechtm/Code/rt_debug/413_Support_Rinoh/source/glossary.rst:48: WARNING: duplicate term description of Samp, other instance in glossary
/Users/brechtm/Code/rt_debug/413_Support_Rinoh/source/modules/WdgM/deviations.rst:9: WARNING: Title underline too short.

Sample text
==========
source/modules/WdgM/generated/modification_parameters.txt:11: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/modification_parameters.txt:19: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/modification_parameters.txt:27: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/modification_parameters.txt:37: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/modification_parameters.txt:47: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/modification_parameters.txt:57: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/modification_parameters.txt:67: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/modification_parameters.txt:75: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/modification_parameters.txt:84: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/modification_parameters.txt:93: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/modification_parameters.txt:101: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/modification_parameters.txt:115: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/modification_parameters.txt:123: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/modification_parameters.txt:133: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/modification_parameters.txt:144: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/modification_parameters.txt:155: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/modification_parameters.txt:163: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/modification_parameters.txt:172: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/modification_parameters.txt:180: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/modification_parameters.txt:188: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/modification_parameters.txt:198: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/exclusion_parameters.txt:11: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/exclusion_parameters.txt:12: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/exclusion_parameters.txt:13: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/exclusion_parameters.txt:14: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/exclusion_parameters.txt:15: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/exclusion_parameters.txt:16: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/exclusion_parameters.txt:17: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/exclusion_parameters.txt:18: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/exclusion_parameters.txt:19: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/exclusion_parameters.txt:20: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/exclusion_parameters.txt:21: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/exclusion_parameters.txt:22: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/exclusion_parameters.txt:23: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/exclusion_parameters.txt:24: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/exclusion_parameters.txt:25: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/exclusion_parameters.txt:26: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/exclusion_parameters.txt:27: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/exclusion_parameters.txt:28: ERROR: Unknown interpreted text role "ar".
source/modules/WdgM/generated/exclusion_parameters.txt:29: ERROR: Unknown interpreted text role "ar".
/Users/brechtm/Code/rt_debug/413_Support_Rinoh/source/modules/WdgM/int_advice.rst:89: CRITICAL: Title level inconsistent:

Sample textx
^^^^^^^^^^^^
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
processing RTA-CAR Release Notes_12.2.0dev0... index modules/WdgM/WdgM modules/WdgM/introduction modules/WdgM/supported_features modules/WdgM/extensions modules/WdgM/limitations modules/WdgM/exclusion modules/WdgM/deviations modules/WdgM/api modules/WdgM/conf_advice modules/WdgM/int_advice modules/WdgM/hw_reqs glossary resolving references...

Exception occurred:
  File "/Users/brechtm/Code/rt_debug/413_Support_Rinoh/.venv/lib/python3.11/site-packages/rinoh/resource.py", line 41, in parse_string
    raise ResourceNotFound(cls, resource_name, entry_point_name)
rinoh.resource.ResourceNotFound: (<class 'rinoh.template.DocumentTemplate'>, 'etas_manual', 'etas_manual')
The full traceback has been saved in /var/folders/t3/n6h1s2ss58n5l5llnt6c4zbh0000gn/T/sphinx-err-qsv2ucpq.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!

Please provide a minimal Sphinx project that works in a fresh virtualenv. Are there any other dependencies besides sphinx_rtd_theme and GitPython(?).

pdu3hc commented 1 year ago

Hi @brechtm, I've updated new zip file remove interpreted text role ar.

Support_Rinoh.zip

brechtm commented 1 year ago

That was not the main issue. This is:

Exception occurred:
  File "/Users/brechtm/Code/rt_debug/413_Support_Rinoh/.venv/lib/python3.11/site-packages/rinoh/resource.py", line 41, in parse_string
    raise ResourceNotFound(cls, resource_name, entry_point_name)
rinoh.resource.ResourceNotFound: (<class 'rinoh.template.DocumentTemplate'>, 'etas_manual', 'etas_manual')

The archive is missing your custom template. Please verify in a clean virtualenv that the archive you're providing is self-contained and can reproduce your issue.

jwhitham commented 1 year ago

Hi, thank you for getting back to us. I work with @pdu3hc and I'm also looking at issues relating to our documentation build, having taken one of the tickets relating to this problem.

I've made a reproducer which includes all of the custom packages and a venv setup script. Please could you try again with this:

issue-413-reproduce-infinite-loop-bug.zip

In the root of this zip file I have made a "venv_setup.py" script which does the necessary setup steps for the virtual environment, including installing three custom packages, and also a "run_test.py" script which reproduces the bug. When I run "run_test.py" I see that the progress reaches 65% and then stalls - however, the page count continues to increase, and never seems to finish. I have been able to reproduce the bug on my home computer using Python 3.8, so I am fairly sure that no other internal or unusual packages are needed.

The context is that we're trying to transition from an old Sphinx-based build system to Rinohtype. We don't know much about it yet; the custom template was supplied by another team which already successfully switched to the new tools. We'd like it to terminate with an error if it finds something that it can't fit on a page, so that we can find whatever caused this and reformat it. This may already be possible but we don't know how. If there are any debugging options which might help, I'd be interested to know about them.

Thanks for your support!

brechtm commented 1 year ago

Hi @jwhitham. I was able to track down the issue to _split_minimumrows in the table style definition in your style sheet. Comment it out, and the issue is "fixed".

[table]
margin_left=-2cm
horizontal_align=center
# split_minimum_rows=2

The infinite loop is also triggered even when all content is removed from index.rst. I don't know which table is rendered in that case, but there must be one!

Of course, rinohtype should ideally detect this situation and handle it gracefully. If this feature is important for your project, you can consider sponsoring sponsoring development for it (contact me by mail - see the README).

jwhitham commented 1 year ago

Hi @brechtm thank you so much for your support. This solves the problem and I'm able to build the documents now. I'll report this to the people who made the stylesheet package.