Skip to content

Fix: Replace usage of nodes.title by nodes.rubric#50

Closed
payno wants to merge 6 commits into
mainfrom
6-including-ewokstasks-directive-inside-another-directive-breaks-the-document-structure
Closed

Fix: Replace usage of nodes.title by nodes.rubric#50
payno wants to merge 6 commits into
mainfrom
6-including-ewokstasks-directive-inside-another-directive-breaks-the-document-structure

Conversation

@payno

@payno payno commented Jun 2, 2026

Copy link
Copy Markdown
Member

Scope

Closes #6

  • replace usage of nodes.title by nodes.rubric
  • update test
    • Updated test strings to include a title, as restructuredtext.parse requires a document title to avoid errors. While mocking the title was an alternative, explicitly adding a title in the test input is more transparent and reduces reliance on test-specific workarounds. See note
    • assert_task_preamble has been changed because it appears that the nodes.rubric can be interpreted as nodes.subtitles... See dedicated note.

note: CI fails because of an unrelated ruff error.

@payno payno self-assigned this Jun 2, 2026
@codecov

codecov Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment on lines +9 to +15
"""
Title
=====

.. ewokstasks:: ewoksnoexisting.tasks.MyNonExistingTask
:task-type: class
""",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the title because the rubric cannot be the first element. It needs a parent else restructuredtext.parse fails.
It seems the clearer way to fix this. Else we could have mock or maybe used another function than restructuredtext.parse but I haven't saw it.

Comment on lines +17 to +18
assert len(parsed_nodes) == 5
_assert_class_task_nodes(parsed_nodes[1:])

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we just need to 'ignore' the title node.

# warning: A rubric is like an informal heading that doesn’t correspond to the document’s structure, i.e. it does not create a table of contents node.
# see https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#presentational
# so ultimately it can be interpreted different ways.
assert_node(parsed_nodes[0], (nodes.subtitle, nodes.rubric, str), name)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the 'tricky part'. It seems that the rubric is presentational and can be converted to subtitle by DocUtils transform during the parsing.

This transformation can also be defined by themes...

Nevertheless from what I read from the issue and structure this will be better than using nodes.title.

@payno payno changed the title DRAFT: 6 including ewokstasks directive inside another directive breaks the document structure Fix: Replace usage of nodes.title by nodes.rubric Jun 2, 2026
@payno payno added the bug Something isn't working label Jun 2, 2026
@payno payno requested a review from a team June 2, 2026 15:04
Comment on lines 33 to 215
@@ -199,7 +199,7 @@ def additional_model_nodes(
for task in tasks:
for model_name, model_fields in task["submodels"].items():
section = nodes.section("", ids=[model_name])
section.append(nodes.title("", model_name.split(".")[-1]))
section.append(nodes.rubric("", model_name.split(".")[-1]))

section.append(_field_list(directive, {"fields": model_fields}))
model_sections.append(section)
@@ -209,7 +209,7 @@ def additional_model_nodes(

return nodes.section(
"",
nodes.title("", "Additional models"),
nodes.rubric("", "Additional models"),
*model_sections,
ids=["Additional models"],
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are the 'real' modification on the processing side. Others are to update the tests.

@woutdenolf

woutdenolf commented Jun 3, 2026

Copy link
Copy Markdown
Member

Do we still have the tasks in the index/TOC?

For example https://ewoksfluo.readthedocs.io/en/stable/reference/tasks.html

image

@loichuder

Copy link
Copy Markdown
Member

Do we still have the tasks in the index/TOC?

Yes it seems to be the case:

image

Unfortunately, the new rubrics is now at the same visual level than the other rubrics. See for example Additional models:

image

The semantics are still good though so perhaps this could be fixed by some CSS.

@loichuder

Copy link
Copy Markdown
Member

Great effort but since we can't reproduce #6, I'd say we can close this and keep it for future reference in case it happens.

@payno payno closed this Jun 4, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Ewoks dev week - June 2026 Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Including ewokstasks directive inside another directive breaks the document structure

3 participants