According to Paul Muller-Ortega, the purpose of a commentary is to orient the reader in the right interpretative direction.
1 Discrimination: Splitting lines into words
As in Devanāgārī all characters are strung together, the first purpose of a commentary is to simply break up the string into specific words. This process is called Pada-Pāṭha.
Due to the rules of Sandhi ambiguity can arise easily, since a string often can be split in multiple grammatically valid ways. The resulting alternative can shift in meaning entirely.
2 Glossing: Establishing Meaning
To specify and develop the meaning of a given word, a commentator may provide a gloss of alternative words.
A specific meaning may be constructed, and specific alternatives may be rejected.
3 Analysis: How things are composed
Examining the meaning of key words, their etymology, illuminating their composition, pointing out connections to other words and concepts.
4 Debate
Argumentative debate, dealing with possible doubts and Possible Objections. Showing how they can be refuted and demonstrated to be untrue.
5 Quotation
The purpose of quotations is to deepen the position of the argument, responding to earlier objections to establish a conviction.