Discard the documentation, look at only the fragments.
Find the “top” fragment.
Replace each fragment reference with the appropriate fragment body.
Repeat until there are no more fragment references.
That's the code.