brechtm / rinohtype

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

Improve error message for unsupported nodes #421

Open rptb1 opened 11 months ago

rptb1 commented 11 months ago

Is there an existing issue for this?

Sphinx or rinoh output

Traceback (most recent call last):
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 27, in map_node
    return cls._mapping[node_name.replace('-', '_')](node, **context)
KeyError: 'topics'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/sphinx/cmd/build.py", line 281, in build_main
    app.build(args.force_all, args.filenames)
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/sphinx/application.py", line 347, in build
    self.builder.build_update()
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 307, in build_update
    self.build(['__all__'], to_build)
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 376, in build
    self.write(docnames, list(updated_docnames), method)
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/sphinx/__init__.py", line 257, in write
    self.write_document(entry)
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/sphinx/__init__.py", line 263, in write_document
    rinoh_document = self.construct_rinohtype_document(data)
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/sphinx/__init__.py", line 279, in construct_rinohtype_document
    rinoh_tree = from_doctree(doctree, sphinx_builder=self)
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/rst/__init__.py", line 149, in from_doctree
    return mapped_tree.flowable()
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 132, in flowable
    flowable, = self.flowables()
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/rst/__init__.py", line 107, in flowables
    for flowable in super().flowables():
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 137, in flowables
    for i, flowable in enumerate(self.build_flowables()):
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 146, in build_flowables
    yield self.build_flowable()
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 162, in build_flowable
    return self.grouped_flowables_class(self.children_flowables(),
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 125, in children_flowables
    return list(chain(*(item.flowables() for item in children)))
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/rst/__init__.py", line 107, in flowables
    for flowable in super().flowables():
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 137, in flowables
    for i, flowable in enumerate(self.build_flowables()):
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 146, in build_flowables
    yield self.build_flowable()
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 162, in build_flowable
    return self.grouped_flowables_class(self.children_flowables(),
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 125, in children_flowables
    return list(chain(*(item.flowables() for item in children)))
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/rst/__init__.py", line 107, in flowables
    for flowable in super().flowables():
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 137, in flowables
    for i, flowable in enumerate(self.build_flowables()):
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 146, in build_flowables
    yield self.build_flowable()
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/sphinx/nodes.py", line 240, in build_flowable
    return super().build_flowable(id='%' + self.get('docname'), **kwargs)
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 162, in build_flowable
    return self.grouped_flowables_class(self.children_flowables(),
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 125, in children_flowables
    return list(chain(*(item.flowables() for item in children)))
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/rst/__init__.py", line 107, in flowables
    for flowable in super().flowables():
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 137, in flowables
    for i, flowable in enumerate(self.build_flowables()):
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 146, in build_flowables
    yield self.build_flowable()
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 162, in build_flowable
    return self.grouped_flowables_class(self.children_flowables(),
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 125, in children_flowables
    return list(chain(*(item.flowables() for item in children)))
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/rst/__init__.py", line 107, in flowables
    for flowable in super().flowables():
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 137, in flowables
    for i, flowable in enumerate(self.build_flowables()):
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 146, in build_flowables
    yield self.build_flowable()
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 162, in build_flowable
    return self.grouped_flowables_class(self.children_flowables(),
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 125, in children_flowables
    return list(chain(*(item.flowables() for item in children)))
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/rst/__init__.py", line 107, in flowables
    for flowable in super().flowables():
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 137, in flowables
    for i, flowable in enumerate(self.build_flowables()):
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 146, in build_flowables
    yield self.build_flowable()
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/sphinx/nodes.py", line 240, in build_flowable
    return super().build_flowable(id='%' + self.get('docname'), **kwargs)
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 162, in build_flowable
    return self.grouped_flowables_class(self.children_flowables(),
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 125, in children_flowables
    return list(chain(*(item.flowables() for item in children)))
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/rst/__init__.py", line 107, in flowables
    for flowable in super().flowables():
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 137, in flowables
    for i, flowable in enumerate(self.build_flowables()):
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 146, in build_flowables
    yield self.build_flowable()
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 162, in build_flowable
    return self.grouped_flowables_class(self.children_flowables(),
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 125, in children_flowables
    return list(chain(*(item.flowables() for item in children)))
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/rst/__init__.py", line 107, in flowables
    for flowable in super().flowables():
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 137, in flowables
    for i, flowable in enumerate(self.build_flowables()):
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 146, in build_flowables
    yield self.build_flowable()
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 162, in build_flowable
    return self.grouped_flowables_class(self.children_flowables(),
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 124, in children_flowables
    children = self.getchildren()[skip_first:]
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 64, in getchildren
    return [self.map_node(child, **self.context)
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 64, in <listcomp>
    return [self.map_node(child, **self.context)
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 30, in map_node
    raise NotImplementedError("{}:{} the '{}' node is not yet supported "
NotImplementedError: /home/rb/git/mps/manual/source/guide/lang.rst:None the 'topics' node is not yet supported (rinoh.frontend.rst.nodes)

Exception occurred:
  File "/home/rb/git/mps/manual/tool/lib/python3.10/site-packages/rinoh/frontend/__init__.py", line 30, in map_node
    raise NotImplementedError("{}:{} the '{}' node is not yet supported "
NotImplementedError: /home/rb/git/mps/manual/source/guide/lang.rst:None the 'topics' node is not yet supported (rinoh.frontend.rst.nodes)
The full traceback has been saved in /tmp/sphinx-err-9s3hvehp.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:56: pdf] Error 2

Source files

The Sphinx source tree is available at https://github.com/Ravenbrook/mps/tree/branch/2023-10-22/rinohtype-pdf-manual/manual and include instructions for building the manual , but briefly:

git clone --branch branch/2023-10-22/rinohtype-pdf-manual --depth 1 https://github.com/Ravenbrook/mps.git
cd mps
make -C manual pdf

Versions

rb@kiwi:~/tmp/mps/manual$ tool/bin/rinoh --versions
rinohtype 0.5.4 (2022-06-17)
Sphinx 7.2.6
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0]
Linux-6.2.0-34-generic-x86_64-with-glibc2.35
rb@kiwi:~/tmp/mps/manual$ uname -a
Linux kiwi 6.2.0-34-generic #34~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep  7 13:12:03 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
rb@kiwi:~/tmp/mps/manual$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:    22.04
Codename:   jammy
rptb1 commented 11 months ago

You can also edit manual/requirements.pip to read rinohtype @ git+https://github.com/brechtm/rinohtype@master to reproduce on master.

rptb1 commented 11 months ago

You can also view the version of the manual this is based on at https://memory-pool-system--270.org.readthedocs.build/en/270/

brechtm commented 11 months ago

The MPS Sphinx extension defines new admonition types (among other elements). You need to define rinohtype "translator" classes, or, preferably, implement these custom document elements in a backend-independent manner. Please see the discussion in #201 for more information.

rptb1 commented 11 months ago

Many thanks for the pointer. This is a background project so it might be some time before I can get back to it.

Clearly we can't expect rinohtype to cope with arbitrary custom code. Perhaps there's a way to notice it and improve the messages though, so that you don't get further issues like this one.