brechtm / rinohtype

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

Exception occurred when creating pdf from Sphinx #369

Closed techauthoruk closed 1 year ago

techauthoruk commented 1 year ago

Is there an existing issue for this?

Sphinx or rinoh output

(.venv) mark@LAPTOP-GP578BPL:~/SEaB/opmaint$ make rinoh
Running Sphinx v5.1.1
building [mo]: targets for 0 po files that are out of date
building [rinoh]: all documents
updating environment: [new config] 19 added, 0 changed, 0 removed
reading sources... [100%] trouble
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
processing manual... index legal history preface description safety prepare operation maintenance trouble disposal appxI appxII appxIII appxIV appxV appxVI glossary signs resolving references...

Exception occurred:
  File "/home/mark/.venv/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 42, in __getattr__
    raise AttributeError('No such element: {} in {}'.format(name, self))
AttributeError: No such element: entry in <rinoh.frontend.rst.nodes.Row object at 0x7f50f70f91b0>
The full traceback has been saved in /tmp/sphinx-err-azbjp0id.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!
make: *** [Makefile:20: rinoh] Error 2

Source files

As the error message isn't very clear for me to decypher, I am attaching the error log: sphinx-err-azbjp0id.log

I cannot share the source files here, but could send them privately

Versions

rinohtype 0.5.4 (2022-06-17)
Sphinx 5.1.1
Python 3.10.6 (main, Aug 10 2022, 11:40:04) [GCC 11.3.0]
Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-glibc2.35
techauthoruk commented 1 year ago

OK!

So, I have made some progress. My issues were not caused by a single issue, but most of them centred around tables. If I create a table like this (which renders fine to HTML):

image

I get the exception error. Changing the table to look like this:

image

Which is ok, although the tables don't look great without the merged rows / cells: @brechtm why should this formatting cause an issue?

Another issue I came across was the use of the :index: directive. If I added an index entry to a heading or subheading:

:index:`A Heading`
####################

I again get an exception - index entries in body text don't cause an issue.

I'm just glad I can create pdfs again, but it would be nice to know if there is a way to have tables with merged rows / cells in the output - maybe I am creating the tables incorrectly?

brechtm commented 1 year ago

If I create a table like this (which renders fine to HTML):

image

I get the exception error. Changing the table to look like this:

It looks like this case is indeed not handled by rinohtype. I'll fix this.

However, I think this is probably what you want:

+----------------------+------------------------------------------------------+
| System name          | Product X                                            |
+----------------------+------------------------------------------------------+
| Nominal dimensions   | Refer to the Prepare section of this manual          |
+----------------------+                                                      +
| Nominal weight       |                                                      |
+----------------------+------------------------------------------------------+
| Electrical supply    | 400 / 208 V AC |+-| 5 % three phrase 50 / 60 Hz      |
+----------------------+------------------------------------------------------+

If you have all cells in a row spanning two columns as in your first example, there isn't really a difference with no row-spanning.

brechtm commented 1 year ago

If you want to force a line break inside a table cell (or in a regular paragraph, for that matter), you can use a line block:

+----------------------+------------------------------------------------------+
| System name          | Product X                                            |
+----------------------+------------------------------------------------------+
| | Nominal dimensions | Refer to the Prepare section of this manual          |
| | Nominal weight     |                                                      |
+----------------------+------------------------------------------------------+
| Electrical supply    | 400 / 208 V AC |+-| 5 % three phrase 50 / 60 Hz      |
+----------------------+------------------------------------------------------+
brechtm commented 1 year ago

Another issue I came across was the use of the :index: directive. If I added an index entry to a heading or subheading:

:index:`A Heading`
####################

I again get an exception - index entries in body text don't cause an issue.

And you caught yet another bug. This one's fixed too now. Keep'm coming! 😉