coderefinery / sphinx-lesson

Sphinx extension for creating CodeRefinery lessons
https://coderefinery.github.io/sphinx-lesson/
MIT License
15 stars 20 forks source link

Exerciselist doesn't work in the singlehtml build (nor pdf) #107

Open rkdarst opened 1 month ago

rkdarst commented 1 month ago

It's also now causing an exception in python-for-scicomp, which needs immediate fixing. My current hypothesis is that in the singlehtml build it's initializing things in a different order, before the exerciselist node gets init and sets the expected instance attributes. I don't know why it gets ordered this way yet.

Exception occurred:
  File "/home/rkdarst/git/python-for-scicomp/venv/lib/python3.11/site-packages/sphinx_lesson/exerciselist.py", line 128, in process_exerciselist_nodes
    if not is_exercise_node(exercise_node, include_classes=exerciselist_node.include_classes, exclude_classes=exerciselist_node.exclude_classes):
                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'exerciselist' object has no attribute 'include_classes'
  File "/home/rkdarst/git/python-for-scicomp/venv/lib/python3.11/site-packages/sphinx/cmd/build.py", line 337, in build_ma>
    app.build(args.force_all, args.filenames)
  File "/home/rkdarst/git/python-for-scicomp/venv/lib/python3.11/site-packages/sphinx/application.py", line 378, in build
    self.builder.build_update()
  File "/home/rkdarst/git/python-for-scicomp/venv/lib/python3.11/site-packages/sphinx/builders/__init__.py", line 294, in >
    self.build(['__all__'], to_build)
  File "/home/rkdarst/git/python-for-scicomp/venv/lib/python3.11/site-packages/sphinx/builders/__init__.py", line 367, in >
    self.write(docnames, list(updated_docnames), method)
  File "/home/rkdarst/git/python-for-scicomp/venv/lib/python3.11/site-packages/sphinx/builders/singlehtml.py", line 161, i>
    doctree = self.assemble_doctree()
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rkdarst/git/python-for-scicomp/venv/lib/python3.11/site-packages/sphinx/builders/singlehtml.py", line 85, in>
    self.env.resolve_references(tree, master, self)
  File "/home/rkdarst/git/python-for-scicomp/venv/lib/python3.11/site-packages/sphinx/environment/__init__.py", line 699, >
    self.apply_post_transforms(doctree, fromdocname)
  File "/home/rkdarst/git/python-for-scicomp/venv/lib/python3.11/site-packages/sphinx/environment/__init__.py", line 711, >
    transformer.apply_transforms()
  File "/home/rkdarst/git/python-for-scicomp/venv/lib/python3.11/site-packages/sphinx/transforms/__init__.py", line 93, in>
    super().apply_transforms()  # type: ignore[misc]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/rkdarst/git/python-for-scicomp/venv/lib/python3.11/site-packages/docutils/transforms/__init__.py", line 182,>
    transform.apply(**kwargs)
  File "/home/rkdarst/git/python-for-scicomp/venv/lib/python3.11/site-packages/sphinx_lesson/exerciselist.py", line 182, i>
    process_exerciselist_nodes(self.app, doctree, self.env.docname)
  File "/home/rkdarst/git/python-for-scicomp/venv/lib/python3.11/site-packages/sphinx_lesson/exerciselist.py", line 128, i>
    if not is_exercise_node(exercise_node, include_classes=exerciselist_node.include_classes, exclude_classes=exerciselist>
                                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'exerciselist' object has no attribute 'include_classes'
rkdarst commented 1 month ago

My plan is to set class attributes so at least the build works, and then work on solving it later.

The fix isn't much of a regression because even looking at existing lessons like git-intro, the exercise list is missing from the singlehtml and pdf builds.