@@ -35,7 +35,7 @@ def build_reference_node(app, target_node):
3535
3636class UpdateReferencesToEnumerated (SphinxPostTransform ):
3737 """
38- Check :ref: made to enumerated nodes and update to :numref:
38+ Check :ref: made to enumerated target nodes and update to :numref:
3939 """
4040
4141 default_priority = 5
@@ -71,6 +71,9 @@ def run(self):
7171class ResolveTitlesInExercises (SphinxPostTransform ):
7272 """
7373 Resolve Titles for Exercise Nodes and Enumerated Exercise Nodes
74+ for:
75+ 1. Numbering
76+ 2. Formatting Title and Subtitles into docutils.title node
7477 """
7578
7679 default_priority = 20
@@ -117,10 +120,17 @@ def run(self):
117120
118121def resolve_solution_title (app , node , exercise_node ):
119122 """
120- Resolve Solution Nodes
121- Note: Using a resolver function in case we need to resolve titles
123+ Resolve Titles for Solution Nodes for:
124+
125+ 1. Numbering of Target Exercise Nodes
126+ 2. Formatting Title and Subtitles into docutils.title node
127+ 3. Ensure mathjax is triggered for pages that include path
128+ in titles inherited from Exercise Node
129+
130+ Note: Setup as a resolver function in case we need to resolve titles
122131 in references to solution nodes.
123132 """
133+
124134 title = node .children [0 ]
125135 exercise_title = exercise_node .children [0 ]
126136 if isinstance (title , solution_title ):
@@ -155,10 +165,6 @@ def resolve_solution_title(app, node, exercise_node):
155165
156166
157167class ResolveTitlesInSolutions (SphinxPostTransform ):
158- """
159- Resolve Titles for Solutions Nodes and merge in
160- the main title only from target_nodes
161- """
162168
163169 default_priority = 21
164170
@@ -209,19 +215,19 @@ def run(self):
209215 for child in node .children :
210216 new_node += child
211217 node .replace_self (new_node )
212- if isinstance (target_node , solution_node ):
213- pass
214- # import pdb; pdb.set_trace()
215218 if isinstance (target_node , solution_node ):
219+ # TODO: Check if this condition is required?
220+ if not target_node .resolved_title :
221+ exercise_label = target_node .get ("target_label" )
222+ exercise_target = self .env .sphinx_exercise_registry [
223+ exercise_label
224+ ] # noqa: E501
225+ exercise_node = exercise_target .get ("node" )
226+ target_node = resolve_solution_title (
227+ self .app , target_node , exercise_node
228+ ) # noqa: E501
216229 title_text = target_node .children [0 ].astext ()
217230 inline = node .children [0 ]
218231 inline .children = []
219232 inline += docutil_nodes .Text (title_text )
220233 node .children [0 ] = inline
221-
222- # TODO: Is it possible for the target_node not to be resolved?
223- # if not target_node.resolved_title:
224- # exercise_label = target_node.get("target_label")
225- # exercise_target = self.env.sphinx_exercise_registry[exercise_label] # noqa: E501
226- # exercise_node = exercise_target.get("node")
227- # target_node = resolve_solution_title(self.app, target_node, exercise_node) # noqa: E501
0 commit comments