Currently, ve.dm.MWGroupReferences.static.makeGroupRefs is responsible for figuring out the hierarchical reference list numbering for sub-references. However, it has the following characteristics that make it not fit with our future, refactored data model:
- Assumes that all refs (including main refs) are associated with a ve.dm.MWReferenceNode, by iterating over nodeGroup.getFirstNodesInIndexOrder.
- Builds a data structure footnoteNumberLookup keyed on the listKey instead of listIndex.
- Stores its result in MWReferenceNode as a side effect: refNode.setGroupIndex( groupItemIndex ) - here, groupItemIndex is the footnote number, in an abstract form like {1, -1} for "first top-level ref" and {2, 3} for sub-reference numbered "2.3" in English.
We do have QUnit tests in tests/qunit/ve-cite/ve.dm.MWGroupReferences.test.js which run through the important code paths for numbering.
The goal of this task is to reimplement this numbering, in our new paradigm. Specifically:
- Write the new algorithm in ve.dm.MWDataTransitionHelper
- Use a TDD-like approach, building matching QUnit tests along with the logic.
- The basic logical structure *might* be reusable (copy it over), because we leave placeholders for the main refs even when synthetic refs are not available.
- TBD: unknown whether we need the new data structure to be a lookup keyed on listIndex. But we do know that we need the listIndex to be present, so we can find the footnote body when we render the list in later work.
- Feel free to create a totally new type of data structure, the {1, -1} tuples were not that great in hindsight.